mirror of
https://github.com/raysan5/raylib.git
synced 2026-07-30 20:37:47 +00:00
ADDED: IsPathAbsolute() to check absolute paths
This commit is contained in:
@@ -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*'
|
||||
|
||||
22
src/rcore.c
22
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user