diff options
| author | Ray <raysan5@gmail.com> | 2019-08-07 00:26:33 +0200 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2019-08-07 00:26:33 +0200 |
| commit | b354c1007206e13ce3d6fe8cc6eea486c69b1a2b (patch) | |
| tree | 12bcfcb9f9d75d4bec2e2d6ab8e76fcbfa7b9e40 /src | |
| parent | 6267fd1865a1354cf059567bdbcf56d802e5403b (diff) | |
| download | raylib-b354c1007206e13ce3d6fe8cc6eea486c69b1a2b.tar.gz raylib-b354c1007206e13ce3d6fe8cc6eea486c69b1a2b.zip | |
ADDED: DirectoryExists()
ADDED: GetPrevDirectoryPath()
Diffstat (limited to 'src')
| -rw-r--r-- | src/core.c | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -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) { |
