mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-11-26 12:15:42 +01:00
FileSys: Move all result description to errors.h
This commit is contained in:
parent
3b1f0fea31
commit
92be29adba
@ -38,8 +38,7 @@ public:
|
|||||||
ResultVal<size_t> Write(u64 offset, size_t length, bool flush,
|
ResultVal<size_t> Write(u64 offset, size_t length, bool flush,
|
||||||
const u8* buffer) const override {
|
const u8* buffer) const override {
|
||||||
if (offset > size) {
|
if (offset > size) {
|
||||||
return ResultCode(ErrorDescription::FS_WriteBeyondEnd, ErrorModule::FS,
|
return ERR_WRITE_BEYOND_END;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
|
||||||
} else if (offset == size) {
|
} else if (offset == size) {
|
||||||
return MakeResult<size_t>(0);
|
return MakeResult<size_t>(0);
|
||||||
}
|
}
|
||||||
@ -191,11 +190,9 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(cons
|
|||||||
// TODO(Subv): Verify the archive behavior of SharedExtSaveData compared to ExtSaveData.
|
// TODO(Subv): Verify the archive behavior of SharedExtSaveData compared to ExtSaveData.
|
||||||
// ExtSaveData seems to return FS_NotFound (120) when the archive doesn't exist.
|
// ExtSaveData seems to return FS_NotFound (120) when the archive doesn't exist.
|
||||||
if (!shared) {
|
if (!shared) {
|
||||||
return ResultCode(ErrorDescription::FS_NotFound, ErrorModule::FS,
|
return ERR_NOT_FOUND_INVALID_STATE;
|
||||||
ErrorSummary::InvalidState, ErrorLevel::Status);
|
|
||||||
} else {
|
} else {
|
||||||
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
|
return ERR_NOT_FORMATTED;
|
||||||
ErrorSummary::InvalidState, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto archive = std::make_unique<ExtSaveDataArchive>(fullpath);
|
auto archive = std::make_unique<ExtSaveDataArchive>(fullpath);
|
||||||
@ -230,8 +227,7 @@ ResultVal<ArchiveFormatInfo> ArchiveFactory_ExtSaveData::GetFormatInfo(const Pat
|
|||||||
if (!file.IsOpen()) {
|
if (!file.IsOpen()) {
|
||||||
LOG_ERROR(Service_FS, "Could not open metadata information for archive");
|
LOG_ERROR(Service_FS, "Could not open metadata information for archive");
|
||||||
// TODO(Subv): Verify error code
|
// TODO(Subv): Verify error code
|
||||||
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
|
return ERR_NOT_FORMATTED;
|
||||||
ErrorSummary::InvalidState, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveFormatInfo info = {};
|
ArchiveFormatInfo info = {};
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/file_sys/archive_source_sd_savedata.h"
|
#include "core/file_sys/archive_source_sd_savedata.h"
|
||||||
|
#include "core/file_sys/errors.h"
|
||||||
#include "core/file_sys/savedata_archive.h"
|
#include "core/file_sys/savedata_archive.h"
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
|
|
||||||
@ -49,8 +50,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveSource_SDSaveData::Open(u64 pr
|
|||||||
// save file/directory structure expected by the game has not yet been initialized.
|
// save file/directory structure expected by the game has not yet been initialized.
|
||||||
// Returning the NotFormatted error code will signal the game to provision the SaveData
|
// Returning the NotFormatted error code will signal the game to provision the SaveData
|
||||||
// archive with the files and folders that it expects.
|
// archive with the files and folders that it expects.
|
||||||
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
|
return ERR_NOT_FORMATTED;
|
||||||
ErrorSummary::InvalidState, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto archive = std::make_unique<SaveDataArchive>(std::move(concrete_mount_point));
|
auto archive = std::make_unique<SaveDataArchive>(std::move(concrete_mount_point));
|
||||||
@ -81,8 +81,7 @@ ResultVal<ArchiveFormatInfo> ArchiveSource_SDSaveData::GetFormatInfo(u64 program
|
|||||||
if (!file.IsOpen()) {
|
if (!file.IsOpen()) {
|
||||||
LOG_ERROR(Service_FS, "Could not open metadata information for archive");
|
LOG_ERROR(Service_FS, "Could not open metadata information for archive");
|
||||||
// TODO(Subv): Verify error code
|
// TODO(Subv): Verify error code
|
||||||
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
|
return ERR_NOT_FORMATTED;
|
||||||
ErrorSummary::InvalidState, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchiveFormatInfo info = {};
|
ArchiveFormatInfo info = {};
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/file_sys/archive_systemsavedata.h"
|
#include "core/file_sys/archive_systemsavedata.h"
|
||||||
|
#include "core/file_sys/errors.h"
|
||||||
#include "core/file_sys/savedata_archive.h"
|
#include "core/file_sys/savedata_archive.h"
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
|
|
||||||
@ -53,8 +54,7 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_SystemSaveData::Open(c
|
|||||||
std::string fullpath = GetSystemSaveDataPath(base_path, path);
|
std::string fullpath = GetSystemSaveDataPath(base_path, path);
|
||||||
if (!FileUtil::Exists(fullpath)) {
|
if (!FileUtil::Exists(fullpath)) {
|
||||||
// TODO(Subv): Check error code, this one is probably wrong
|
// TODO(Subv): Check error code, this one is probably wrong
|
||||||
return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS,
|
return ERR_NOT_FORMATTED;
|
||||||
ErrorSummary::InvalidState, ErrorLevel::Status);
|
|
||||||
}
|
}
|
||||||
auto archive = std::make_unique<SaveDataArchive>(fullpath);
|
auto archive = std::make_unique<SaveDataArchive>(fullpath);
|
||||||
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
|
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/file_sys/disk_archive.h"
|
#include "core/file_sys/disk_archive.h"
|
||||||
|
#include "core/file_sys/errors.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FileSys namespace
|
// FileSys namespace
|
||||||
@ -17,8 +18,7 @@ namespace FileSys {
|
|||||||
|
|
||||||
ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const {
|
ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const {
|
||||||
if (!mode.read_flag)
|
if (!mode.read_flag)
|
||||||
return ResultCode(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS,
|
return ERROR_INVALID_OPEN_FLAGS;
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
|
||||||
|
|
||||||
file->Seek(offset, SEEK_SET);
|
file->Seek(offset, SEEK_SET);
|
||||||
return MakeResult<size_t>(file->ReadBytes(buffer, length));
|
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
|
|||||||
ResultVal<size_t> DiskFile::Write(const u64 offset, const size_t length, const bool flush,
|
ResultVal<size_t> DiskFile::Write(const u64 offset, const size_t length, const bool flush,
|
||||||
const u8* buffer) const {
|
const u8* buffer) const {
|
||||||
if (!mode.write_flag)
|
if (!mode.write_flag)
|
||||||
return ResultCode(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS,
|
return ERROR_INVALID_OPEN_FLAGS;
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
|
||||||
|
|
||||||
file->Seek(offset, SEEK_SET);
|
file->Seek(offset, SEEK_SET);
|
||||||
size_t written = file->WriteBytes(buffer, length);
|
size_t written = file->WriteBytes(buffer, length);
|
||||||
|
@ -2,52 +2,93 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
const ResultCode ERROR_INVALID_PATH(ErrorDescription::FS_InvalidPath, ErrorModule::FS,
|
namespace ErrCodes {
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
enum {
|
||||||
const ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrorDescription::FS_UnsupportedOpenFlags,
|
RomFSNotFound = 100,
|
||||||
ErrorModule::FS, ErrorSummary::NotSupported,
|
ArchiveNotMounted = 101,
|
||||||
ErrorLevel::Usage);
|
FileNotFound = 112,
|
||||||
const ResultCode ERROR_INVALID_OPEN_FLAGS(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS,
|
PathNotFound = 113,
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
GameCardNotInserted = 141,
|
||||||
const ResultCode ERROR_INVALID_READ_FLAG(ErrorDescription::FS_InvalidReadFlag, ErrorModule::FS,
|
NotFound = 120,
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
FileAlreadyExists = 180,
|
||||||
const ResultCode ERROR_FILE_NOT_FOUND(ErrorDescription::FS_FileNotFound, ErrorModule::FS,
|
DirectoryAlreadyExists = 185,
|
||||||
ErrorSummary::NotFound, ErrorLevel::Status);
|
AlreadyExists = 190,
|
||||||
const ResultCode ERROR_PATH_NOT_FOUND(ErrorDescription::FS_PathNotFound, ErrorModule::FS,
|
InvalidOpenFlags = 230,
|
||||||
ErrorSummary::NotFound, ErrorLevel::Status);
|
DirectoryNotEmpty = 240,
|
||||||
const ResultCode ERROR_NOT_FOUND(ErrorDescription::FS_NotFound, ErrorModule::FS,
|
NotAFile = 250,
|
||||||
ErrorSummary::NotFound, ErrorLevel::Status);
|
NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive
|
||||||
const ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrorDescription::FS_UnexpectedFileOrDirectory,
|
ExeFSSectionNotFound = 567,
|
||||||
ErrorModule::FS, ErrorSummary::NotSupported,
|
CommandNotAllowed = 630,
|
||||||
ErrorLevel::Usage);
|
InvalidReadFlag = 700,
|
||||||
const ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC(ErrorDescription::FS_NotAFile,
|
InvalidPath = 702,
|
||||||
ErrorModule::FS, ErrorSummary::Canceled,
|
WriteBeyondEnd = 705,
|
||||||
ErrorLevel::Status);
|
UnsupportedOpenFlags = 760,
|
||||||
const ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ErrorDescription::FS_DirectoryAlreadyExists,
|
IncorrectExeFSReadSize = 761,
|
||||||
ErrorModule::FS, ErrorSummary::NothingHappened,
|
UnexpectedFileOrDirectory = 770,
|
||||||
ErrorLevel::Status);
|
};
|
||||||
const ResultCode ERROR_FILE_ALREADY_EXISTS(ErrorDescription::FS_FileAlreadyExists, ErrorModule::FS,
|
}
|
||||||
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
|
||||||
const ResultCode ERROR_ALREADY_EXISTS(ErrorDescription::FS_AlreadyExists, ErrorModule::FS,
|
constexpr ResultCode ERROR_INVALID_PATH(ErrCodes::InvalidPath, ErrorModule::FS,
|
||||||
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
||||||
const ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrorDescription::FS_DirectoryNotEmpty, ErrorModule::FS,
|
constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ErrCodes::UnsupportedOpenFlags, ErrorModule::FS,
|
||||||
ErrorSummary::Canceled, ErrorLevel::Status);
|
ErrorSummary::NotSupported, ErrorLevel::Usage);
|
||||||
const ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrorDescription::FS_GameCardNotInserted,
|
constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ErrCodes::InvalidOpenFlags, ErrorModule::FS,
|
||||||
ErrorModule::FS, ErrorSummary::NotFound,
|
ErrorSummary::Canceled, ErrorLevel::Status);
|
||||||
ErrorLevel::Status);
|
constexpr ResultCode ERROR_INVALID_READ_FLAG(ErrCodes::InvalidReadFlag, ErrorModule::FS,
|
||||||
const ResultCode ERROR_INCORRECT_EXEFS_READ_SIZE(ErrorDescription::FS_IncorrectExeFSReadSize,
|
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
||||||
ErrorModule::FS, ErrorSummary::NotSupported,
|
constexpr ResultCode ERROR_FILE_NOT_FOUND(ErrCodes::FileNotFound, ErrorModule::FS,
|
||||||
ErrorLevel::Usage);
|
ErrorSummary::NotFound, ErrorLevel::Status);
|
||||||
const ResultCode ERROR_ROMFS_NOT_FOUND(ErrorDescription::FS_RomFSNotFound, ErrorModule::FS,
|
constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrCodes::PathNotFound, ErrorModule::FS,
|
||||||
ErrorSummary::NotFound, ErrorLevel::Status);
|
ErrorSummary::NotFound, ErrorLevel::Status);
|
||||||
const ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrorDescription::FS_CommandNotAllowed, ErrorModule::FS,
|
constexpr ResultCode ERROR_NOT_FOUND(ErrCodes::NotFound, ErrorModule::FS, ErrorSummary::NotFound,
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
ErrorLevel::Status);
|
||||||
const ResultCode ERROR_EXEFS_SECTION_NOT_FOUND(ErrorDescription::FS_ExeFSSectionNotFound,
|
constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ErrCodes::UnexpectedFileOrDirectory,
|
||||||
ErrorModule::FS, ErrorSummary::NotFound,
|
ErrorModule::FS, ErrorSummary::NotSupported,
|
||||||
ErrorLevel::Status);
|
ErrorLevel::Usage);
|
||||||
|
constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY_SDMC(ErrCodes::NotAFile, ErrorModule::FS,
|
||||||
|
ErrorSummary::Canceled,
|
||||||
|
ErrorLevel::Status);
|
||||||
|
constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ErrCodes::DirectoryAlreadyExists,
|
||||||
|
ErrorModule::FS, ErrorSummary::NothingHappened,
|
||||||
|
ErrorLevel::Status);
|
||||||
|
constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ErrCodes::FileAlreadyExists, ErrorModule::FS,
|
||||||
|
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
||||||
|
constexpr ResultCode ERROR_ALREADY_EXISTS(ErrCodes::AlreadyExists, ErrorModule::FS,
|
||||||
|
ErrorSummary::NothingHappened, ErrorLevel::Status);
|
||||||
|
constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(ErrCodes::DirectoryNotEmpty, ErrorModule::FS,
|
||||||
|
ErrorSummary::Canceled, ErrorLevel::Status);
|
||||||
|
constexpr ResultCode ERROR_GAMECARD_NOT_INSERTED(ErrCodes::GameCardNotInserted, ErrorModule::FS,
|
||||||
|
ErrorSummary::NotFound, ErrorLevel::Status);
|
||||||
|
constexpr ResultCode ERROR_INCORRECT_EXEFS_READ_SIZE(ErrCodes::IncorrectExeFSReadSize,
|
||||||
|
ErrorModule::FS, ErrorSummary::NotSupported,
|
||||||
|
ErrorLevel::Usage);
|
||||||
|
constexpr ResultCode ERROR_ROMFS_NOT_FOUND(ErrCodes::RomFSNotFound, ErrorModule::FS,
|
||||||
|
ErrorSummary::NotFound, ErrorLevel::Status);
|
||||||
|
constexpr ResultCode ERROR_COMMAND_NOT_ALLOWED(ErrCodes::CommandNotAllowed, ErrorModule::FS,
|
||||||
|
ErrorSummary::WrongArgument, ErrorLevel::Permanent);
|
||||||
|
constexpr ResultCode ERROR_EXEFS_SECTION_NOT_FOUND(ErrCodes::ExeFSSectionNotFound, ErrorModule::FS,
|
||||||
|
ErrorSummary::NotFound, ErrorLevel::Status);
|
||||||
|
|
||||||
|
/// Returned when a function is passed an invalid archive handle.
|
||||||
|
constexpr ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrCodes::ArchiveNotMounted, ErrorModule::FS,
|
||||||
|
ErrorSummary::NotFound,
|
||||||
|
ErrorLevel::Status); // 0xC8804465
|
||||||
|
constexpr ResultCode ERR_WRITE_BEYOND_END(ErrCodes::WriteBeyondEnd, ErrorModule::FS,
|
||||||
|
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Variant of ERROR_NOT_FOUND returned in some places in the code. Unknown if these usages are
|
||||||
|
* correct or a bug.
|
||||||
|
*/
|
||||||
|
constexpr ResultCode ERR_NOT_FOUND_INVALID_STATE(ErrCodes::NotFound, ErrorModule::FS,
|
||||||
|
ErrorSummary::InvalidState, ErrorLevel::Status);
|
||||||
|
constexpr ResultCode ERR_NOT_FORMATTED(ErrCodes::NotFormatted, ErrorModule::FS,
|
||||||
|
ErrorSummary::InvalidState, ErrorLevel::Status);
|
||||||
|
|
||||||
} // namespace FileSys
|
} // namespace FileSys
|
||||||
|
@ -26,30 +26,9 @@ enum class ErrorDescription : u32 {
|
|||||||
OS_InvalidBufferDescriptor = 48,
|
OS_InvalidBufferDescriptor = 48,
|
||||||
MaxConnectionsReached = 52,
|
MaxConnectionsReached = 52,
|
||||||
WrongAddress = 53,
|
WrongAddress = 53,
|
||||||
FS_RomFSNotFound = 100,
|
|
||||||
FS_ArchiveNotMounted = 101,
|
|
||||||
FS_FileNotFound = 112,
|
|
||||||
FS_PathNotFound = 113,
|
|
||||||
FS_GameCardNotInserted = 141,
|
|
||||||
FS_NotFound = 120,
|
|
||||||
FS_FileAlreadyExists = 180,
|
|
||||||
FS_DirectoryAlreadyExists = 185,
|
|
||||||
FS_AlreadyExists = 190,
|
|
||||||
FS_InvalidOpenFlags = 230,
|
|
||||||
FS_DirectoryNotEmpty = 240,
|
|
||||||
FS_NotAFile = 250,
|
|
||||||
FS_NotFormatted = 340, ///< This is used by the FS service when creating a SaveData archive
|
|
||||||
OutofRangeOrMisalignedAddress =
|
OutofRangeOrMisalignedAddress =
|
||||||
513, // TODO(purpasmart): Check if this name fits its actual usage
|
513, // TODO(purpasmart): Check if this name fits its actual usage
|
||||||
GPU_FirstInitialization = 519,
|
GPU_FirstInitialization = 519,
|
||||||
FS_ExeFSSectionNotFound = 567,
|
|
||||||
FS_CommandNotAllowed = 630,
|
|
||||||
FS_InvalidReadFlag = 700,
|
|
||||||
FS_InvalidPath = 702,
|
|
||||||
FS_WriteBeyondEnd = 705,
|
|
||||||
FS_UnsupportedOpenFlags = 760,
|
|
||||||
FS_IncorrectExeFSReadSize = 761,
|
|
||||||
FS_UnexpectedFileOrDirectory = 770,
|
|
||||||
|
|
||||||
// Codes 1000 and above are considered "well-known" and have common values between all modules.
|
// Codes 1000 and above are considered "well-known" and have common values between all modules.
|
||||||
InvalidSection = 1000,
|
InvalidSection = 1000,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "common/swap.h"
|
#include "common/swap.h"
|
||||||
#include "core/file_sys/archive_systemsavedata.h"
|
#include "core/file_sys/archive_systemsavedata.h"
|
||||||
|
#include "core/file_sys/errors.h"
|
||||||
#include "core/file_sys/file_backend.h"
|
#include "core/file_sys/file_backend.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/cfg/cfg.h"
|
#include "core/hle/service/cfg/cfg.h"
|
||||||
@ -411,8 +412,7 @@ ResultCode UpdateConfigNANDSavegame() {
|
|||||||
ResultCode FormatConfig() {
|
ResultCode FormatConfig() {
|
||||||
ResultCode res = DeleteConfigNANDSaveFile();
|
ResultCode res = DeleteConfigNANDSaveFile();
|
||||||
// The delete command fails if the file doesn't exist, so we have to check that too
|
// The delete command fails if the file doesn't exist, so we have to check that too
|
||||||
if (!res.IsSuccess() &&
|
if (!res.IsSuccess() && res != FileSys::ERROR_FILE_NOT_FOUND) {
|
||||||
res.description != static_cast<u32>(ErrorDescription::FS_FileNotFound)) {
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// Delete the old data
|
// Delete the old data
|
||||||
@ -535,7 +535,7 @@ ResultCode LoadConfigNANDSaveFile() {
|
|||||||
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
|
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
|
||||||
|
|
||||||
// If the archive didn't exist, create the files inside
|
// If the archive didn't exist, create the files inside
|
||||||
if (archive_result.Code().description == static_cast<u32>(ErrorDescription::FS_NotFormatted)) {
|
if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
|
||||||
// Format the archive to create the directories
|
// Format the archive to create the directories
|
||||||
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData,
|
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData,
|
||||||
FileSys::ArchiveFormatInfo(), archive_path);
|
FileSys::ArchiveFormatInfo(), archive_path);
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "core/file_sys/archive_sdmcwriteonly.h"
|
#include "core/file_sys/archive_sdmcwriteonly.h"
|
||||||
#include "core/file_sys/archive_systemsavedata.h"
|
#include "core/file_sys/archive_systemsavedata.h"
|
||||||
#include "core/file_sys/directory_backend.h"
|
#include "core/file_sys/directory_backend.h"
|
||||||
|
#include "core/file_sys/errors.h"
|
||||||
#include "core/file_sys/file_backend.h"
|
#include "core/file_sys/file_backend.h"
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
@ -55,11 +56,6 @@ namespace FS {
|
|||||||
const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS,
|
const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS,
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
|
||||||
|
|
||||||
/// Returned when a function is passed an invalid archive handle.
|
|
||||||
const ResultCode ERR_INVALID_ARCHIVE_HANDLE(ErrorDescription::FS_ArchiveNotMounted, ErrorModule::FS,
|
|
||||||
ErrorSummary::NotFound,
|
|
||||||
ErrorLevel::Status); // 0xC8804465
|
|
||||||
|
|
||||||
// Command to access archive file
|
// Command to access archive file
|
||||||
enum class FileCommand : u32 {
|
enum class FileCommand : u32 {
|
||||||
Dummy1 = 0x000100C6,
|
Dummy1 = 0x000100C6,
|
||||||
@ -284,7 +280,7 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
|
|||||||
|
|
||||||
ResultCode CloseArchive(ArchiveHandle handle) {
|
ResultCode CloseArchive(ArchiveHandle handle) {
|
||||||
if (handle_map.erase(handle) == 0)
|
if (handle_map.erase(handle) == 0)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
else
|
else
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -309,7 +305,7 @@ ResultVal<std::shared_ptr<File>> OpenFileFromArchive(ArchiveHandle archive_handl
|
|||||||
const FileSys::Mode mode) {
|
const FileSys::Mode mode) {
|
||||||
ArchiveBackend* archive = GetArchive(archive_handle);
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
auto backend = archive->OpenFile(path, mode);
|
auto backend = archive->OpenFile(path, mode);
|
||||||
if (backend.Failed())
|
if (backend.Failed())
|
||||||
@ -322,7 +318,7 @@ ResultVal<std::shared_ptr<File>> OpenFileFromArchive(ArchiveHandle archive_handl
|
|||||||
ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
ResultCode DeleteFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
||||||
ArchiveBackend* archive = GetArchive(archive_handle);
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
return archive->DeleteFile(path);
|
return archive->DeleteFile(path);
|
||||||
}
|
}
|
||||||
@ -334,7 +330,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
|
|||||||
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
|
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
|
||||||
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
|
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
|
||||||
if (src_archive == nullptr || dest_archive == nullptr)
|
if (src_archive == nullptr || dest_archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
if (src_archive == dest_archive) {
|
if (src_archive == dest_archive) {
|
||||||
return src_archive->RenameFile(src_path, dest_path);
|
return src_archive->RenameFile(src_path, dest_path);
|
||||||
@ -347,7 +343,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
|
|||||||
ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
||||||
ArchiveBackend* archive = GetArchive(archive_handle);
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
return archive->DeleteDirectory(path);
|
return archive->DeleteDirectory(path);
|
||||||
}
|
}
|
||||||
@ -356,7 +352,7 @@ ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
|
|||||||
const FileSys::Path& path) {
|
const FileSys::Path& path) {
|
||||||
ArchiveBackend* archive = GetArchive(archive_handle);
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
return archive->DeleteDirectoryRecursively(path);
|
return archive->DeleteDirectoryRecursively(path);
|
||||||
}
|
}
|
||||||
@ -365,7 +361,7 @@ ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path
|
|||||||
u64 file_size) {
|
u64 file_size) {
|
||||||
ArchiveBackend* archive = GetArchive(archive_handle);
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
return archive->CreateFile(path, file_size);
|
return archive->CreateFile(path, file_size);
|
||||||
}
|
}
|
||||||
@ -373,7 +369,7 @@ ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path
|
|||||||
ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
ResultCode CreateDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path) {
|
||||||
ArchiveBackend* archive = GetArchive(archive_handle);
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
return archive->CreateDirectory(path);
|
return archive->CreateDirectory(path);
|
||||||
}
|
}
|
||||||
@ -385,7 +381,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
|
|||||||
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
|
ArchiveBackend* src_archive = GetArchive(src_archive_handle);
|
||||||
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
|
ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
|
||||||
if (src_archive == nullptr || dest_archive == nullptr)
|
if (src_archive == nullptr || dest_archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
if (src_archive == dest_archive) {
|
if (src_archive == dest_archive) {
|
||||||
return src_archive->RenameDirectory(src_path, dest_path);
|
return src_archive->RenameDirectory(src_path, dest_path);
|
||||||
@ -399,7 +395,7 @@ ResultVal<std::shared_ptr<Directory>> OpenDirectoryFromArchive(ArchiveHandle arc
|
|||||||
const FileSys::Path& path) {
|
const FileSys::Path& path) {
|
||||||
ArchiveBackend* archive = GetArchive(archive_handle);
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
|
|
||||||
auto backend = archive->OpenDirectory(path);
|
auto backend = archive->OpenDirectory(path);
|
||||||
if (backend.Failed())
|
if (backend.Failed())
|
||||||
@ -412,7 +408,7 @@ ResultVal<std::shared_ptr<Directory>> OpenDirectoryFromArchive(ArchiveHandle arc
|
|||||||
ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) {
|
ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) {
|
||||||
ArchiveBackend* archive = GetArchive(archive_handle);
|
ArchiveBackend* archive = GetArchive(archive_handle);
|
||||||
if (archive == nullptr)
|
if (archive == nullptr)
|
||||||
return ERR_INVALID_ARCHIVE_HANDLE;
|
return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
|
||||||
return MakeResult<u64>(archive->GetFreeBytes());
|
return MakeResult<u64>(archive->GetFreeBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
|
#include "core/file_sys/errors.h"
|
||||||
#include "core/hle/kernel/client_session.h"
|
#include "core/hle/kernel/client_session.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
@ -539,9 +540,7 @@ static void FormatSaveData(Service::Interface* self) {
|
|||||||
if (archive_id != FS::ArchiveIdCode::SaveData) {
|
if (archive_id != FS::ArchiveIdCode::SaveData) {
|
||||||
LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u",
|
LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u",
|
||||||
static_cast<u32>(archive_id));
|
static_cast<u32>(archive_id));
|
||||||
cmd_buff[1] = ResultCode(ErrorDescription::FS_InvalidPath, ErrorModule::FS,
|
cmd_buff[1] = FileSys::ERROR_INVALID_PATH.raw;
|
||||||
ErrorSummary::InvalidArgument, ErrorLevel::Usage)
|
|
||||||
.raw;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "core/file_sys/errors.h"
|
||||||
#include "core/file_sys/file_backend.h"
|
#include "core/file_sys/file_backend.h"
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
#include "core/hle/service/ptm/ptm.h"
|
#include "core/hle/service/ptm/ptm.h"
|
||||||
@ -134,7 +135,7 @@ void Init() {
|
|||||||
auto archive_result =
|
auto archive_result =
|
||||||
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
|
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
|
||||||
// If the archive didn't exist, create the files inside
|
// If the archive didn't exist, create the files inside
|
||||||
if (archive_result.Code().description == static_cast<u32>(ErrorDescription::FS_NotFormatted)) {
|
if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) {
|
||||||
// Format the archive to create the directories
|
// Format the archive to create the directories
|
||||||
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData,
|
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData,
|
||||||
FileSys::ArchiveFormatInfo(), archive_path);
|
FileSys::ArchiveFormatInfo(), archive_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user