浏览代码

REVIEWED: GetFileExtension() to include the dot #1523

pull/1627/head
Ray 4 年前
父节点
当前提交
bcc4418ff0
共有 5 个文件被更改,包括 19 次插入19 次删除
  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 查看文件

@ -2351,14 +2351,14 @@ bool DirectoryExists(const char *dirPath)
return result; 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 *GetFileExtension(const char *fileName)
{ {
const char *dot = strrchr(fileName, '.'); const char *dot = strrchr(fileName, '.');
if (!dot || dot == fileName) return NULL; if (!dot || dot == fileName) return NULL;
return p">(dot + 1);
return dot;
} }
// String pointer reverse break: returns right-most occurrence of charset in s // String pointer reverse break: returns right-most occurrence of charset in s

+ 4
- 4
src/raudio.c 查看文件

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

+ 1
- 1
src/raylib.h 查看文件

@ -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 FileExists(const char *fileName); // Check if file exists
RLAPI bool DirectoryExists(const char *dirPath); // Check if a directory path 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 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 *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 *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) RLAPI const char *GetDirectoryPath(const char *filePath); // Get full path for a given fileName with path (uses static string)

+ 3
- 3
src/text.c 查看文件

@ -479,7 +479,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
return font; 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 LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount)
{ {
Font font = { 0 }; Font font = { 0 };
@ -488,8 +488,8 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
strcpy(fileExtLower, TextToLower(fileType)); strcpy(fileExtLower, TextToLower(fileType));
#if defined(SUPPORT_FILEFORMAT_TTF) #if defined(SUPPORT_FILEFORMAT_TTF)
if (TextIsEqual(fileExtLower, "ttf") ||
TextIsEqual(fileExtLower, "otf"))
if (TextIsEqual(fileExtLower, ".ttf") ||
TextIsEqual(fileExtLower, ".otf"))
{ {
font.baseSize = fontSize; font.baseSize = fontSize;
font.charsCount = (charsCount > 0)? charsCount : 95; font.charsCount = (charsCount > 0)? charsCount : 95;

+ 9
- 9
src/textures.c 查看文件

@ -294,7 +294,7 @@ Image LoadImageAnim(const char *fileName, int *frames)
return image; 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 LoadImageFromMemory(const char *fileType, const unsigned char *fileData, int dataSize)
{ {
Image image = { 0 }; Image image = { 0 };
@ -303,28 +303,28 @@ Image LoadImageFromMemory(const char *fileType, const unsigned char *fileData, i
strcpy(fileExtLower, TextToLower(fileType)); strcpy(fileExtLower, TextToLower(fileType));
#if defined(SUPPORT_FILEFORMAT_PNG) #if defined(SUPPORT_FILEFORMAT_PNG)
if ((TextIsEqual(fileExtLower, "png"))
if ((TextIsEqual(fileExtLower, ".png"))
#else #else
if ((false) if ((false)
#endif #endif
#if defined(SUPPORT_FILEFORMAT_BMP) #if defined(SUPPORT_FILEFORMAT_BMP)
|| (TextIsEqual(fileExtLower, "bmp"))
|| (TextIsEqual(fileExtLower, ".bmp"))
#endif #endif
#if defined(SUPPORT_FILEFORMAT_TGA) #if defined(SUPPORT_FILEFORMAT_TGA)
|| (TextIsEqual(fileExtLower, "tga"))
|| (TextIsEqual(fileExtLower, ".tga"))
#endif #endif
#if defined(SUPPORT_FILEFORMAT_JPG) #if defined(SUPPORT_FILEFORMAT_JPG)
|| (TextIsEqual(fileExtLower, "jpg") ||
TextIsEqual(fileExtLower, "jpeg"))
|| (TextIsEqual(fileExtLower, ".jpg") ||
TextIsEqual(fileExtLower, ".jpeg"))
#endif #endif
#if defined(SUPPORT_FILEFORMAT_GIF) #if defined(SUPPORT_FILEFORMAT_GIF)
|| (TextIsEqual(fileExtLower, "gif"))
|| (TextIsEqual(fileExtLower, ".gif"))
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PIC) #if defined(SUPPORT_FILEFORMAT_PIC)
|| (TextIsEqual(fileExtLower, "pic"))
|| (TextIsEqual(fileExtLower, ".pic"))
#endif #endif
#if defined(SUPPORT_FILEFORMAT_PSD) #if defined(SUPPORT_FILEFORMAT_PSD)
|| (TextIsEqual(fileExtLower, "psd"))
|| (TextIsEqual(fileExtLower, ".psd"))
#endif #endif
) )
{ {

正在加载...
取消
保存