diff options
author | bunnei <bunneidev@gmail.com> | 2019-04-05 10:52:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 10:52:54 -0400 |
commit | d6b7195192057a61b448a353bcf109cc2ddd2d73 (patch) | |
tree | df7ceb4f42977c3182f9ec2135a8889752caae96 /src | |
parent | 66be5150d6d201e3f8ca6e5e09968f052df4beb1 (diff) | |
parent | 15e0c4c4ec112b9f37591ff5791ccca497bb85a0 (diff) |
Merge pull request #2338 from lioncash/fs
filesystem: Use a std::string_view in OpenFile()
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 13 |
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>( |