diff --git a/src/common/file_system.cpp b/src/common/file_system.cpp index e3da145c8..53445e00b 100644 --- a/src/common/file_system.cpp +++ b/src/common/file_system.cpp @@ -75,6 +75,9 @@ void CanonicalizePath(char* Destination, u32 cbDestination, const char* Path, bo // remove the previous \, if we have one trailing the dot it'll append it anyway if (destinationLength > 0) Destination[--destinationLength] = '\0'; + // if there was no previous \, skip past the next one + else if (nextCh != '\0') + i++; continue; } @@ -126,6 +129,10 @@ void CanonicalizePath(char* Destination, u32 cbDestination, const char* Path, bo i++; } + // if we end up with the empty string, return '.' + if (destinationLength == 0) + Destination[destinationLength++] = '.'; + // ensure nullptr termination if (destinationLength < cbDestination) Destination[destinationLength] = '\0';