ADDED: IsPathAbsolute() to check absolute paths
This commit is contained in:
parent
b806e3d2ec
commit
cfccb83ddd
1 changed files with 23 additions and 0 deletions
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue