diff options
| author | 2014-12-15 02:44:04 -0200 | |
|---|---|---|
| committer | 2014-12-16 01:08:42 -0200 | |
| commit | f6153679b0781eea084b22f3ceecc74b1fe6b018 (patch) | |
| tree | aa8d86cb2a525630c3abf95cfaa658e3fd634516 /src | |
| parent | HLE: Rename namespaces to match move & fix initialization order (diff) | |
| download | yuzu-f6153679b0781eea084b22f3ceecc74b1fe6b018.tar.gz yuzu-f6153679b0781eea084b22f3ceecc74b1fe6b018.tar.xz yuzu-f6153679b0781eea084b22f3ceecc74b1fe6b018.zip | |
Service.FS: Do archive registration using IdCode instead of name
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/archive.h | 17 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.h | 6 | ||||
| -rw-r--r-- | src/core/file_sys/archive_sdmc.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 19 | ||||
| -rw-r--r-- | src/core/hle/service/fs/fs_user.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/loader.cpp | 2 |
7 files changed, 32 insertions, 42 deletions
diff --git a/src/core/file_sys/archive.h b/src/core/file_sys/archive.h index 27ed23cd0..b7978bfbe 100644 --- a/src/core/file_sys/archive.h +++ b/src/core/file_sys/archive.h | |||
| @@ -162,25 +162,12 @@ private: | |||
| 162 | 162 | ||
| 163 | class Archive : NonCopyable { | 163 | class Archive : NonCopyable { |
| 164 | public: | 164 | public: |
| 165 | /// Supported archive types | ||
| 166 | enum class IdCode : u32 { | ||
| 167 | RomFS = 0x00000003, | ||
| 168 | SaveData = 0x00000004, | ||
| 169 | ExtSaveData = 0x00000006, | ||
| 170 | SharedExtSaveData = 0x00000007, | ||
| 171 | SystemSaveData = 0x00000008, | ||
| 172 | SDMC = 0x00000009, | ||
| 173 | SDMCWriteOnly = 0x0000000A, | ||
| 174 | }; | ||
| 175 | |||
| 176 | Archive() { } | ||
| 177 | virtual ~Archive() { } | 165 | virtual ~Archive() { } |
| 178 | 166 | ||
| 179 | /** | 167 | /** |
| 180 | * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.) | 168 | * Get a descriptive name for the archive (e.g. "RomFS", "SaveData", etc.) |
| 181 | * @return IdCode of the archive | ||
| 182 | */ | 169 | */ |
| 183 | virtual IdCode GetIdCode() const = 0; | 170 | virtual std::string GetName() const = 0; |
| 184 | 171 | ||
| 185 | /** | 172 | /** |
| 186 | * Open a file specified by its path, using the specified mode | 173 | * Open a file specified by its path, using the specified mode |
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index 222bdc356..b60fcca99 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h | |||
| @@ -22,11 +22,7 @@ public: | |||
| 22 | Archive_RomFS(const Loader::AppLoader& app_loader); | 22 | Archive_RomFS(const Loader::AppLoader& app_loader); |
| 23 | ~Archive_RomFS() override; | 23 | ~Archive_RomFS() override; |
| 24 | 24 | ||
| 25 | /** | 25 | std::string GetName() const override { return "RomFS"; } |
| 26 | * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.) | ||
| 27 | * @return IdCode of the archive | ||
| 28 | */ | ||
| 29 | IdCode GetIdCode() const override { return IdCode::RomFS; } | ||
| 30 | 26 | ||
| 31 | /** | 27 | /** |
| 32 | * Open a file specified by its path, using the specified mode | 28 | * Open a file specified by its path, using the specified mode |
diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h index 19f563a62..54c18cb0c 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h | |||
| @@ -26,11 +26,7 @@ public: | |||
| 26 | */ | 26 | */ |
| 27 | bool Initialize(); | 27 | bool Initialize(); |
| 28 | 28 | ||
| 29 | /** | 29 | std::string GetName() const override { return "SDMC"; } |
| 30 | * Get the IdCode of the archive (e.g. RomFS, SaveData, etc.) | ||
| 31 | * @return IdCode of the archive | ||
| 32 | */ | ||
| 33 | IdCode GetIdCode() const override { return IdCode::SDMC; } | ||
| 34 | 30 | ||
| 35 | /** | 31 | /** |
| 36 | * Open a file specified by its path, using the specified mode | 32 | * Open a file specified by its path, using the specified mode |
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 5893a944b..61cbfa73c 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -43,9 +43,9 @@ enum class DirectoryCommand : u32 { | |||
| 43 | 43 | ||
| 44 | class Archive : public Kernel::Session { | 44 | class Archive : public Kernel::Session { |
| 45 | public: | 45 | public: |
| 46 | std::string GetName() const override { return "Archive: " + name; } | 46 | std::string GetName() const override { return "Archive: " + backend->GetName(); } |
| 47 | 47 | ||
| 48 | std::string name; ///< Name of archive (optional) | 48 | ArchiveIdCode id_code; ///< Id code of the archive |
| 49 | FileSys::Archive* backend; ///< Archive backend interface | 49 | FileSys::Archive* backend; ///< Archive backend interface |
| 50 | 50 | ||
| 51 | ResultVal<bool> SyncRequest() override { | 51 | ResultVal<bool> SyncRequest() override { |
| @@ -91,7 +91,7 @@ public: | |||
| 91 | case FileCommand::Close: | 91 | case FileCommand::Close: |
| 92 | { | 92 | { |
| 93 | LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); | 93 | LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str()); |
| 94 | CloseArchive(backend->GetIdCode()); | 94 | CloseArchive(id_code); |
| 95 | break; | 95 | break; |
| 96 | } | 96 | } |
| 97 | // Unknown command... | 97 | // Unknown command... |
| @@ -228,9 +228,9 @@ public: | |||
| 228 | 228 | ||
| 229 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 229 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 230 | 230 | ||
| 231 | std::map<FileSys::Archive::IdCode, Handle> g_archive_map; ///< Map of file archives by IdCode | 231 | std::map<ArchiveIdCode, Handle> g_archive_map; ///< Map of file archives by IdCode |
| 232 | 232 | ||
| 233 | ResultVal<Handle> OpenArchive(FileSys::Archive::IdCode id_code) { | 233 | ResultVal<Handle> OpenArchive(ArchiveIdCode id_code) { |
| 234 | auto itr = g_archive_map.find(id_code); | 234 | auto itr = g_archive_map.find(id_code); |
| 235 | if (itr == g_archive_map.end()) { | 235 | if (itr == g_archive_map.end()) { |
| 236 | return ResultCode(ErrorDescription::NotFound, ErrorModule::FS, | 236 | return ResultCode(ErrorDescription::NotFound, ErrorModule::FS, |
| @@ -240,7 +240,7 @@ ResultVal<Handle> OpenArchive(FileSys::Archive::IdCode id_code) { | |||
| 240 | return MakeResult<Handle>(itr->second); | 240 | return MakeResult<Handle>(itr->second); |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | ResultCode CloseArchive(FileSys::Archive::IdCode id_code) { | 243 | ResultCode CloseArchive(ArchiveIdCode id_code) { |
| 244 | auto itr = g_archive_map.find(id_code); | 244 | auto itr = g_archive_map.find(id_code); |
| 245 | if (itr == g_archive_map.end()) { | 245 | if (itr == g_archive_map.end()) { |
| 246 | LOG_ERROR(Service_FS, "Cannot close archive %d, does not exist!", (int)id_code); | 246 | LOG_ERROR(Service_FS, "Cannot close archive %d, does not exist!", (int)id_code); |
| @@ -256,7 +256,7 @@ ResultCode CloseArchive(FileSys::Archive::IdCode id_code) { | |||
| 256 | * @param archive Pointer to the archive to mount | 256 | * @param archive Pointer to the archive to mount |
| 257 | */ | 257 | */ |
| 258 | ResultCode MountArchive(Archive* archive) { | 258 | ResultCode MountArchive(Archive* archive) { |
| 259 | FileSys::Archive::IdCode id_code = archive->backend->GetIdCode(); | 259 | ArchiveIdCode id_code = archive->id_code; |
| 260 | ResultVal<Handle> archive_handle = OpenArchive(id_code); | 260 | ResultVal<Handle> archive_handle = OpenArchive(id_code); |
| 261 | if (archive_handle.Succeeded()) { | 261 | if (archive_handle.Succeeded()) { |
| 262 | LOG_ERROR(Service_FS, "Cannot mount two archives with the same ID code! (%d)", (int) id_code); | 262 | LOG_ERROR(Service_FS, "Cannot mount two archives with the same ID code! (%d)", (int) id_code); |
| @@ -267,10 +267,10 @@ ResultCode MountArchive(Archive* archive) { | |||
| 267 | return RESULT_SUCCESS; | 267 | return RESULT_SUCCESS; |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | ResultCode CreateArchive(FileSys::Archive* backend, const std::string& name) { | 270 | ResultCode CreateArchive(FileSys::Archive* backend, ArchiveIdCode id_code) { |
| 271 | Archive* archive = new Archive; | 271 | Archive* archive = new Archive; |
| 272 | Handle handle = Kernel::g_object_pool.Create(archive); | 272 | Handle handle = Kernel::g_object_pool.Create(archive); |
| 273 | archive->name = name; | 273 | archive->id_code = id_code; |
| 274 | archive->backend = backend; | 274 | archive->backend = backend; |
| 275 | 275 | ||
| 276 | ResultCode result = MountArchive(archive); | 276 | ResultCode result = MountArchive(archive); |
| @@ -411,7 +411,7 @@ void ArchiveInit() { | |||
| 411 | std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX); | 411 | std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX); |
| 412 | auto archive = new FileSys::Archive_SDMC(sdmc_directory); | 412 | auto archive = new FileSys::Archive_SDMC(sdmc_directory); |
| 413 | if (archive->Initialize()) | 413 | if (archive->Initialize()) |
| 414 | CreateArchive(archive, "SDMC"); | 414 | CreateArchive(archive, ArchiveIdCode::SDMC); |
| 415 | else | 415 | else |
| 416 | LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); | 416 | LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str()); |
| 417 | } | 417 | } |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index a7ee212d3..9a1df5110 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -13,25 +13,36 @@ | |||
| 13 | namespace Service { | 13 | namespace Service { |
| 14 | namespace FS { | 14 | namespace FS { |
| 15 | 15 | ||
| 16 | /// Supported archive types | ||
| 17 | enum class ArchiveIdCode : u32 { | ||
| 18 | RomFS = 0x00000003, | ||
| 19 | SaveData = 0x00000004, | ||
| 20 | ExtSaveData = 0x00000006, | ||
| 21 | SharedExtSaveData = 0x00000007, | ||
| 22 | SystemSaveData = 0x00000008, | ||
| 23 | SDMC = 0x00000009, | ||
| 24 | SDMCWriteOnly = 0x0000000A, | ||
| 25 | }; | ||
| 26 | |||
| 16 | /** | 27 | /** |
| 17 | * Opens an archive | 28 | * Opens an archive |
| 18 | * @param id_code IdCode of the archive to open | 29 | * @param id_code IdCode of the archive to open |
| 19 | * @return Handle to the opened archive | 30 | * @return Handle to the opened archive |
| 20 | */ | 31 | */ |
| 21 | ResultVal<Handle> OpenArchive(FileSys::Archive::IdCode id_code); | 32 | ResultVal<Handle> OpenArchive(ArchiveIdCode id_code); |
| 22 | 33 | ||
| 23 | /** | 34 | /** |
| 24 | * Closes an archive | 35 | * Closes an archive |
| 25 | * @param id_code IdCode of the archive to open | 36 | * @param id_code IdCode of the archive to open |
| 26 | */ | 37 | */ |
| 27 | ResultCode CloseArchive(FileSys::Archive::IdCode id_code); | 38 | ResultCode CloseArchive(ArchiveIdCode id_code); |
| 28 | 39 | ||
| 29 | /** | 40 | /** |
| 30 | * Creates an Archive | 41 | * Creates an Archive |
| 31 | * @param backend File system backend interface to the archive | 42 | * @param backend File system backend interface to the archive |
| 32 | * @param name Name of Archive | 43 | * @param id_code Id code used to access this type of archive |
| 33 | */ | 44 | */ |
| 34 | ResultCode CreateArchive(FileSys::Archive* backend, const std::string& name); | 45 | ResultCode CreateArchive(FileSys::Archive* backend, ArchiveIdCode id_code); |
| 35 | 46 | ||
| 36 | /** | 47 | /** |
| 37 | * Open a File from an Archive | 48 | * Open a File from an Archive |
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 76689c6af..eda7cb8ab 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp | |||
| @@ -88,7 +88,7 @@ static void OpenFile(Service::Interface* self) { | |||
| 88 | static void OpenFileDirectly(Service::Interface* self) { | 88 | static void OpenFileDirectly(Service::Interface* self) { |
| 89 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 89 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 90 | 90 | ||
| 91 | auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[2]); | 91 | auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]); |
| 92 | auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[3]); | 92 | auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[3]); |
| 93 | u32 archivename_size = cmd_buff[4]; | 93 | u32 archivename_size = cmd_buff[4]; |
| 94 | auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]); | 94 | auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]); |
| @@ -334,7 +334,7 @@ static void OpenDirectory(Service::Interface* self) { | |||
| 334 | static void OpenArchive(Service::Interface* self) { | 334 | static void OpenArchive(Service::Interface* self) { |
| 335 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 335 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 336 | 336 | ||
| 337 | auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[1]); | 337 | auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]); |
| 338 | auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]); | 338 | auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]); |
| 339 | u32 archivename_size = cmd_buff[3]; | 339 | u32 archivename_size = cmd_buff[3]; |
| 340 | u32 archivename_ptr = cmd_buff[5]; | 340 | u32 archivename_ptr = cmd_buff[5]; |
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 6ce752561..49f8c458d 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp | |||
| @@ -74,7 +74,7 @@ ResultStatus LoadFile(const std::string& filename) { | |||
| 74 | 74 | ||
| 75 | // Load application and RomFS | 75 | // Load application and RomFS |
| 76 | if (ResultStatus::Success == app_loader.Load()) { | 76 | if (ResultStatus::Success == app_loader.Load()) { |
| 77 | Service::FS::CreateArchive(new FileSys::Archive_RomFS(app_loader), "RomFS"); | 77 | Service::FS::CreateArchive(new FileSys::Archive_RomFS(app_loader), Service::FS::ArchiveIdCode::RomFS); |
| 78 | return ResultStatus::Success; | 78 | return ResultStatus::Success; |
| 79 | } | 79 | } |
| 80 | break; | 80 | break; |