summaryrefslogtreecommitdiff
path: root/src/common/file_util.cpp
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-07-23 22:40:35 -0400
committerGravatar bunnei2018-07-23 19:40:35 -0700
commit59cb258409c5cbd6cdc9cc6a6f8e858603924a2b (patch)
treec024d285fe63daae9d73ef07800349a065768672 /src/common/file_util.cpp
parentMerge pull request #787 from bunnei/tlds (diff)
downloadyuzu-59cb258409c5cbd6cdc9cc6a6f8e858603924a2b.tar.gz
yuzu-59cb258409c5cbd6cdc9cc6a6f8e858603924a2b.tar.xz
yuzu-59cb258409c5cbd6cdc9cc6a6f8e858603924a2b.zip
VFS Regression and Accuracy Fixes (#776)
* Regression and Mode Fixes * Review Fixes * string_view correction * Add operator& for FileSys::Mode * Return std::string from SanitizePath * Farming Simulator Fix * Use != With mode operator&
Diffstat (limited to '')
-rw-r--r--src/common/file_util.cpp11
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
873std::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
873IOFile::IOFile() {} 882IOFile::IOFile() {}
874 883
875IOFile::IOFile(const std::string& filename, const char openmode[], int flags) { 884IOFile::IOFile(const std::string& filename, const char openmode[], int flags) {