diff --git a/src/raylib.h b/src/raylib.h index e7c449d84..154158131 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1162,6 +1162,7 @@ RLAPI int MakeDirectory(const char *dirPath); // Create di RLAPI int ChangeDirectory(const char *dirPath); // Change working directory, returns 0 on success RLAPI bool IsPathFile(const char *path); // Check if provided path points to a file RLAPI bool IsPathDirectory(const char *path); // Check if provided path points to a directory +RLAPI bool IsPathAbsolute(const char *path); // Check if provided path is an absolute path RLAPI bool IsFileNameValid(const char *fileName); // Check if fileName is valid for the platform/OS RLAPI FilePathList LoadDirectoryFiles(const char *dirPath); // Load directory filepaths, files and directories, no subdirs scan RLAPI FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); // Load directory filepaths with extension filtering and subdir scan; some filters available: '*.*','FILES*','DIRS*' diff --git a/src/rcore.c b/src/rcore.c index b6cfeaabb..80d1cbf11 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -2842,6 +2842,28 @@ bool IsPathDirectory(const char *path) return result; } +// Check if provided path is an absolute path +static bool IsPathAbsolute(const char *path) +{ + int result = false; + + if ((path != NULL) && (path[0] != '\0')) + { +#if defined(_WIN32) + // UNC path (\\server\share) + if ((path[0] == '\\') && (path[1] == '\\')) result = true; + // Drive letter (e.g. C:\ or D:/) + else if (isalpha((unsigned char)path[0]) && (path[1] == ':') && + ((path[2] == '\\') || (path[2] == '/'))) result = true; +#else + // POSIX: must start with / + if (path[0] == '/') result = true; +#endif + } + + return result; +} + // Check if fileName is valid for the platform/OS bool IsFileNameValid(const char *fileName) {