summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorivn <[email protected]>2020-05-14 18:30:32 +0300
committerGitHub <[email protected]>2020-05-14 17:30:32 +0200
commit730375faf738790b32e31f668813443ecdfd8150 (patch)
treed4ca5bd2c57861858861460be9bb4e114a865059 /src
parent257f232d418cd0e8dc6aef409a16defca044fa1a (diff)
downloadraylib-730375faf738790b32e31f668813443ecdfd8150.tar.gz
raylib-730375faf738790b32e31f668813443ecdfd8150.zip
fix bug in GetPrevDirectoryPath on Unix-like systems (#1246)
Diffstat (limited to 'src')
-rw-r--r--src/core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/core.c b/src/core.c
index 33caac51..ac77138c 100644
--- a/src/core.c
+++ b/src/core.c
@@ -2087,11 +2087,12 @@ const char *GetPrevDirectoryPath(const char *dirPath)
if (pathLen <= 3) strcpy(prevDirPath, dirPath);
- for (int i = (pathLen - 1); (i > 0) && (pathLen > 3); i--)
+ for (int i = (pathLen - 1); (i >= 0) && (pathLen > 3); i--)
{
if ((dirPath[i] == '\\') || (dirPath[i] == '/'))
{
- if (i == 2) i++; // Check for root: "C:\"
+ if ((i == 2) && (dirPath[1] ==':') // Check for root: "C:\"
+ || i == 0) i++; // Check for root: "/"
strncpy(prevDirPath, dirPath, i);
break;
}