Browse Source

REVIEWED: GetFileExtension() to include the dot #1523

pull/1627/head
Ray 3 years ago
parent
commit
bcc4418ff0
5 changed files with 19 additions and 19 deletions
  1. +2
    -2
      src/core.c
  2. +4
    -4
      src/raudio.c
  3. +1
    -1
      src/raylib.h
  4. +3
    -3
      src/text.c
  5. +9
    -9
      src/textures.c

+ 2
- 2
src/core.c View File

@ -2351,14 +2351,14 @@ bool DirectoryExists(const char *dirPath)
return result;
}
// Get pointer to extension for a filename string
// Get pointer to extension for a filename string (includes the dot: .png)
const char *GetFileExtension(const char *fileName)
{
const char *dot = strrchr(fileName, '.');
if (!dot || dot == fileName) return NULL;
return p">(dot + 1);
return dot;
}
// String pointer reverse break: returns right-most occurrence of charset in s

+ 4
- 4
src/raudio.c View File

@ -732,16 +732,16 @@ Wave LoadWaveFromMemory(const char *fileType, const unsigned char *fileData, int
if (false) { }
#if defined(SUPPORT_FILEFORMAT_WAV)
else if (TextIsEqual(fileExtLower, "wav")) wave = LoadWAV(fileData, dataSize);
else if (TextIsEqual(fileExtLower, ".wav")) wave = LoadWAV(fileData, dataSize);
#endif
#if defined(SUPPORT_FILEFORMAT_OGG)
else if (TextIsEqual(fileExtLower, "ogg")) wave = LoadOGG(fileData, dataSize);
else if (TextIsEqual(fileExtLower, ".ogg")) wave = LoadOGG(fileData, dataSize);
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
else if (TextIsEqual(fileExtLower, "flac")) wave = LoadFLAC(fileData, dataSize);
else if (TextIsEqual(fileExtLower, ".flac")) wave = LoadFLAC(fileData, dataSize);
#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
else if (TextIsEqual(fileExtLower, "mp3")) wave = LoadMP3(fileData, dataSize);
else if (TextIsEqual(fileExtLower, ".mp3")) wave = LoadMP3(fileData, dataSize);
#endif
else TRACELOG(LOG_WARNING, "WAVE: File format not supported");

+ 1
- 1
src/raylib.h View File

@ -998,7 +998,7 @@ RLAPI bool SaveFileText(const char *fileName, char *text); // Save text d
RLAPI bool FileExists(const char *fileName); // Check if file exists
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path exists
RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension (including point: .png, .wav)
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (including point: ".png")
RLAPI const char *GetFileExtension(const char *fileName); // Get pointer to extension for a filename string (includes dot: ".png")
RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string
RLAPI const char *GetFileNameWithoutExt(const char *filePath); // Get filename string without extension (uses static string)
RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string)

+ 3
- 3
src/text.c View File

@ -479,7 +479,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
return font;
}
// Load font from memory buffer, fileType refers to extension: i.e. "ttf"
// Load font from memory buffer, fileType refers to extension: i.e. ".ttf"
Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount)
{
Font font = { 0 };
@ -488,8 +488,8 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
strcpy(fileExtLower, TextToLower(fileType));
#if defined(SUPPORT_FILEFORMAT_TTF)
if (TextIsEqual(fileExtLower, "ttf") ||
TextIsEqual(fileExtLower, "otf"))
if (TextIsEqual(fileExtLower, ".ttf") ||
TextIsEqual(fileExtLower, ".otf"))
{
font.baseSize = fontSize;
font.charsCount = (charsCount > 0)? charsCount : 95;

+ 9
- 9
src/textures.c View File

@ -294,7 +294,7 @@ Image LoadImageAnim(const char *fileName, int *frames)
return image;
}
// Load image from memory buffer, fileType refers to extension: i.e. "png"
// Load image from memory buffer, fileType refers to extension: i.e. ".png"
Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize)
{
Image image = { 0 };
@ -303,28 +303,28 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
strcpy(fileExtLower, TextToLower(fileType));
#if defined(SUPPORT_FILEFORMAT_PNG)
if ((TextIsEqual(fileExtLower, "png"))
if ((TextIsEqual(fileExtLower, ".png"))
#else
if ((false)
#endif
#if defined(SUPPORT_FILEFORMAT_BMP)
|| (TextIsEqual(fileExtLower, "bmp"))
|| (TextIsEqual(fileExtLower, ".bmp"))
#endif
#if defined(SUPPORT_FILEFORMAT_TGA)
|| (TextIsEqual(fileExtLower, "tga"))
|| (TextIsEqual(fileExtLower, ".tga"))
#endif
#if defined(SUPPORT_FILEFORMAT_JPG)
|| (TextIsEqual(fileExtLower, "jpg") ||
TextIsEqual(fileExtLower, "jpeg"))
|| (TextIsEqual(fileExtLower, ".jpg") ||
TextIsEqual(fileExtLower, ".jpeg"))
#endif
#if defined(SUPPORT_FILEFORMAT_GIF)
|| (TextIsEqual(fileExtLower, "gif"))
|| (TextIsEqual(fileExtLower, ".gif"))
#endif
#if defined(SUPPORT_FILEFORMAT_PIC)
|| (TextIsEqual(fileExtLower, "pic"))
|| (TextIsEqual(fileExtLower, ".pic"))
#endif
#if defined(SUPPORT_FILEFORMAT_PSD)
|| (TextIsEqual(fileExtLower, "psd"))
|| (TextIsEqual(fileExtLower, ".psd"))
#endif
)
{

Loading…
Cancel
Save