summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/file_sys/archive_extsavedata.cpp12
-rw-r--r--src/core/file_sys/archive_source_sd_savedata.cpp7
-rw-r--r--src/core/file_sys/archive_systemsavedata.cpp4
-rw-r--r--src/core/file_sys/disk_archive.cpp7
-rw-r--r--src/core/file_sys/errors.h127
-rw-r--r--src/core/hle/result.h21
-rw-r--r--src/core/hle/service/cfg/cfg.cpp6
-rw-r--r--src/core/hle/service/fs/archive.cpp28
-rw-r--r--src/core/hle/service/fs/fs_user.cpp5
-rw-r--r--src/core/hle/service/ptm/ptm.cpp3
10 files changed, 115 insertions, 105 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
18ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const { 19ResultVal<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
27ResultVal<size_t> DiskFile::Write(const u64 offset, const size_t length, const bool flush, 27ResultVal<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
7namespace FileSys { 9namespace FileSys {
8 10
9const ResultCode ERROR_INVALID_PATH(ErrorDescription::FS_InvalidPath, ErrorModule::FS, 11namespace ErrCodes {
10 ErrorSummary::InvalidArgument, ErrorLevel::Usage); 12enum {
11const 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,
14const ResultCode ERROR_INVALID_OPEN_FLAGS(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS, 16 PathNotFound = 113,
15 ErrorSummary::Canceled, ErrorLevel::Status); 17 GameCardNotInserted = 141,
16const ResultCode ERROR_INVALID_READ_FLAG(ErrorDescription::FS_InvalidReadFlag, ErrorModule::FS, 18 NotFound = 120,
17 ErrorSummary::InvalidArgument, ErrorLevel::Usage); 19 FileAlreadyExists = 180,
18const ResultCode ERROR_FILE_NOT_FOUND(ErrorDescription::FS_FileNotFound, ErrorModule::FS, 20 DirectoryAlreadyExists = 185,
19 ErrorSummary::NotFound, ErrorLevel::Status); 21 AlreadyExists = 190,
20const ResultCode ERROR_PATH_NOT_FOUND(ErrorDescription::FS_PathNotFound, ErrorModule::FS, 22 InvalidOpenFlags = 230,
21 ErrorSummary::NotFound, ErrorLevel::Status); 23 DirectoryNotEmpty = 240,
22const 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
24const 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,
27const 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,
30const ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ErrorDescription::FS_DirectoryAlreadyExists, 32 IncorrectExeFSReadSize = 761,
31 ErrorModule::FS, ErrorSummary::NothingHappened, 33 UnexpectedFileOrDirectory = 770,
32 ErrorLevel::Status); 34};
33const ResultCode ERROR_FILE_ALREADY_EXISTS(ErrorDescription::FS_FileAlreadyExists, ErrorModule::FS, 35}
34 ErrorSummary::NothingHappened, ErrorLevel::Status); 36
35const ResultCode ERROR_ALREADY_EXISTS(ErrorDescription::FS_AlreadyExists, ErrorModule::FS, 37constexpr ResultCode ERROR_INVALID_PATH(ErrCodes::InvalidPath, ErrorModule::FS,
36 ErrorSummary::NothingHappened, ErrorLevel::Status); 38 ErrorSummary::InvalidArgument, ErrorLevel::Usage);
37const ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrorDescription::FS_DirectoryNotEmpty, ErrorModule::FS, 39constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS,
38 ErrorSummary::Canceled, ErrorLevel::Status); 40 ErrorSummary::NotSupported, ErrorLevel::Usage);
39const ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrorDescription::FS_GameCardNotInserted, 41constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ErrCodes::InvalidOpenFlags, ErrorModule::FS,
40 ErrorModule::FS, ErrorSummary::NotFound, 42 ErrorSummary::Canceled, ErrorLevel::Status);
41 ErrorLevel::Status); 43constexpr ResultCode ERROR_INVALID_READ_FLAG(ErrCodes::InvalidReadFlag, ErrorModule::FS,
42const ResultCode ERROR_INCORRECT_EXEFS_READ_SIZE(ErrorDescription::FS_IncorrectExeFSReadSize, 44 ErrorSummary::InvalidArgument, ErrorLevel::Usage);
43 ErrorModule::FS, ErrorSummary::NotSupported, 45constexpr ResultCode ERROR_FILE_NOT_FOUND(ErrCodes::FileNotFound, ErrorModule::FS,
44 ErrorLevel::Usage); 46 ErrorSummary::NotFound, ErrorLevel::Status);
45const ResultCode ERROR_ROMFS_NOT_FOUND(ErrorDescription::FS_RomFSNotFound, ErrorModule::FS, 47constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrCodes::PathNotFound, ErrorModule::FS,
46 ErrorSummary::NotFound, ErrorLevel::Status); 48 ErrorSummary::NotFound, ErrorLevel::Status);
47const ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrorDescription::FS_CommandNotAllowed, ErrorModule::FS, 49constexpr ResultCode ERROR_NOT_FOUND(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound,
48 ErrorSummary::WrongArgument, ErrorLevel::Permanent); 50 ErrorLevel::Status);
49const ResultCode ERROR_EXEFS_SECTION_NOT_FOUND(ErrorDescription::FS_ExeFSSectionNotFound, 51constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrCodes::UnexpectedFileOrDirectory,
50 ErrorModule::FS, ErrorSummary::NotFound, 52 ErrorModule::FS, ErrorSummary::NotSupported,
51 ErrorLevel::Status); 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);
52 93
53} // namespace FileSys 94} // namespace FileSys
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index c44668732..b066b7d4e 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -26,30 +26,9 @@ enum class ErrorDescription : u32 {
26 OS_InvalidBufferDescriptor = 48, 26 OS_InvalidBufferDescriptor = 48,
27 MaxConnectionsReached = 52, 27 MaxConnectionsReached = 52,
28 WrongAddress = 53, 28 WrongAddress = 53,
29 FS_RomFSNotFound = 100,
30 FS_ArchiveNotMounted = 101,
31 FS_FileNotFound = 112,
32 FS_PathNotFound = 113,
33 FS_GameCardNotInserted = 141,
34 FS_NotFound = 120,
35 FS_FileAlreadyExists = 180,
36 FS_DirectoryAlreadyExists = 185,
37 FS_AlreadyExists = 190,
38 FS_InvalidOpenFlags = 230,
39 FS_DirectoryNotEmpty = 240,
40 FS_NotAFile = 250,
41 FS_NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive
42 OutofRangeOrMisalignedAddress = 29 OutofRangeOrMisalignedAddress =
43 513, // TODO(purpasmart): Check if this name fits its actual usage 30 513, // TODO(purpasmart): Check if this name fits its actual usage
44 GPU_FirstInitialization = 519, 31 GPU_FirstInitialization = 519,
45 FS_ExeFSSectionNotFound = 567,
46 FS_CommandNotAllowed = 630,
47 FS_InvalidReadFlag = 700,
48 FS_InvalidPath = 702,
49 FS_WriteBeyondEnd = 705,
50 FS_UnsupportedOpenFlags = 760,
51 FS_IncorrectExeFSReadSize = 761,
52 FS_UnexpectedFileOrDirectory = 770,
53 32
54 // Codes 1000 and above are considered "well-known" and have common values between all modules. 33 // Codes 1000 and above are considered "well-known" and have common values between all modules.
55 InvalidSection = 1000, 34 InvalidSection = 1000,
diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp
index 14185ae20..caa41ded7 100644
--- a/src/core/hle/service/cfg/cfg.cpp
+++ b/src/core/hle/service/cfg/cfg.cpp
@@ -11,6 +11,7 @@
11#include "common/string_util.h" 11#include "common/string_util.h"
12#include "common/swap.h" 12#include "common/swap.h"
13#include "core/file_sys/archive_systemsavedata.h" 13#include "core/file_sys/archive_systemsavedata.h"
14#include "core/file_sys/errors.h"
14#include "core/file_sys/file_backend.h" 15#include "core/file_sys/file_backend.h"
15#include "core/hle/result.h" 16#include "core/hle/result.h"
16#include "core/hle/service/cfg/cfg.h" 17#include "core/hle/service/cfg/cfg.h"
@@ -411,8 +412,7 @@ ResultCode UpdateConfigNANDSavegame() {
411ResultCode FormatConfig() { 412ResultCode FormatConfig() {
412 ResultCode res = DeleteConfigNANDSaveFile(); 413 ResultCode res = DeleteConfigNANDSaveFile();
413 // The delete command fails if the file doesn't exist, so we have to check that too 414 // The delete command fails if the file doesn't exist, so we have to check that too
414 if (!res.IsSuccess() && 415 if (!res.IsSuccess() && res != FileSys::ERROR_FILE_NOT_FOUND) {
415 res.description != static_cast<u32>(ErrorDescription::FS_FileNotFound)) {
416 return res; 416 return res;
417 } 417 }
418 // Delete the old data 418 // Delete the old data
@@ -535,7 +535,7 @@ ResultCode LoadConfigNANDSaveFile() {
535 Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path); 535 Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
536 536
537 // If the archive didn't exist, create the files inside 537 // If the archive didn't exist, create the files inside
538 if (archive_result.Code().description == static_cast<u32>(ErrorDescription::FS_NotFormatted)) { 538 if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
539 // Format the archive to create the directories 539 // Format the archive to create the directories
540 Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData, 540 Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData,
541 FileSys::ArchiveFormatInfo(), archive_path); 541 FileSys::ArchiveFormatInfo(), archive_path);
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 6cddc1fdb..5c1235f8b 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -22,6 +22,7 @@
22#include "core/file_sys/archive_sdmcwriteonly.h" 22#include "core/file_sys/archive_sdmcwriteonly.h"
23#include "core/file_sys/archive_systemsavedata.h" 23#include "core/file_sys/archive_systemsavedata.h"
24#include "core/file_sys/directory_backend.h" 24#include "core/file_sys/directory_backend.h"
25#include "core/file_sys/errors.h"
25#include "core/file_sys/file_backend.h" 26#include "core/file_sys/file_backend.h"
26#include "core/hle/kernel/client_session.h" 27#include "core/hle/kernel/client_session.h"
27#include "core/hle/result.h" 28#include "core/hle/result.h"
@@ -55,11 +56,6 @@ namespace FS {
55const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS, 56const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS,
56 ErrorSummary::InvalidArgument, ErrorLevel::Permanent); 57 ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
57 58
58/// Returned when a function is passed an invalid archive handle.
59const ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrorDescription::FS_ArchiveNotMounted, ErrorModule::FS,
60 ErrorSummary::NotFound,
61 ErrorLevel::Status); // 0xC8804465
62
63// Command to access archive file 59// Command to access archive file
64enum class FileCommand : u32 { 60enum class FileCommand : u32 {
65 Dummy1 = 0x000100C6, 61 Dummy1 = 0x000100C6,
@@ -284,7 +280,7 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
284 280
285ResultCode CloseArchive(ArchiveHandle handle) { 281ResultCode CloseArchive(ArchiveHandle handle) {
286 if (handle_map.erase(handle) == 0) 282 if (handle_map.erase(handle) == 0)
287 return ERR_INVALID_ARCHIVE_HANDLE; 283 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
288 else 284 else
289 return RESULT_SUCCESS; 285 return RESULT_SUCCESS;
290} 286}
@@ -309,7 +305,7 @@ ResultVal<std::shared_ptr<File>> OpenFileFromArchive(ArchiveHandle archive_handl
309 const FileSys::Mode mode) { 305 const FileSys::Mode mode) {
310 ArchiveBackend* archive = GetArchive(archive_handle); 306 ArchiveBackend* archive = GetArchive(archive_handle);
311 if (archive == nullptr) 307 if (archive == nullptr)
312 return ERR_INVALID_ARCHIVE_HANDLE; 308 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
313 309
314 auto backend = archive->OpenFile(path, mode); 310 auto backend = archive->OpenFile(path, mode);
315 if (backend.Failed()) 311 if (backend.Failed())
@@ -322,7 +318,7 @@ ResultVal<std::shared_ptr<File>> OpenFileFromArchive(ArchiveHandle archive_handl
322ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 318ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
323 ArchiveBackend* archive = GetArchive(archive_handle); 319 ArchiveBackend* archive = GetArchive(archive_handle);
324 if (archive == nullptr) 320 if (archive == nullptr)
325 return ERR_INVALID_ARCHIVE_HANDLE; 321 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
326 322
327 return archive->DeleteFile(path); 323 return archive->DeleteFile(path);
328} 324}
@@ -334,7 +330,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
334 ArchiveBackend* src_archive = GetArchive(src_archive_handle); 330 ArchiveBackend* src_archive = GetArchive(src_archive_handle);
335 ArchiveBackend* dest_archive = GetArchive(dest_archive_handle); 331 ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
336 if (src_archive == nullptr || dest_archive == nullptr) 332 if (src_archive == nullptr || dest_archive == nullptr)
337 return ERR_INVALID_ARCHIVE_HANDLE; 333 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
338 334
339 if (src_archive == dest_archive) { 335 if (src_archive == dest_archive) {
340 return src_archive->RenameFile(src_path, dest_path); 336 return src_archive->RenameFile(src_path, dest_path);
@@ -347,7 +343,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
347ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 343ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
348 ArchiveBackend* archive = GetArchive(archive_handle); 344 ArchiveBackend* archive = GetArchive(archive_handle);
349 if (archive == nullptr) 345 if (archive == nullptr)
350 return ERR_INVALID_ARCHIVE_HANDLE; 346 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
351 347
352 return archive->DeleteDirectory(path); 348 return archive->DeleteDirectory(path);
353} 349}
@@ -356,7 +352,7 @@ ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
356 const FileSys::Path& path) { 352 const FileSys::Path& path) {
357 ArchiveBackend* archive = GetArchive(archive_handle); 353 ArchiveBackend* archive = GetArchive(archive_handle);
358 if (archive == nullptr) 354 if (archive == nullptr)
359 return ERR_INVALID_ARCHIVE_HANDLE; 355 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
360 356
361 return archive->DeleteDirectoryRecursively(path); 357 return archive->DeleteDirectoryRecursively(path);
362} 358}
@@ -365,7 +361,7 @@ ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path
365 u64 file_size) { 361 u64 file_size) {
366 ArchiveBackend* archive = GetArchive(archive_handle); 362 ArchiveBackend* archive = GetArchive(archive_handle);
367 if (archive == nullptr) 363 if (archive == nullptr)
368 return ERR_INVALID_ARCHIVE_HANDLE; 364 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
369 365
370 return archive->CreateFile(path, file_size); 366 return archive->CreateFile(path, file_size);
371} 367}
@@ -373,7 +369,7 @@ ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path
373ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) { 369ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
374 ArchiveBackend* archive = GetArchive(archive_handle); 370 ArchiveBackend* archive = GetArchive(archive_handle);
375 if (archive == nullptr) 371 if (archive == nullptr)
376 return ERR_INVALID_ARCHIVE_HANDLE; 372 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
377 373
378 return archive->CreateDirectory(path); 374 return archive->CreateDirectory(path);
379} 375}
@@ -385,7 +381,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
385 ArchiveBackend* src_archive = GetArchive(src_archive_handle); 381 ArchiveBackend* src_archive = GetArchive(src_archive_handle);
386 ArchiveBackend* dest_archive = GetArchive(dest_archive_handle); 382 ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
387 if (src_archive == nullptr || dest_archive == nullptr) 383 if (src_archive == nullptr || dest_archive == nullptr)
388 return ERR_INVALID_ARCHIVE_HANDLE; 384 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
389 385
390 if (src_archive == dest_archive) { 386 if (src_archive == dest_archive) {
391 return src_archive->RenameDirectory(src_path, dest_path); 387 return src_archive->RenameDirectory(src_path, dest_path);
@@ -399,7 +395,7 @@ ResultVal<std::shared_ptr<Directory>> OpenDirectoryFromArchive(ArchiveHandle arc
399 const FileSys::Path& path) { 395 const FileSys::Path& path) {
400 ArchiveBackend* archive = GetArchive(archive_handle); 396 ArchiveBackend* archive = GetArchive(archive_handle);
401 if (archive == nullptr) 397 if (archive == nullptr)
402 return ERR_INVALID_ARCHIVE_HANDLE; 398 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
403 399
404 auto backend = archive->OpenDirectory(path); 400 auto backend = archive->OpenDirectory(path);
405 if (backend.Failed()) 401 if (backend.Failed())
@@ -412,7 +408,7 @@ ResultVal<std::shared_ptr<Directory>> OpenDirectoryFromArchive(ArchiveHandle arc
412ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) { 408ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) {
413 ArchiveBackend* archive = GetArchive(archive_handle); 409 ArchiveBackend* archive = GetArchive(archive_handle);
414 if (archive == nullptr) 410 if (archive == nullptr)
415 return ERR_INVALID_ARCHIVE_HANDLE; 411 return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
416 return MakeResult<u64>(archive->GetFreeBytes()); 412 return MakeResult<u64>(archive->GetFreeBytes());
417} 413}
418 414
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp
index 33b290699..ad1aadab5 100644
--- a/src/core/hle/service/fs/fs_user.cpp
+++ b/src/core/hle/service/fs/fs_user.cpp
@@ -8,6 +8,7 @@
8#include "common/logging/log.h" 8#include "common/logging/log.h"
9#include "common/scope_exit.h" 9#include "common/scope_exit.h"
10#include "common/string_util.h" 10#include "common/string_util.h"
11#include "core/file_sys/errors.h"
11#include "core/hle/kernel/client_session.h" 12#include "core/hle/kernel/client_session.h"
12#include "core/hle/result.h" 13#include "core/hle/result.h"
13#include "core/hle/service/fs/archive.h" 14#include "core/hle/service/fs/archive.h"
@@ -539,9 +540,7 @@ static void FormatSaveData(Service::Interface* self) {
539 if (archive_id != FS::ArchiveIdCode::SaveData) { 540 if (archive_id != FS::ArchiveIdCode::SaveData) {
540 LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u", 541 LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u",
541 static_cast<u32>(archive_id)); 542 static_cast<u32>(archive_id));
542 cmd_buff[1] = ResultCode(ErrorDescription::FS_InvalidPath, ErrorModule::FS, 543 cmd_buff[1] = FileSys::ERROR_INVALID_PATH.raw;
543 ErrorSummary::InvalidArgument, ErrorLevel::Usage)
544 .raw;
545 return; 544 return;
546 } 545 }
547 546
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp
index b6d6d105a..39382ef09 100644
--- a/src/core/hle/service/ptm/ptm.cpp
+++ b/src/core/hle/service/ptm/ptm.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/file_sys/errors.h"
6#include "core/file_sys/file_backend.h" 7#include "core/file_sys/file_backend.h"
7#include "core/hle/service/fs/archive.h" 8#include "core/hle/service/fs/archive.h"
8#include "core/hle/service/ptm/ptm.h" 9#include "core/hle/service/ptm/ptm.h"
@@ -134,7 +135,7 @@ void Init() {
134 auto archive_result = 135 auto archive_result =
135 Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path); 136 Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
136 // If the archive didn't exist, create the files inside 137 // If the archive didn't exist, create the files inside
137 if (archive_result.Code().description == static_cast<u32>(ErrorDescription::FS_NotFormatted)) { 138 if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
138 // Format the archive to create the directories 139 // Format the archive to create the directories
139 Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, 140 Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData,
140 FileSys::ArchiveFormatInfo(), archive_path); 141 FileSys::ArchiveFormatInfo(), archive_path);