mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-11-03 23:28:48 +00:00 
			
		
		
		
	FileSys: Move all result description to errors.h
This commit is contained in:
		
							parent
							
								
									3b1f0fea31
								
							
						
					
					
						commit
						92be29adba
					
				
					 10 changed files with 115 additions and 105 deletions
				
			
		| 
						 | 
				
			
			@ -22,6 +22,7 @@
 | 
			
		|||
#include "core/file_sys/archive_sdmcwriteonly.h"
 | 
			
		||||
#include "core/file_sys/archive_systemsavedata.h"
 | 
			
		||||
#include "core/file_sys/directory_backend.h"
 | 
			
		||||
#include "core/file_sys/errors.h"
 | 
			
		||||
#include "core/file_sys/file_backend.h"
 | 
			
		||||
#include "core/hle/kernel/client_session.h"
 | 
			
		||||
#include "core/hle/result.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -55,11 +56,6 @@ namespace FS {
 | 
			
		|||
const ResultCode ERR_INVALID_HANDLE(ErrorDescription::InvalidHandle, ErrorModule::FS,
 | 
			
		||||
                                    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
 | 
			
		||||
enum class FileCommand : u32 {
 | 
			
		||||
    Dummy1 = 0x000100C6,
 | 
			
		||||
| 
						 | 
				
			
			@ -284,7 +280,7 @@ ResultVal<ArchiveHandle> OpenArchive(ArchiveIdCode id_code, FileSys::Path& archi
 | 
			
		|||
 | 
			
		||||
ResultCode CloseArchive(ArchiveHandle handle) {
 | 
			
		||||
    if (handle_map.erase(handle) == 0)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
    else
 | 
			
		||||
        return RESULT_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -309,7 +305,7 @@ ResultVal<std::shared_ptr<File>> OpenFileFromArchive(ArchiveHandle archive_handl
 | 
			
		|||
                                                     const FileSys::Mode mode) {
 | 
			
		||||
    ArchiveBackend* archive = GetArchive(archive_handle);
 | 
			
		||||
    if (archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    auto backend = archive->OpenFile(path, mode);
 | 
			
		||||
    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) {
 | 
			
		||||
    ArchiveBackend* archive = GetArchive(archive_handle);
 | 
			
		||||
    if (archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    return archive->DeleteFile(path);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -334,7 +330,7 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
 | 
			
		|||
    ArchiveBackend* src_archive = GetArchive(src_archive_handle);
 | 
			
		||||
    ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
 | 
			
		||||
    if (src_archive == nullptr || dest_archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    if (src_archive == dest_archive) {
 | 
			
		||||
        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) {
 | 
			
		||||
    ArchiveBackend* archive = GetArchive(archive_handle);
 | 
			
		||||
    if (archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    return archive->DeleteDirectory(path);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -356,7 +352,7 @@ ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
 | 
			
		|||
                                                 const FileSys::Path& path) {
 | 
			
		||||
    ArchiveBackend* archive = GetArchive(archive_handle);
 | 
			
		||||
    if (archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    return archive->DeleteDirectoryRecursively(path);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -365,7 +361,7 @@ ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path
 | 
			
		|||
                               u64 file_size) {
 | 
			
		||||
    ArchiveBackend* archive = GetArchive(archive_handle);
 | 
			
		||||
    if (archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    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) {
 | 
			
		||||
    ArchiveBackend* archive = GetArchive(archive_handle);
 | 
			
		||||
    if (archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    return archive->CreateDirectory(path);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -385,7 +381,7 @@ ResultCode RenameDirectoryBetweenArchives(ArchiveHandle src_archive_handle,
 | 
			
		|||
    ArchiveBackend* src_archive = GetArchive(src_archive_handle);
 | 
			
		||||
    ArchiveBackend* dest_archive = GetArchive(dest_archive_handle);
 | 
			
		||||
    if (src_archive == nullptr || dest_archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    if (src_archive == dest_archive) {
 | 
			
		||||
        return src_archive->RenameDirectory(src_path, dest_path);
 | 
			
		||||
| 
						 | 
				
			
			@ -399,7 +395,7 @@ ResultVal<std::shared_ptr<Directory>> OpenDirectoryFromArchive(ArchiveHandle arc
 | 
			
		|||
                                                               const FileSys::Path& path) {
 | 
			
		||||
    ArchiveBackend* archive = GetArchive(archive_handle);
 | 
			
		||||
    if (archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
 | 
			
		||||
    auto backend = archive->OpenDirectory(path);
 | 
			
		||||
    if (backend.Failed())
 | 
			
		||||
| 
						 | 
				
			
			@ -412,7 +408,7 @@ ResultVal<std::shared_ptr<Directory>> OpenDirectoryFromArchive(ArchiveHandle arc
 | 
			
		|||
ResultVal<u64> GetFreeBytesInArchive(ArchiveHandle archive_handle) {
 | 
			
		||||
    ArchiveBackend* archive = GetArchive(archive_handle);
 | 
			
		||||
    if (archive == nullptr)
 | 
			
		||||
        return ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;
 | 
			
		||||
    return MakeResult<u64>(archive->GetFreeBytes());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,6 +8,7 @@
 | 
			
		|||
#include "common/logging/log.h"
 | 
			
		||||
#include "common/scope_exit.h"
 | 
			
		||||
#include "common/string_util.h"
 | 
			
		||||
#include "core/file_sys/errors.h"
 | 
			
		||||
#include "core/hle/kernel/client_session.h"
 | 
			
		||||
#include "core/hle/result.h"
 | 
			
		||||
#include "core/hle/service/fs/archive.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -539,9 +540,7 @@ static void FormatSaveData(Service::Interface* self) {
 | 
			
		|||
    if (archive_id != FS::ArchiveIdCode::SaveData) {
 | 
			
		||||
        LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u",
 | 
			
		||||
                  static_cast<u32>(archive_id));
 | 
			
		||||
        cmd_buff[1] = ResultCode(ErrorDescription::FS_InvalidPath, ErrorModule::FS,
 | 
			
		||||
                                 ErrorSummary::InvalidArgument, ErrorLevel::Usage)
 | 
			
		||||
                          .raw;
 | 
			
		||||
        cmd_buff[1] = FileSys::ERROR_INVALID_PATH.raw;
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue