diff options
| author | 2017-10-31 19:26:11 -0400 | |
|---|---|---|
| committer | 2017-10-31 19:26:11 -0400 | |
| commit | 34571f4d2e80a3194a3c4cb697dba674d11a35b4 (patch) | |
| tree | b2b4b70d7a5bdea95ef5d44733eedf7e6b3b7009 /src/core/file_sys | |
| parent | externals: Update dynarmic and xbyak. (diff) | |
| download | yuzu-34571f4d2e80a3194a3c4cb697dba674d11a35b4.tar.gz yuzu-34571f4d2e80a3194a3c4cb697dba674d11a35b4.tar.xz yuzu-34571f4d2e80a3194a3c4cb697dba674d11a35b4.zip | |
hle: Use Switch formatted result codes.
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/errors.h | 66 | ||||
| -rw-r--r-- | src/core/file_sys/ivfc_archive.cpp | 10 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_archive.cpp | 22 |
3 files changed, 24 insertions, 74 deletions
diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h index a974bc775..be3224ef8 100644 --- a/src/core/file_sys/errors.h +++ b/src/core/file_sys/errors.h | |||
| @@ -34,61 +34,15 @@ enum { | |||
| 34 | }; | 34 | }; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | constexpr ResultCode ERROR_INVALID_PATH(ErrCodes::InvalidPath, ErrorModule::FS, | 37 | // TODO(bunnei): Replace these with correct errors for Switch OS |
| 38 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | 38 | constexpr ResultCode ERROR_INVALID_PATH(ResultCode(-1)); |
| 39 | constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS, | 39 | constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ResultCode(-1)); |
| 40 | ErrorSummary::NotSupported, ErrorLevel::Usage); | 40 | constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ResultCode(-1)); |
| 41 | constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ErrCodes::InvalidOpenFlags, ErrorModule::FS, | 41 | constexpr ResultCode ERROR_FILE_NOT_FOUND(ResultCode(-1)); |
| 42 | ErrorSummary::Canceled, ErrorLevel::Status); | 42 | constexpr ResultCode ERROR_PATH_NOT_FOUND(ResultCode(-1)); |
| 43 | constexpr ResultCode ERROR_INVALID_READ_FLAG(ErrCodes::InvalidReadFlag, ErrorModule::FS, | 43 | constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ResultCode(-1)); |
| 44 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | 44 | constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ResultCode(-1)); |
| 45 | constexpr ResultCode ERROR_FILE_NOT_FOUND(ErrCodes::FileNotFound, ErrorModule::FS, | 45 | constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ResultCode(-1)); |
| 46 | ErrorSummary::NotFound, ErrorLevel::Status); | 46 | constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(ResultCode(-1)); |
| 47 | constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrCodes::PathNotFound, ErrorModule::FS, | ||
| 48 | ErrorSummary::NotFound, ErrorLevel::Status); | ||
| 49 | constexpr ResultCode ERROR_NOT_FOUND(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound, | ||
| 50 | ErrorLevel::Status); | ||
| 51 | constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrCodes::UnexpectedFileOrDirectory, | ||
| 52 | ErrorModule::FS, ErrorSummary::NotSupported, | ||
| 53 | ErrorLevel::Usage); | ||
| 54 | constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC(ErrCodes::NotAFile, ErrorModule::FS, | ||
| 55 | ErrorSummary::Canceled, | ||
| 56 | ErrorLevel::Status); | ||
| 57 | constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ErrCodes::DirectoryAlreadyExists, | ||
| 58 | ErrorModule::FS, ErrorSummary::NothingHappened, | ||
| 59 | ErrorLevel::Status); | ||
| 60 | constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ErrCodes::FileAlreadyExists, ErrorModule::FS, | ||
| 61 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 62 | constexpr ResultCode ERROR_ALREADY_EXISTS(ErrCodes::AlreadyExists, ErrorModule::FS, | ||
| 63 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 64 | constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrCodes::DirectoryNotEmpty, ErrorModule::FS, | ||
| 65 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 66 | constexpr ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrCodes::GameCardNotInserted, ErrorModule::FS, | ||
| 67 | ErrorSummary::NotFound, ErrorLevel::Status); | ||
| 68 | constexpr ResultCode ERROR_INCORRECT_EXEFS_READ_SIZE(ErrCodes::IncorrectExeFSReadSize, | ||
| 69 | ErrorModule::FS, ErrorSummary::NotSupported, | ||
| 70 | ErrorLevel::Usage); | ||
| 71 | constexpr ResultCode ERROR_ROMFS_NOT_FOUND(ErrCodes::RomFSNotFound, ErrorModule::FS, | ||
| 72 | ErrorSummary::NotFound, ErrorLevel::Status); | ||
| 73 | constexpr ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrCodes::CommandNotAllowed, ErrorModule::FS, | ||
| 74 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 75 | constexpr ResultCode ERROR_EXEFS_SECTION_NOT_FOUND(ErrCodes::ExeFSSectionNotFound, ErrorModule::FS, | ||
| 76 | ErrorSummary::NotFound, ErrorLevel::Status); | ||
| 77 | |||
| 78 | /// Returned when a function is passed an invalid archive handle. | ||
| 79 | constexpr ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrCodes::ArchiveNotMounted, ErrorModule::FS, | ||
| 80 | ErrorSummary::NotFound, | ||
| 81 | ErrorLevel::Status); // 0xC8804465 | ||
| 82 | constexpr ResultCode ERR_WRITE_BEYOND_END(ErrCodes::WriteBeyondEnd, ErrorModule::FS, | ||
| 83 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 84 | |||
| 85 | /** | ||
| 86 | * Variant of ERROR_NOT_FOUND returned in some places in the code. Unknown if these usages are | ||
| 87 | * correct or a bug. | ||
| 88 | */ | ||
| 89 | constexpr ResultCode ERR_NOT_FOUND_INVALID_STATE(ErrCodes::NotFound, ErrorModule::FS, | ||
| 90 | ErrorSummary::InvalidState, ErrorLevel::Status); | ||
| 91 | constexpr ResultCode ERR_NOT_FORMATTED(ErrCodes::NotFormatted, ErrorModule::FS, | ||
| 92 | ErrorSummary::InvalidState, ErrorLevel::Status); | ||
| 93 | 47 | ||
| 94 | } // namespace FileSys | 48 | } // namespace FileSys |
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp index 2735d2e3c..b3c3f2c6f 100644 --- a/src/core/file_sys/ivfc_archive.cpp +++ b/src/core/file_sys/ivfc_archive.cpp | |||
| @@ -26,9 +26,8 @@ ResultVal<std::unique_ptr<FileBackend>> IVFCArchive::OpenFile(const Path& path, | |||
| 26 | ResultCode IVFCArchive::DeleteFile(const Path& path) const { | 26 | ResultCode IVFCArchive::DeleteFile(const Path& path) const { |
| 27 | LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive (%s).", | 27 | LOG_CRITICAL(Service_FS, "Attempted to delete a file from an IVFC archive (%s).", |
| 28 | GetName().c_str()); | 28 | GetName().c_str()); |
| 29 | // TODO(Subv): Verify error code | 29 | // TODO(bunnei): Use correct error code |
| 30 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, | 30 | return ResultCode(-1); |
| 31 | ErrorLevel::Status); | ||
| 32 | } | 31 | } |
| 33 | 32 | ||
| 34 | ResultCode IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { | 33 | ResultCode IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { |
| @@ -55,9 +54,8 @@ ResultCode IVFCArchive::DeleteDirectoryRecursively(const Path& path) const { | |||
| 55 | ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { | 54 | ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { |
| 56 | LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive (%s).", | 55 | LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive (%s).", |
| 57 | GetName().c_str()); | 56 | GetName().c_str()); |
| 58 | // TODO: Verify error code | 57 | // TODO(bunnei): Use correct error code |
| 59 | return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, | 58 | return ResultCode(-1); |
| 60 | ErrorLevel::Permanent); | ||
| 61 | } | 59 | } |
| 62 | 60 | ||
| 63 | ResultCode IVFCArchive::CreateDirectory(const Path& path) const { | 61 | ResultCode IVFCArchive::CreateDirectory(const Path& path) const { |
diff --git a/src/core/file_sys/savedata_archive.cpp b/src/core/file_sys/savedata_archive.cpp index f8f811ba0..d7b012f6e 100644 --- a/src/core/file_sys/savedata_archive.cpp +++ b/src/core/file_sys/savedata_archive.cpp | |||
| @@ -128,10 +128,8 @@ ResultCode SaveDataArchive::RenameFile(const Path& src_path, const Path& dest_pa | |||
| 128 | return RESULT_SUCCESS; | 128 | return RESULT_SUCCESS; |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't | 131 | // TODO(bunnei): Use correct error code |
| 132 | // exist or similar. Verify. | 132 | return ResultCode(-1); |
| 133 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 134 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 135 | } | 133 | } |
| 136 | 134 | ||
| 137 | template <typename T> | 135 | template <typename T> |
| @@ -223,8 +221,9 @@ ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) cons | |||
| 223 | } | 221 | } |
| 224 | 222 | ||
| 225 | LOG_ERROR(Service_FS, "Too large file"); | 223 | LOG_ERROR(Service_FS, "Too large file"); |
| 226 | return ResultCode(ErrorDescription::TooLarge, ErrorModule::FS, ErrorSummary::OutOfResource, | 224 | |
| 227 | ErrorLevel::Info); | 225 | // TODO(bunnei): Use correct error code |
| 226 | return ResultCode(-1); | ||
| 228 | } | 227 | } |
| 229 | 228 | ||
| 230 | ResultCode SaveDataArchive::CreateDirectory(const Path& path) const { | 229 | ResultCode SaveDataArchive::CreateDirectory(const Path& path) const { |
| @@ -260,8 +259,9 @@ ResultCode SaveDataArchive::CreateDirectory(const Path& path) const { | |||
| 260 | } | 259 | } |
| 261 | 260 | ||
| 262 | LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating %s", mount_point.c_str()); | 261 | LOG_CRITICAL(Service_FS, "(unreachable) Unknown error creating %s", mount_point.c_str()); |
| 263 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, ErrorSummary::Canceled, | 262 | |
| 264 | ErrorLevel::Status); | 263 | // TODO(bunnei): Use correct error code |
| 264 | return ResultCode(-1); | ||
| 265 | } | 265 | } |
| 266 | 266 | ||
| 267 | ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { | 267 | ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { |
| @@ -287,10 +287,8 @@ ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& de | |||
| 287 | return RESULT_SUCCESS; | 287 | return RESULT_SUCCESS; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | // TODO(yuriks): This code probably isn't right, it'll return a Status even if the file didn't | 290 | // TODO(bunnei): Use correct error code |
| 291 | // exist or similar. Verify. | 291 | return ResultCode(-1); |
| 292 | return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description | ||
| 293 | ErrorSummary::NothingHappened, ErrorLevel::Status); | ||
| 294 | } | 292 | } |
| 295 | 293 | ||
| 296 | ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory( | 294 | ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory( |