diff options
Diffstat (limited to 'src/common/file_util.cpp')
| -rw-r--r-- | src/common/file_util.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 1bc291cf9..b8dd92b65 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -826,7 +826,7 @@ std::string_view GetPathWithoutTop(std::string_view path) { | |||
| 826 | } | 826 | } |
| 827 | 827 | ||
| 828 | while (path[0] == '\\' || path[0] == '/') { | 828 | while (path[0] == '\\' || path[0] == '/') { |
| 829 | path.remove_suffix(1); | 829 | path.remove_prefix(1); |
| 830 | if (path.empty()) { | 830 | if (path.empty()) { |
| 831 | return path; | 831 | return path; |
| 832 | } | 832 | } |
| @@ -870,6 +870,15 @@ std::string_view RemoveTrailingSlash(std::string_view path) { | |||
| 870 | return path; | 870 | return path; |
| 871 | } | 871 | } |
| 872 | 872 | ||
| 873 | std::string SanitizePath(std::string_view path_) { | ||
| 874 | std::string path(path_); | ||
| 875 | std::replace(path.begin(), path.end(), '\\', '/'); | ||
| 876 | path.erase(std::unique(path.begin(), path.end(), | ||
| 877 | [](char c1, char c2) { return c1 == '/' && c2 == '/'; }), | ||
| 878 | path.end()); | ||
| 879 | return std::string(RemoveTrailingSlash(path)); | ||
| 880 | } | ||
| 881 | |||
| 873 | IOFile::IOFile() {} | 882 | IOFile::IOFile() {} |
| 874 | 883 | ||
| 875 | IOFile::IOFile(const std::string& filename, const char openmode[], int flags) { | 884 | IOFile::IOFile(const std::string& filename, const char openmode[], int flags) { |