aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2019-08-07 00:26:33 +0200
committerRay <raysan5@gmail.com>2019-08-07 00:26:33 +0200
commitb354c1007206e13ce3d6fe8cc6eea486c69b1a2b (patch)
tree12bcfcb9f9d75d4bec2e2d6ab8e76fcbfa7b9e40 /src
parent6267fd1865a1354cf059567bdbcf56d802e5403b (diff)
downloadraylib-b354c1007206e13ce3d6fe8cc6eea486c69b1a2b.tar.gz
raylib-b354c1007206e13ce3d6fe8cc6eea486c69b1a2b.zip
ADDED: DirectoryExists()
ADDED: GetPrevDirectoryPath()
Diffstat (limited to 'src')
-rw-r--r--src/core.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/core.c b/src/core.c
index 6bb12619..1dad59d9 100644
--- a/src/core.c
+++ b/src/core.c
@@ -8,7 +8,7 @@
* - PLATFORM_DESKTOP: FreeBSD, OpenBSD, NetBSD, DragonFly (X11 desktop)
* - PLATFORM_DESKTOP: OSX/macOS
* - 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_UWP: Windows 10 App, Windows Phone, Xbox One
*
@@ -1746,6 +1746,21 @@ bool IsFileExtension(const char *fileName, const char *ext)
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
const char *GetExtension(const char *fileName)
{
@@ -1816,6 +1831,28 @@ const char *GetDirectoryPath(const char *fileName)
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
const char *GetWorkingDirectory(void)
{