diff options
| author | 2021-05-01 09:33:00 -0400 | |
|---|---|---|
| committer | 2021-05-01 09:33:00 -0400 | |
| commit | 72b22fd43301548873164dbaa5856a0c2fd19a30 (patch) | |
| tree | a781ef57b4aa637f85a711213e13fcb1112c9cc0 /src/core/hle | |
| parent | Merge pull request #6257 from Morph1984/fix-use-after-free-webapplet (diff) | |
| download | yuzu-72b22fd43301548873164dbaa5856a0c2fd19a30.tar.gz yuzu-72b22fd43301548873164dbaa5856a0c2fd19a30.tar.xz yuzu-72b22fd43301548873164dbaa5856a0c2fd19a30.zip | |
service: filesystem: Return proper error codes for CreateFile
This improves the accuracy of CreateFile by returning the correct error codes on certain conditions (parent directory does not exist, path already exists).
This fixes saving and the loading of existing saves in New Pokemon Snap
Diffstat (limited to 'src/core/hle')
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 72ad273b2..67b2b3102 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -55,10 +55,15 @@ std::string VfsDirectoryServiceWrapper::GetName() const { | |||
| 55 | ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { | 55 | ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { |
| 56 | std::string path(Common::FS::SanitizePath(path_)); | 56 | std::string path(Common::FS::SanitizePath(path_)); |
| 57 | auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); | 57 | auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); |
| 58 | // dir can be nullptr if path contains subdirectories, create those prior to creating the file. | ||
| 59 | if (dir == nullptr) { | 58 | if (dir == nullptr) { |
| 60 | dir = backing->CreateSubdirectory(Common::FS::GetParentPath(path)); | 59 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 60 | } | ||
| 61 | |||
| 62 | const auto entry_type = GetEntryType(path); | ||
| 63 | if (entry_type.Code() == RESULT_SUCCESS) { | ||
| 64 | return FileSys::ERROR_PATH_ALREADY_EXISTS; | ||
| 61 | } | 65 | } |
| 66 | |||
| 62 | auto file = dir->CreateFile(Common::FS::GetFilename(path)); | 67 | auto file = dir->CreateFile(Common::FS::GetFilename(path)); |
| 63 | if (file == nullptr) { | 68 | if (file == nullptr) { |
| 64 | // TODO(DarkLordZach): Find a better error code for this | 69 | // TODO(DarkLordZach): Find a better error code for this |