summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar bunnei2017-10-31 19:26:11 -0400
committerGravatar bunnei2017-10-31 19:26:11 -0400
commit34571f4d2e80a3194a3c4cb697dba674d11a35b4 (patch)
treeb2b4b70d7a5bdea95ef5d44733eedf7e6b3b7009 /src/core/file_sys
parentexternals: Update dynarmic and xbyak. (diff)
downloadyuzu-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.h66
-rw-r--r--src/core/file_sys/ivfc_archive.cpp10
-rw-r--r--src/core/file_sys/savedata_archive.cpp22
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
37constexpr ResultCode ERROR_INVALID_PATH(ErrCodes::InvalidPath, ErrorModule::FS, 37// TODO(bunnei): Replace these with correct errors for Switch OS
38 ErrorSummary::InvalidArgument, ErrorLevel::Usage); 38constexpr ResultCode ERROR_INVALID_PATH(ResultCode(-1));
39constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS, 39constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ResultCode(-1));
40 ErrorSummary::NotSupported, ErrorLevel::Usage); 40constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ResultCode(-1));
41constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ErrCodes::InvalidOpenFlags, ErrorModule::FS, 41constexpr ResultCode ERROR_FILE_NOT_FOUND(ResultCode(-1));
42 ErrorSummary::Canceled, ErrorLevel::Status); 42constexpr ResultCode ERROR_PATH_NOT_FOUND(ResultCode(-1));
43constexpr ResultCode ERROR_INVALID_READ_FLAG(ErrCodes::InvalidReadFlag, ErrorModule::FS, 43constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ResultCode(-1));
44 ErrorSummary::InvalidArgument, ErrorLevel::Usage); 44constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ResultCode(-1));
45constexpr ResultCode ERROR_FILE_NOT_FOUND(ErrCodes::FileNotFound, ErrorModule::FS, 45constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ResultCode(-1));
46 ErrorSummary::NotFound, ErrorLevel::Status); 46constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(ResultCode(-1));
47constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrCodes::PathNotFound, ErrorModule::FS,
48 ErrorSummary::NotFound, ErrorLevel::Status);
49constexpr ResultCode ERROR_NOT_FOUND(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound,
50 ErrorLevel::Status);
51constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrCodes::UnexpectedFileOrDirectory,
52 ErrorModule::FS, ErrorSummary::NotSupported,
53 ErrorLevel::Usage);
54constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC(ErrCodes::NotAFile, ErrorModule::FS,
55 ErrorSummary::Canceled,
56 ErrorLevel::Status);
57constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ErrCodes::DirectoryAlreadyExists,
58 ErrorModule::FS, ErrorSummary::NothingHappened,
59 ErrorLevel::Status);
60constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ErrCodes::FileAlreadyExists, ErrorModule::FS,
61 ErrorSummary::NothingHappened, ErrorLevel::Status);
62constexpr ResultCode ERROR_ALREADY_EXISTS(ErrCodes::AlreadyExists, ErrorModule::FS,
63 ErrorSummary::NothingHappened, ErrorLevel::Status);
64constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrCodes::DirectoryNotEmpty, ErrorModule::FS,
65 ErrorSummary::Canceled, ErrorLevel::Status);
66constexpr ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrCodes::GameCardNotInserted, ErrorModule::FS,
67 ErrorSummary::NotFound, ErrorLevel::Status);
68constexpr ResultCode ERROR_INCORRECT_EXEFS_READ_SIZE(ErrCodes::IncorrectExeFSReadSize,
69 ErrorModule::FS, ErrorSummary::NotSupported,
70 ErrorLevel::Usage);
71constexpr ResultCode ERROR_ROMFS_NOT_FOUND(ErrCodes::RomFSNotFound, ErrorModule::FS,
72 ErrorSummary::NotFound, ErrorLevel::Status);
73constexpr ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrCodes::CommandNotAllowed, ErrorModule::FS,
74 ErrorSummary::WrongArgument, ErrorLevel::Permanent);
75constexpr 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.
79constexpr ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrCodes::ArchiveNotMounted, ErrorModule::FS,
80 ErrorSummary::NotFound,
81 ErrorLevel::Status); // 0xC8804465
82constexpr 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 */
89constexpr ResultCode ERR_NOT_FOUND_INVALID_STATE(ErrCodes::NotFound, ErrorModule::FS,
90 ErrorSummary::InvalidState, ErrorLevel::Status);
91constexpr 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,
26ResultCode IVFCArchive::DeleteFile(const Path& path) const { 26ResultCode 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
34ResultCode IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const { 33ResultCode IVFCArchive::RenameFile(const Path& src_path, const Path& dest_path) const {
@@ -55,9 +54,8 @@ ResultCode IVFCArchive::DeleteDirectoryRecursively(const Path& path) const {
55ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const { 54ResultCode 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
63ResultCode IVFCArchive::CreateDirectory(const Path& path) const { 61ResultCode 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
137template <typename T> 135template <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
230ResultCode SaveDataArchive::CreateDirectory(const Path& path) const { 229ResultCode 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
267ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& dest_path) const { 267ResultCode 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
296ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory( 294ResultVal<std::unique_ptr<DirectoryBackend>> SaveDataArchive::OpenDirectory(