diff --git a/src/core.c b/src/core.c index 60bc58b8..371a22ee 100644 --- a/src/core.c +++ b/src/core.c @@ -1174,7 +1174,7 @@ bool IsFileExtension(const char *fileName, const char *ext) return result; } -// Get the extension for a filename +// Get pointer to extension for a filename string const char *GetExtension(const char *fileName) { const char *dot = strrchr(fileName, '.'); @@ -1184,6 +1184,17 @@ const char *GetExtension(const char *fileName) return (dot + 1); } +// Get pointer to filename for a path string +const char *GetFileName(const char *filePath) +{ + const char *fileName = strrchr(filePath, '\\'); + + if (!fileName || fileName == filePath) return filePath; + + return fileName + 1; +} + + // Get directory for a given fileName (with path) const char *GetDirectoryPath(const char *fileName) { diff --git a/src/raylib.h b/src/raylib.h index 3e2dbe0c..75bd883d 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -736,9 +736,10 @@ RLAPI int GetRandomValue(int min, int max); // Returns a r // Files management functions RLAPI bool IsFileExtension(const char *fileName, const char *ext);// Check file extension -RLAPI const char *GetExtension(const char *fileName); // Get file extension -RLAPI const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path) -RLAPI const char *GetWorkingDirectory(void); // Get current working directory +RLAPI const char *GetExtension(const char *fileName); // Get pointer to extension for a filename string +RLAPI const char *GetFileName(const char *filePath); // Get pointer to filename for a path string +RLAPI const char *GetDirectoryPath(const char *fileName); // Get full path for a given fileName (uses static string) +RLAPI const char *GetWorkingDirectory(void); // Get current working directory (uses static string) RLAPI bool ChangeDirectory(const char *dir); // Change working directory, returns true if success RLAPI bool IsFileDropped(void); // Check if a file has been dropped into window RLAPI char **GetDroppedFiles(int *count); // Get dropped files names