diff --git a/src/core.c b/src/core.c index 78a21cc5a..d55bcf3db 100644 --- a/src/core.c +++ b/src/core.c @@ -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 (dot + 1); + return dot; } // String pointer reverse break: returns right-most occurrence of charset in s diff --git a/src/raudio.c b/src/raudio.c index 7fc847fe3..050b37de9 100644 --- a/src/raudio.c +++ b/src/raudio.c @@ -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"); diff --git a/src/raylib.h b/src/raylib.h index 2bd62ae19..21597738f 100644 --- a/src/raylib.h +++ b/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 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) diff --git a/src/text.c b/src/text.c index 5c10dd439..e0b0b324d 100644 --- a/src/text.c +++ b/src/text.c @@ -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; diff --git a/src/textures.c b/src/textures.c index 32d995244..7ef3903d9 100644 --- a/src/textures.c +++ b/src/textures.c @@ -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 ) {