Merge pull request #1940 from JamePeng/fix-archive-error-code

Fix the errorcode of archive handle
This commit is contained in:
bunnei 2016-07-06 18:37:43 -04:00 committed by GitHub
commit 6fa7b1f486
2 changed files with 15 additions and 10 deletions

View file

@ -20,6 +20,7 @@ enum class ErrorDescription : u32 {
WrongPermission = 46, WrongPermission = 46,
OS_InvalidBufferDescriptor = 48, OS_InvalidBufferDescriptor = 48,
WrongAddress = 53, WrongAddress = 53,
FS_ArchiveNotMounted = 101,
FS_NotFound = 120, FS_NotFound = 120,
FS_AlreadyExists = 190, FS_AlreadyExists = 190,
FS_InvalidOpenFlags = 230, FS_InvalidOpenFlags = 230,

View file

@ -58,6 +58,10 @@ 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,
@ -292,7 +296,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_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
else else
return RESULT_SUCCESS; return RESULT_SUCCESS;
} }
@ -314,7 +318,7 @@ ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_han
const FileSys::Path& path, const FileSys::Mode mode) { const FileSys::Path& path, const FileSys::Mode mode) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) if (archive == nullptr)
return ERR_INVALID_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
auto backend = archive->OpenFile(path, mode); auto backend = archive->OpenFile(path, mode);
if (backend.Failed()) if (backend.Failed())
@ -327,7 +331,7 @@ ResultVal<Kernel::SharedPtr<File>> OpenFileFromArchive(ArchiveHandle archive_han
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_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
return archive->DeleteFile(path); return archive->DeleteFile(path);
} }
@ -337,7 +341,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil
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_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
if (src_archive == dest_archive) { if (src_archive == dest_archive) {
if (src_archive->RenameFile(src_path, dest_path)) if (src_archive->RenameFile(src_path, dest_path))
@ -356,7 +360,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle, const Fil
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_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
if (archive->DeleteDirectory(path)) if (archive->DeleteDirectory(path))
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -367,7 +371,7 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u64 file_size) { ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path, u64 file_size) {
ArchiveBackend* archive = GetArchive(archive_handle); ArchiveBackend* archive = GetArchive(archive_handle);
if (archive == nullptr) if (archive == nullptr)
return ERR_INVALID_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
return archive->CreateFile(path, file_size); return archive->CreateFile(path, file_size);
} }
@ -375,7 +379,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_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
if (archive->CreateDirectory(path)) if (archive->CreateDirectory(path))
return RESULT_SUCCESS; return RESULT_SUCCESS;
@ -388,7 +392,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle, cons
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_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
if (src_archive == dest_archive) { if (src_archive == dest_archive) {
if (src_archive->RenameDirectory(src_path, dest_path)) if (src_archive->RenameDirectory(src_path, dest_path))
@ -408,7 +412,7 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a
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_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
std::unique_ptr<FileSys::DirectoryBackend> backend = archive->OpenDirectory(path); std::unique_ptr<FileSys::DirectoryBackend> backend = archive->OpenDirectory(path);
if (backend == nullptr) { if (backend == nullptr) {
@ -423,7 +427,7 @@ ResultVal<Kernel::SharedPtr<Directory>> OpenDirectoryFromArchive(ArchiveHandle a
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_HANDLE; return ERR_INVALID_ARCHIVE_HANDLE;
return MakeResult<u64>(archive->GetFreeBytes()); return MakeResult<u64>(archive->GetFreeBytes());
} }