diff options
| author | 2017-05-20 21:41:11 -0700 | |
|---|---|---|
| committer | 2017-05-24 21:06:00 -0700 | |
| commit | 92be29adba56408685e594e5e659f1dc83686cde (patch) | |
| tree | 09afef886d4eb26e4f752dc9b93c81ea21d87d9c /src/core/file_sys | |
| parent | result: Make error description a generic integer (diff) | |
| download | yuzu-92be29adba56408685e594e5e659f1dc83686cde.tar.gz yuzu-92be29adba56408685e594e5e659f1dc83686cde.tar.xz yuzu-92be29adba56408685e594e5e659f1dc83686cde.zip | |
FileSys: Move all result description to errors.h
Diffstat (limited to 'src/core/file_sys')
| -rw-r--r-- | src/core/file_sys/archive_extsavedata.cpp | 12 | ||||
| -rw-r--r-- | src/core/file_sys/archive_source_sd_savedata.cpp | 7 | ||||
| -rw-r--r-- | src/core/file_sys/archive_systemsavedata.cpp | 4 | ||||
| -rw-r--r-- | src/core/file_sys/disk_archive.cpp | 7 | ||||
| -rw-r--r-- | src/core/file_sys/errors.h | 127 |
5 files changed, 96 insertions, 61 deletions
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp index f454e7840..4867c9d17 100644 --- a/src/core/file_sys/archive_extsavedata.cpp +++ b/src/core/file_sys/archive_extsavedata.cpp | |||
| @@ -38,8 +38,7 @@ public: | |||
| 38 | ResultVal<size_t> Write(u64 offset, size_t length, bool flush, | 38 | ResultVal<size_t> Write(u64 offset, size_t length, bool flush, |
| 39 | const u8* buffer) const override { | 39 | const u8* buffer) const override { |
| 40 | if (offset > size) { | 40 | if (offset > size) { |
| 41 | return ResultCode(ErrorDescription::FS_WriteBeyondEnd, ErrorModule::FS, | 41 | return ERR_WRITE_BEYOND_END; |
| 42 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | ||
| 43 | } else if (offset == size) { | 42 | } else if (offset == size) { |
| 44 | return MakeResult<size_t>(0); | 43 | return MakeResult<size_t>(0); |
| 45 | } | 44 | } |
| @@ -191,11 +190,9 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(cons | |||
| 191 | // TODO(Subv): Verify the archive behavior of SharedExtSaveData compared to ExtSaveData. | 190 | // TODO(Subv): Verify the archive behavior of SharedExtSaveData compared to ExtSaveData. |
| 192 | // ExtSaveData seems to return FS_NotFound (120) when the archive doesn't exist. | 191 | // ExtSaveData seems to return FS_NotFound (120) when the archive doesn't exist. |
| 193 | if (!shared) { | 192 | if (!shared) { |
| 194 | return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS, | 193 | return ERR_NOT_FOUND_INVALID_STATE; |
| 195 | ErrorSummary::InvalidState, ErrorLevel::Status); | ||
| 196 | } else { | 194 | } else { |
| 197 | return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, | 195 | return ERR_NOT_FORMATTED; |
| 198 | ErrorSummary::InvalidState, ErrorLevel::Status); | ||
| 199 | } | 196 | } |
| 200 | } | 197 | } |
| 201 | auto archive = std::make_unique<ExtSaveDataArchive>(fullpath); | 198 | auto archive = std::make_unique<ExtSaveDataArchive>(fullpath); |
| @@ -230,8 +227,7 @@ ResultVal<ArchiveFormatInfo> ArchiveFactory_ExtSaveData::GetFormatInfo(const Pat | |||
| 230 | if (!file.IsOpen()) { | 227 | if (!file.IsOpen()) { |
| 231 | LOG_ERROR(Service_FS, "Could not open metadata information for archive"); | 228 | LOG_ERROR(Service_FS, "Could not open metadata information for archive"); |
| 232 | // TODO(Subv): Verify error code | 229 | // TODO(Subv): Verify error code |
| 233 | return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, | 230 | return ERR_NOT_FORMATTED; |
| 234 | ErrorSummary::InvalidState, ErrorLevel::Status); | ||
| 235 | } | 231 | } |
| 236 | 232 | ||
| 237 | ArchiveFormatInfo info = {}; | 233 | ArchiveFormatInfo info = {}; |
diff --git a/src/core/file_sys/archive_source_sd_savedata.cpp b/src/core/file_sys/archive_source_sd_savedata.cpp index f31a68038..a7e331724 100644 --- a/src/core/file_sys/archive_source_sd_savedata.cpp +++ b/src/core/file_sys/archive_source_sd_savedata.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "common/string_util.h" | 7 | #include "common/string_util.h" |
| 8 | #include "core/file_sys/archive_source_sd_savedata.h" | 8 | #include "core/file_sys/archive_source_sd_savedata.h" |
| 9 | #include "core/file_sys/errors.h" | ||
| 9 | #include "core/file_sys/savedata_archive.h" | 10 | #include "core/file_sys/savedata_archive.h" |
| 10 | #include "core/hle/service/fs/archive.h" | 11 | #include "core/hle/service/fs/archive.h" |
| 11 | 12 | ||
| @@ -49,8 +50,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveSource_SDSaveData::Open(u64 pr | |||
| 49 | // save file/directory structure expected by the game has not yet been initialized. | 50 | // save file/directory structure expected by the game has not yet been initialized. |
| 50 | // Returning the NotFormatted error code will signal the game to provision the SaveData | 51 | // Returning the NotFormatted error code will signal the game to provision the SaveData |
| 51 | // archive with the files and folders that it expects. | 52 | // archive with the files and folders that it expects. |
| 52 | return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, | 53 | return ERR_NOT_FORMATTED; |
| 53 | ErrorSummary::InvalidState, ErrorLevel::Status); | ||
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | auto archive = std::make_unique<SaveDataArchive>(std::move(concrete_mount_point)); | 56 | auto archive = std::make_unique<SaveDataArchive>(std::move(concrete_mount_point)); |
| @@ -81,8 +81,7 @@ ResultVal<ArchiveFormatInfo> ArchiveSource_SDSaveData::GetFormatInfo(u64 program | |||
| 81 | if (!file.IsOpen()) { | 81 | if (!file.IsOpen()) { |
| 82 | LOG_ERROR(Service_FS, "Could not open metadata information for archive"); | 82 | LOG_ERROR(Service_FS, "Could not open metadata information for archive"); |
| 83 | // TODO(Subv): Verify error code | 83 | // TODO(Subv): Verify error code |
| 84 | return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, | 84 | return ERR_NOT_FORMATTED; |
| 85 | ErrorSummary::InvalidState, ErrorLevel::Status); | ||
| 86 | } | 85 | } |
| 87 | 86 | ||
| 88 | ArchiveFormatInfo info = {}; | 87 | ArchiveFormatInfo info = {}; |
diff --git a/src/core/file_sys/archive_systemsavedata.cpp b/src/core/file_sys/archive_systemsavedata.cpp index 8986b5c0e..81423bffd 100644 --- a/src/core/file_sys/archive_systemsavedata.cpp +++ b/src/core/file_sys/archive_systemsavedata.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/file_util.h" | 9 | #include "common/file_util.h" |
| 10 | #include "common/string_util.h" | 10 | #include "common/string_util.h" |
| 11 | #include "core/file_sys/archive_systemsavedata.h" | 11 | #include "core/file_sys/archive_systemsavedata.h" |
| 12 | #include "core/file_sys/errors.h" | ||
| 12 | #include "core/file_sys/savedata_archive.h" | 13 | #include "core/file_sys/savedata_archive.h" |
| 13 | #include "core/hle/service/fs/archive.h" | 14 | #include "core/hle/service/fs/archive.h" |
| 14 | 15 | ||
| @@ -53,8 +54,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(c | |||
| 53 | std::string fullpath = GetSystemSaveDataPath(base_path, path); | 54 | std::string fullpath = GetSystemSaveDataPath(base_path, path); |
| 54 | if (!FileUtil::Exists(fullpath)) { | 55 | if (!FileUtil::Exists(fullpath)) { |
| 55 | // TODO(Subv): Check error code, this one is probably wrong | 56 | // TODO(Subv): Check error code, this one is probably wrong |
| 56 | return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, | 57 | return ERR_NOT_FORMATTED; |
| 57 | ErrorSummary::InvalidState, ErrorLevel::Status); | ||
| 58 | } | 58 | } |
| 59 | auto archive = std::make_unique<SaveDataArchive>(fullpath); | 59 | auto archive = std::make_unique<SaveDataArchive>(fullpath); |
| 60 | return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); | 60 | return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive)); |
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index a243d9a13..98d80aabc 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/file_util.h" | 9 | #include "common/file_util.h" |
| 10 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 11 | #include "core/file_sys/disk_archive.h" | 11 | #include "core/file_sys/disk_archive.h" |
| 12 | #include "core/file_sys/errors.h" | ||
| 12 | 13 | ||
| 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 14 | // FileSys namespace | 15 | // FileSys namespace |
| @@ -17,8 +18,7 @@ namespace FileSys { | |||
| 17 | 18 | ||
| 18 | ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const { | 19 | ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const { |
| 19 | if (!mode.read_flag) | 20 | if (!mode.read_flag) |
| 20 | return ResultCode(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS, | 21 | return ERROR_INVALID_OPEN_FLAGS; |
| 21 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 22 | 22 | ||
| 23 | file->Seek(offset, SEEK_SET); | 23 | file->Seek(offset, SEEK_SET); |
| 24 | return MakeResult<size_t>(file->ReadBytes(buffer, length)); | 24 | return MakeResult<size_t>(file->ReadBytes(buffer, length)); |
| @@ -27,8 +27,7 @@ ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buff | |||
| 27 | ResultVal<size_t> DiskFile::Write(const u64 offset, const size_t length, const bool flush, | 27 | ResultVal<size_t> DiskFile::Write(const u64 offset, const size_t length, const bool flush, |
| 28 | const u8* buffer) const { | 28 | const u8* buffer) const { |
| 29 | if (!mode.write_flag) | 29 | if (!mode.write_flag) |
| 30 | return ResultCode(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS, | 30 | return ERROR_INVALID_OPEN_FLAGS; |
| 31 | ErrorSummary::Canceled, ErrorLevel::Status); | ||
| 32 | 31 | ||
| 33 | file->Seek(offset, SEEK_SET); | 32 | file->Seek(offset, SEEK_SET); |
| 34 | size_t written = file->WriteBytes(buffer, length); | 33 | size_t written = file->WriteBytes(buffer, length); |
diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h index 9fc8d753b..a974bc775 100644 --- a/src/core/file_sys/errors.h +++ b/src/core/file_sys/errors.h | |||
| @@ -2,52 +2,93 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | ||
| 6 | |||
| 5 | #include "core/hle/result.h" | 7 | #include "core/hle/result.h" |
| 6 | 8 | ||
| 7 | namespace FileSys { | 9 | namespace FileSys { |
| 8 | 10 | ||
| 9 | const ResultCode ERROR_INVALID_PATH(ErrorDescription::FS_InvalidPath, ErrorModule::FS, | 11 | namespace ErrCodes { |
| 10 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | 12 | enum { |
| 11 | const ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrorDescription::FS_UnsupportedOpenFlags, | 13 | RomFSNotFound = 100, |
| 12 | ErrorModule::FS, ErrorSummary::NotSupported, | 14 | ArchiveNotMounted = 101, |
| 13 | ErrorLevel::Usage); | 15 | FileNotFound = 112, |
| 14 | const ResultCode ERROR_INVALID_OPEN_FLAGS(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS, | 16 | PathNotFound = 113, |
| 15 | ErrorSummary::Canceled, ErrorLevel::Status); | 17 | GameCardNotInserted = 141, |
| 16 | const ResultCode ERROR_INVALID_READ_FLAG(ErrorDescription::FS_InvalidReadFlag, ErrorModule::FS, | 18 | NotFound = 120, |
| 17 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); | 19 | FileAlreadyExists = 180, |
| 18 | const ResultCode ERROR_FILE_NOT_FOUND(ErrorDescription::FS_FileNotFound, ErrorModule::FS, | 20 | DirectoryAlreadyExists = 185, |
| 19 | ErrorSummary::NotFound, ErrorLevel::Status); | 21 | AlreadyExists = 190, |
| 20 | const ResultCode ERROR_PATH_NOT_FOUND(ErrorDescription::FS_PathNotFound, ErrorModule::FS, | 22 | InvalidOpenFlags = 230, |
| 21 | ErrorSummary::NotFound, ErrorLevel::Status); | 23 | DirectoryNotEmpty = 240, |
| 22 | const ResultCode ERROR_NOT_FOUND(ErrorDescription::FS_NotFound, ErrorModule::FS, | 24 | NotAFile = 250, |
| 23 | ErrorSummary::NotFound, ErrorLevel::Status); | 25 | NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive |
| 24 | const ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrorDescription::FS_UnexpectedFileOrDirectory, | 26 | ExeFSSectionNotFound = 567, |
| 25 | ErrorModule::FS, ErrorSummary::NotSupported, | 27 | CommandNotAllowed = 630, |
| 26 | ErrorLevel::Usage); | 28 | InvalidReadFlag = 700, |
| 27 | const ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC(ErrorDescription::FS_NotAFile, | 29 | InvalidPath = 702, |
| 28 | ErrorModule::FS, ErrorSummary::Canceled, | 30 | WriteBeyondEnd = 705, |
| 29 | ErrorLevel::Status); | 31 | UnsupportedOpenFlags = 760, |
| 30 | const ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ErrorDescription::FS_DirectoryAlreadyExists, | 32 | IncorrectExeFSReadSize = 761, |
| 31 | ErrorModule::FS, ErrorSummary::NothingHappened, | 33 | UnexpectedFileOrDirectory = 770, |
| 32 | ErrorLevel::Status); | 34 | }; |
| 33 | const ResultCode ERROR_FILE_ALREADY_EXISTS(ErrorDescription::FS_FileAlreadyExists, ErrorModule::FS, | 35 | } |
| 34 | ErrorSummary::NothingHappened, ErrorLevel::Status); | 36 | |
| 35 | const ResultCode ERROR_ALREADY_EXISTS(ErrorDescription::FS_AlreadyExists, ErrorModule::FS, | 37 | constexpr ResultCode ERROR_INVALID_PATH(ErrCodes::InvalidPath, ErrorModule::FS, |
| 36 | ErrorSummary::NothingHappened, ErrorLevel::Status); | 38 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); |
| 37 | const ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrorDescription::FS_DirectoryNotEmpty, ErrorModule::FS, | 39 | constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS, |
| 38 | ErrorSummary::Canceled, ErrorLevel::Status); | 40 | ErrorSummary::NotSupported, ErrorLevel::Usage); |
| 39 | const ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrorDescription::FS_GameCardNotInserted, | 41 | constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ErrCodes::InvalidOpenFlags, ErrorModule::FS, |
| 40 | ErrorModule::FS, ErrorSummary::NotFound, | 42 | ErrorSummary::Canceled, ErrorLevel::Status); |
| 41 | ErrorLevel::Status); | 43 | constexpr ResultCode ERROR_INVALID_READ_FLAG(ErrCodes::InvalidReadFlag, ErrorModule::FS, |
| 42 | const ResultCode ERROR_INCORRECT_EXEFS_READ_SIZE(ErrorDescription::FS_IncorrectExeFSReadSize, | 44 | ErrorSummary::InvalidArgument, ErrorLevel::Usage); |
| 43 | ErrorModule::FS, ErrorSummary::NotSupported, | 45 | constexpr ResultCode ERROR_FILE_NOT_FOUND(ErrCodes::FileNotFound, ErrorModule::FS, |
| 44 | ErrorLevel::Usage); | 46 | ErrorSummary::NotFound, ErrorLevel::Status); |
| 45 | const ResultCode ERROR_ROMFS_NOT_FOUND(ErrorDescription::FS_RomFSNotFound, ErrorModule::FS, | 47 | constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrCodes::PathNotFound, ErrorModule::FS, |
| 46 | ErrorSummary::NotFound, ErrorLevel::Status); | 48 | ErrorSummary::NotFound, ErrorLevel::Status); |
| 47 | const ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrorDescription::FS_CommandNotAllowed, ErrorModule::FS, | 49 | constexpr ResultCode ERROR_NOT_FOUND(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound, |
| 48 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | 50 | ErrorLevel::Status); |
| 49 | const ResultCode ERROR_EXEFS_SECTION_NOT_FOUND(ErrorDescription::FS_ExeFSSectionNotFound, | 51 | constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrCodes::UnexpectedFileOrDirectory, |
| 50 | ErrorModule::FS, ErrorSummary::NotFound, | 52 | ErrorModule::FS, ErrorSummary::NotSupported, |
| 51 | ErrorLevel::Status); | 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); | ||
| 52 | 93 | ||
| 53 | } // namespace FileSys | 94 | } // namespace FileSys |