summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-04-05 16:52:54 +0200
committerGitHub <noreply@github.com>2019-04-05 16:52:54 +0200
commitd6b7195192057a61b448a353bcf109cc2ddd2d73 (patch)
treedf7ceb4f42977c3182f9ec2135a8889752caae96
parentMerge pull request #2282 from bunnei/gpu-asynch-v2 (diff)
parentfilesystem: Use a std::string_view in OpenFile() (diff)
downloadyuzu-d6b7195192057a61b448a353bcf109cc2ddd2d73.tar
yuzu-d6b7195192057a61b448a353bcf109cc2ddd2d73.tar.gz
yuzu-d6b7195192057a61b448a353bcf109cc2ddd2d73.tar.bz2
yuzu-d6b7195192057a61b448a353bcf109cc2ddd2d73.tar.lz
yuzu-d6b7195192057a61b448a353bcf109cc2ddd2d73.tar.xz
yuzu-d6b7195192057a61b448a353bcf109cc2ddd2d73.tar.zst
yuzu-d6b7195192057a61b448a353bcf109cc2ddd2d73.zip
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index c6da2df43..1fbab2789 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -197,13 +197,16 @@ ResultCode VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_pa
ResultVal<FileSys::VirtualFile> VfsDirectoryServiceWrapper::OpenFile(const std::string& path_,
FileSys::Mode mode) const {
- std::string path(FileUtil::SanitizePath(path_));
- auto npath = path;
- while (npath.size() > 0 && (npath[0] == '/' || npath[0] == '\\'))
- npath = npath.substr(1);
+ const std::string path(FileUtil::SanitizePath(path_));
+ std::string_view npath = path;
+ while (!npath.empty() && (npath[0] == '/' || npath[0] == '\\')) {
+ npath.remove_prefix(1);
+ }
+
auto file = backing->GetFileRelative(npath);
- if (file == nullptr)
+ if (file == nullptr) {
return FileSys::ERROR_PATH_NOT_FOUND;
+ }
if (mode == FileSys::Mode::Append) {
return MakeResult<FileSys::VirtualFile>(