summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2021-05-02 00:45:18 -0700
committerGravatar GitHub2021-05-02 00:45:18 -0700
commit01a57d4c8d1000a827bca21d6a3ed2f57247d51e (patch)
tree48021bf1ca1a8f23250dc6c278f5049f53fd6a73
parentMerge pull request #6245 from lat9nq/boost-only-config (diff)
parentservice: filesystem: Return proper error codes for CreateFile (diff)
downloadyuzu-01a57d4c8d1000a827bca21d6a3ed2f57247d51e.tar.gz
yuzu-01a57d4c8d1000a827bca21d6a3ed2f57247d51e.tar.xz
yuzu-01a57d4c8d1000a827bca21d6a3ed2f57247d51e.zip
Merge pull request #6265 from Morph1984/snap-save-fix
service: filesystem: Return proper error codes for CreateFile
-rw-r--r--src/core/file_sys/errors.h1
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp9
2 files changed, 8 insertions, 2 deletions
diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h
index bb4654366..1a920b45d 100644
--- a/src/core/file_sys/errors.h
+++ b/src/core/file_sys/errors.h
@@ -9,6 +9,7 @@
9namespace FileSys { 9namespace FileSys {
10 10
11constexpr ResultCode ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1}; 11constexpr ResultCode ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1};
12constexpr ResultCode ERROR_PATH_ALREADY_EXISTS{ErrorModule::FS, 2};
12constexpr ResultCode ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002}; 13constexpr ResultCode ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002};
13constexpr ResultCode ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001}; 14constexpr ResultCode ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001};
14constexpr ResultCode ERROR_OUT_OF_BOUNDS{ErrorModule::FS, 3005}; 15constexpr ResultCode ERROR_OUT_OF_BOUNDS{ErrorModule::FS, 3005};
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 {
55ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { 55ResultCode 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