diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/paths.cpp | 12 | ||||
-rw-r--r-- | src/utils/paths.h | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index faa1882e6..04f553ca9 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -20,10 +20,12 @@ #include "utils/paths.h" +#include "utils/stringutils.h" + #include <string.h> #include <cstdarg> #include <cstdio> - +#include <physfs.h> #include <stdlib.h> #ifdef WIN32 @@ -65,3 +67,11 @@ bool checkPath(std::string path) && path.find("/..") == std::string::npos && path.find("\\..") == std::string::npos; } + +std::string &fixDirSeparators(std::string &str) +{ + if (*PHYSFS_getDirSeparator() == '/') + return str; + + return replaceAll(str, "/", "\\"); +} diff --git a/src/utils/paths.h b/src/utils/paths.h index f92fcdcb5..b89671adc 100644 --- a/src/utils/paths.h +++ b/src/utils/paths.h @@ -29,4 +29,6 @@ bool isRealPath(const std::string &str); bool checkPath(std::string path); +std::string &fixDirSeparators(std::string &str); + #endif // UTILS_PATHS_H |