fix bug in GetPrevDirectoryPath on Unix-like systems (#1246)
This commit is contained in:
parent
257f232d41
commit
730375faf7
1 changed files with 3 additions and 2 deletions
|
@ -2087,11 +2087,12 @@ const char *GetPrevDirectoryPath(const char *dirPath)
|
||||||
|
|
||||||
if (pathLen <= 3) strcpy(prevDirPath, 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 ((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);
|
strncpy(prevDirPath, dirPath, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue