mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 11:28:17 +00:00
ADDED: DirectoryExists()
ADDED: GetPrevDirectoryPath()
This commit is contained in:
39
src/core.c
39
src/core.c
@@ -8,7 +8,7 @@
|
|||||||
* - PLATFORM_DESKTOP: FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop)
|
* - PLATFORM_DESKTOP: FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop)
|
||||||
* - PLATFORM_DESKTOP: OSX/macOS
|
* - PLATFORM_DESKTOP: OSX/macOS
|
||||||
* - PLATFORM_ANDROID: Android 4.0 (ARM, ARM64)
|
* - PLATFORM_ANDROID: Android 4.0 (ARM, ARM64)
|
||||||
* - PLATFORM_RPI: Raspberry Pi 0,1,2,3 (Raspbian)
|
* - PLATFORM_RPI: Raspberry Pi 0,1,2,3,4 (Raspbian)
|
||||||
* - PLATFORM_WEB: HTML5 with asm.js (Chrome, Firefox)
|
* - PLATFORM_WEB: HTML5 with asm.js (Chrome, Firefox)
|
||||||
* - PLATFORM_UWP: Windows 10 App, Windows Phone, Xbox One
|
* - PLATFORM_UWP: Windows 10 App, Windows Phone, Xbox One
|
||||||
*
|
*
|
||||||
@@ -1746,6 +1746,21 @@ bool IsFileExtension(const char *fileName, const char *ext)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if a directory path exists
|
||||||
|
bool DirectoryExists(const char *dirPath)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
DIR *dir = opendir(dirPath);
|
||||||
|
|
||||||
|
if (dir != NULL)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
closedir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Get pointer to extension for a filename string
|
// Get pointer to extension for a filename string
|
||||||
const char *GetExtension(const char *fileName)
|
const char *GetExtension(const char *fileName)
|
||||||
{
|
{
|
||||||
@@ -1816,6 +1831,28 @@ const char *GetDirectoryPath(const char *fileName)
|
|||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get previous directory path for a given path
|
||||||
|
const char *GetPrevDirectoryPath(const char *path)
|
||||||
|
{
|
||||||
|
static char prevDir[MAX_FILEPATH_LENGTH];
|
||||||
|
memset(prevDir, 0, MAX_FILEPATH_LENGTH);
|
||||||
|
int pathLen = strlen(path);
|
||||||
|
|
||||||
|
for (int i = (pathLen - 1); i >= 0; i--)
|
||||||
|
{
|
||||||
|
if ((path[i] == '\\') || (path[i] == '/'))
|
||||||
|
{
|
||||||
|
if ((i != (pathLen - 1)) && (path[pathLen - 2] != ':'))
|
||||||
|
{
|
||||||
|
strncpy(prevDir, path, i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return prevDir;
|
||||||
|
}
|
||||||
|
|
||||||
// Get current working directory
|
// Get current working directory
|
||||||
const char *GetWorkingDirectory(void)
|
const char *GetWorkingDirectory(void)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user