2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #6265 from Morph1984/snap-save-fix

service: filesystem: Return proper error codes for CreateFile
This commit is contained in:
bunnei 2021-05-02 00:45:18 -07:00 committed by GitHub
commit 01a57d4c8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -9,6 +9,7 @@
namespace FileSys { namespace FileSys {
constexpr ResultCode ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1}; constexpr ResultCode ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1};
constexpr ResultCode ERROR_PATH_ALREADY_EXISTS{ErrorModule::FS, 2};
constexpr ResultCode ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002}; constexpr ResultCode ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002};
constexpr ResultCode ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001}; constexpr ResultCode ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001};
constexpr ResultCode ERROR_OUT_OF_BOUNDS{ErrorModule::FS, 3005}; constexpr ResultCode ERROR_OUT_OF_BOUNDS{ErrorModule::FS, 3005};

View file

@ -55,10 +55,15 @@ std::string VfsDirectoryServiceWrapper::GetName() const {
ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { ResultCode VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const {
std::string path(Common::FS::SanitizePath(path_)); std::string path(Common::FS::SanitizePath(path_));
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
// dir can be nullptr if path contains subdirectories, create those prior to creating the file.
if (dir == nullptr) { if (dir == nullptr) {
dir = backing->CreateSubdirectory(Common::FS::GetParentPath(path)); return FileSys::ERROR_PATH_NOT_FOUND;
} }
const auto entry_type = GetEntryType(path);
if (entry_type.Code() == RESULT_SUCCESS) {
return FileSys::ERROR_PATH_ALREADY_EXISTS;
}
auto file = dir->CreateFile(Common::FS::GetFilename(path)); auto file = dir->CreateFile(Common::FS::GetFilename(path));
if (file == nullptr) { if (file == nullptr) {
// TODO(DarkLordZach): Find a better error code for this // TODO(DarkLordZach): Find a better error code for this