fs/errors: Unify naming of result codes
This commit is contained in:
parent
cc09c265e1
commit
c60ab6bbf6
|
@ -7,18 +7,13 @@
|
|||
|
||||
namespace FileSys {
|
||||
|
||||
constexpr Result ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1};
|
||||
constexpr Result ERROR_PATH_ALREADY_EXISTS{ErrorModule::FS, 2};
|
||||
constexpr Result ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002};
|
||||
constexpr Result ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001};
|
||||
constexpr Result ERROR_OUT_OF_BOUNDS{ErrorModule::FS, 3005};
|
||||
constexpr Result ERROR_FAILED_MOUNT_ARCHIVE{ErrorModule::FS, 3223};
|
||||
constexpr Result ERROR_INVALID_ARGUMENT{ErrorModule::FS, 6001};
|
||||
constexpr Result ERROR_INVALID_OFFSET{ErrorModule::FS, 6061};
|
||||
constexpr Result ERROR_INVALID_SIZE{ErrorModule::FS, 6062};
|
||||
|
||||
constexpr Result ResultPathNotFound{ErrorModule::FS, 1};
|
||||
constexpr Result ResultPathAlreadyExists{ErrorModule::FS, 2};
|
||||
constexpr Result ResultUnsupportedSdkVersion{ErrorModule::FS, 50};
|
||||
constexpr Result ResultPartitionNotFound{ErrorModule::FS, 1001};
|
||||
constexpr Result ResultTargetNotFound{ErrorModule::FS, 1002};
|
||||
constexpr Result ResultPortSdCardNoDevice{ErrorModule::FS, 2001};
|
||||
constexpr Result ResultNotImplemented{ErrorModule::FS, 3001};
|
||||
constexpr Result ResultUnsupportedVersion{ErrorModule::FS, 3002};
|
||||
constexpr Result ResultOutOfRange{ErrorModule::FS, 3005};
|
||||
constexpr Result ResultAllocationMemoryFailedInFileSystemBuddyHeapA{ErrorModule::FS, 3294};
|
||||
|
|
|
@ -52,12 +52,12 @@ Result VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size
|
|||
std::string path(Common::FS::SanitizePath(path_));
|
||||
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
|
||||
if (dir == nullptr) {
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
|
||||
FileSys::DirectoryEntryType entry_type{};
|
||||
if (GetEntryType(&entry_type, path) == ResultSuccess) {
|
||||
return FileSys::ERROR_PATH_ALREADY_EXISTS;
|
||||
return FileSys::ResultPathAlreadyExists;
|
||||
}
|
||||
|
||||
auto file = dir->CreateFile(Common::FS::GetFilename(path));
|
||||
|
@ -81,7 +81,7 @@ Result VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const {
|
|||
|
||||
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
|
||||
if (dir == nullptr || dir->GetFile(Common::FS::GetFilename(path)) == nullptr) {
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
if (!dir->DeleteFile(Common::FS::GetFilename(path))) {
|
||||
// TODO(DarkLordZach): Find a better error code for this
|
||||
|
@ -152,12 +152,12 @@ Result VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_,
|
|||
if (Common::FS::GetParentPath(src_path) == Common::FS::GetParentPath(dest_path)) {
|
||||
// Use more-optimized vfs implementation rename.
|
||||
if (src == nullptr) {
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
|
||||
if (dst && Common::FS::Exists(dst->GetFullPath())) {
|
||||
LOG_ERROR(Service_FS, "File at new_path={} already exists", dst->GetFullPath());
|
||||
return FileSys::ERROR_PATH_ALREADY_EXISTS;
|
||||
return FileSys::ResultPathAlreadyExists;
|
||||
}
|
||||
|
||||
if (!src->Rename(Common::FS::GetFilename(dest_path))) {
|
||||
|
@ -194,7 +194,7 @@ Result VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_path_,
|
|||
if (Common::FS::GetParentPath(src_path) == Common::FS::GetParentPath(dest_path)) {
|
||||
// Use more-optimized vfs implementation rename.
|
||||
if (src == nullptr)
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
if (!src->Rename(Common::FS::GetFilename(dest_path))) {
|
||||
// TODO(DarkLordZach): Find a better error code for this
|
||||
return ResultUnknown;
|
||||
|
@ -223,7 +223,7 @@ Result VfsDirectoryServiceWrapper::OpenFile(FileSys::VirtualFile* out_file,
|
|||
|
||||
auto file = backing->GetFileRelative(npath);
|
||||
if (file == nullptr) {
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
|
||||
if (mode == FileSys::OpenMode::AllowAppend) {
|
||||
|
@ -241,7 +241,7 @@ Result VfsDirectoryServiceWrapper::OpenDirectory(FileSys::VirtualDir* out_direct
|
|||
auto dir = GetDirectoryRelativeWrapped(backing, path);
|
||||
if (dir == nullptr) {
|
||||
// TODO(DarkLordZach): Find a better error code for this
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
*out_directory = dir;
|
||||
return ResultSuccess;
|
||||
|
@ -252,7 +252,7 @@ Result VfsDirectoryServiceWrapper::GetEntryType(FileSys::DirectoryEntryType* out
|
|||
std::string path(Common::FS::SanitizePath(path_));
|
||||
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
|
||||
if (dir == nullptr) {
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
|
||||
auto filename = Common::FS::GetFilename(path);
|
||||
|
@ -272,19 +272,19 @@ Result VfsDirectoryServiceWrapper::GetEntryType(FileSys::DirectoryEntryType* out
|
|||
return ResultSuccess;
|
||||
}
|
||||
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
|
||||
Result VfsDirectoryServiceWrapper::GetFileTimeStampRaw(
|
||||
FileSys::FileTimeStampRaw* out_file_time_stamp_raw, const std::string& path) const {
|
||||
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
|
||||
if (dir == nullptr) {
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
|
||||
FileSys::DirectoryEntryType entry_type;
|
||||
if (GetEntryType(&entry_type, path) != ResultSuccess) {
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
return FileSys::ResultPathNotFound;
|
||||
}
|
||||
|
||||
*out_file_time_stamp_raw = dir->GetFileTimeStamp(Common::FS::GetFilename(path));
|
||||
|
@ -317,7 +317,7 @@ Result FileSystemController::OpenProcess(
|
|||
|
||||
const auto it = registrations.find(process_id);
|
||||
if (it == registrations.end()) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
return FileSys::ResultTargetNotFound;
|
||||
}
|
||||
|
||||
*out_program_id = it->second.program_id;
|
||||
|
@ -360,12 +360,12 @@ Result FileSystemController::OpenSDMC(FileSys::VirtualDir* out_sdmc) const {
|
|||
LOG_TRACE(Service_FS, "Opening SDMC");
|
||||
|
||||
if (sdmc_factory == nullptr) {
|
||||
return FileSys::ERROR_SD_CARD_NOT_FOUND;
|
||||
return FileSys::ResultPortSdCardNoDevice;
|
||||
}
|
||||
|
||||
auto sdmc = sdmc_factory->Open();
|
||||
if (sdmc == nullptr) {
|
||||
return FileSys::ERROR_SD_CARD_NOT_FOUND;
|
||||
return FileSys::ResultPortSdCardNoDevice;
|
||||
}
|
||||
|
||||
*out_sdmc = sdmc;
|
||||
|
@ -377,12 +377,12 @@ Result FileSystemController::OpenBISPartition(FileSys::VirtualDir* out_bis_parti
|
|||
LOG_TRACE(Service_FS, "Opening BIS Partition with id={:08X}", id);
|
||||
|
||||
if (bis_factory == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
return FileSys::ResultTargetNotFound;
|
||||
}
|
||||
|
||||
auto part = bis_factory->OpenPartition(id);
|
||||
if (part == nullptr) {
|
||||
return FileSys::ERROR_INVALID_ARGUMENT;
|
||||
return FileSys::ResultInvalidArgument;
|
||||
}
|
||||
|
||||
*out_bis_partition = part;
|
||||
|
@ -394,12 +394,12 @@ Result FileSystemController::OpenBISPartitionStorage(
|
|||
LOG_TRACE(Service_FS, "Opening BIS Partition Storage with id={:08X}", id);
|
||||
|
||||
if (bis_factory == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
return FileSys::ResultTargetNotFound;
|
||||
}
|
||||
|
||||
auto part = bis_factory->OpenPartitionStorage(id, system.GetFilesystem());
|
||||
if (part == nullptr) {
|
||||
return FileSys::ERROR_INVALID_ARGUMENT;
|
||||
return FileSys::ResultInvalidArgument;
|
||||
}
|
||||
|
||||
*out_bis_partition_storage = part;
|
||||
|
|
|
@ -33,13 +33,13 @@ void IFile::Read(HLERequestContext& ctx) {
|
|||
if (length < 0) {
|
||||
LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(FileSys::ERROR_INVALID_SIZE);
|
||||
rb.Push(FileSys::ResultInvalidSize);
|
||||
return;
|
||||
}
|
||||
if (offset < 0) {
|
||||
LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(FileSys::ERROR_INVALID_OFFSET);
|
||||
rb.Push(FileSys::ResultInvalidOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -66,13 +66,13 @@ void IFile::Write(HLERequestContext& ctx) {
|
|||
if (length < 0) {
|
||||
LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(FileSys::ERROR_INVALID_SIZE);
|
||||
rb.Push(FileSys::ResultInvalidSize);
|
||||
return;
|
||||
}
|
||||
if (offset < 0) {
|
||||
LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(FileSys::ERROR_INVALID_OFFSET);
|
||||
rb.Push(FileSys::ResultInvalidOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ void IStorage::Read(HLERequestContext& ctx) {
|
|||
if (length < 0) {
|
||||
LOG_ERROR(Service_FS, "Length is less than 0, length={}", length);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(FileSys::ERROR_INVALID_SIZE);
|
||||
rb.Push(FileSys::ResultInvalidSize);
|
||||
return;
|
||||
}
|
||||
if (offset < 0) {
|
||||
LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(FileSys::ERROR_INVALID_OFFSET);
|
||||
rb.Push(FileSys::ResultInvalidOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ void FSP_SRV::OpenSaveDataFileSystem(HLERequestContext& ctx) {
|
|||
save_data_controller->OpenSaveData(&dir, parameters.space_id, parameters.attribute);
|
||||
if (result != ResultSuccess) {
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 0};
|
||||
rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND);
|
||||
rb.Push(FileSys::ResultTargetNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ void FSP_SRV::OpenPatchDataStorageByCurrentProcess(HLERequestContext& ctx) {
|
|||
LOG_DEBUG(Service_FS, "called with storage_id={:02X}, title_id={:016X}", storage_id, title_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND);
|
||||
rb.Push(FileSys::ResultTargetNotFound);
|
||||
}
|
||||
|
||||
void FSP_SRV::OpenDataStorageWithProgramIndex(HLERequestContext& ctx) {
|
||||
|
|
|
@ -44,7 +44,7 @@ Result SaveDataController::CreateSaveData(FileSys::VirtualDir* out_save_data,
|
|||
|
||||
auto save_data = factory->Create(space, attribute);
|
||||
if (save_data == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
return FileSys::ResultTargetNotFound;
|
||||
}
|
||||
|
||||
*out_save_data = save_data;
|
||||
|
@ -56,7 +56,7 @@ Result SaveDataController::OpenSaveData(FileSys::VirtualDir* out_save_data,
|
|||
const FileSys::SaveDataAttribute& attribute) {
|
||||
auto save_data = factory->Open(space, attribute);
|
||||
if (save_data == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
return FileSys::ResultTargetNotFound;
|
||||
}
|
||||
|
||||
*out_save_data = save_data;
|
||||
|
@ -67,7 +67,7 @@ Result SaveDataController::OpenSaveDataSpace(FileSys::VirtualDir* out_save_data_
|
|||
FileSys::SaveDataSpaceId space) {
|
||||
auto save_data_space = factory->GetSaveDataSpaceDirectory(space);
|
||||
if (save_data_space == nullptr) {
|
||||
return FileSys::ERROR_ENTITY_NOT_FOUND;
|
||||
return FileSys::ResultTargetNotFound;
|
||||
}
|
||||
|
||||
*out_save_data_space = save_data_space;
|
||||
|
|
|
@ -67,13 +67,13 @@ Result GetFirmwareVersionImpl(FirmwareVersionFormat& out_firmware, Core::System&
|
|||
const auto ver_file = romfs->GetFile("file");
|
||||
if (ver_file == nullptr) {
|
||||
return early_exit_failure("The system version archive didn't contain the file 'file'.",
|
||||
FileSys::ERROR_INVALID_ARGUMENT);
|
||||
FileSys::ResultInvalidArgument);
|
||||
}
|
||||
|
||||
auto data = ver_file->ReadAllBytes();
|
||||
if (data.size() != sizeof(FirmwareVersionFormat)) {
|
||||
return early_exit_failure("The system version file 'file' was not the correct size.",
|
||||
FileSys::ERROR_OUT_OF_BOUNDS);
|
||||
FileSys::ResultOutOfRange);
|
||||
}
|
||||
|
||||
std::memcpy(&out_firmware, data.data(), sizeof(FirmwareVersionFormat));
|
||||
|
|
Loading…
Reference in a new issue