summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/fs/archive.cpp20
-rw-r--r--src/core/hle/service/fs/archive.h19
-rw-r--r--src/core/hle/service/fs/fs_user.cpp4
3 files changed, 27 insertions, 16 deletions
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 {
class Archive : public Kernel::Session {
public:
- std::string GetName() const override { return "Archive: " + name; }
+ std::string GetName() const override { return "Archive: " + backend->GetName(); }
- std::string name; ///< Name of archive (optional)
+ ArchiveIdCode id_code; ///< Id code of the archive
FileSys::Archive* backend; ///< Archive backend interface
ResultVal<bool> SyncRequest() override {
@@ -91,7 +91,7 @@ public:
case FileCommand::Close:
{
LOG_TRACE(Service_FS, "Close %s %s", GetTypeName().c_str(), GetName().c_str());
- CloseArchive(backend->GetIdCode());
+ CloseArchive(id_code);
break;
}
// Unknown command...
@@ -228,9 +228,9 @@ public:
////////////////////////////////////////////////////////////////////////////////////////////////////
-std::map<FileSys::Archive::IdCode, Handle> g_archive_map; ///< Map of file archives by IdCode
+std::map<ArchiveIdCode, Handle> g_archive_map; ///< Map of file archives by IdCode
-ResultVal<Handle> OpenArchive(FileSys::Archive::IdCode id_code) {
+ResultVal<Handle> OpenArchive(ArchiveIdCode id_code) {
auto itr = g_archive_map.find(id_code);
if (itr == g_archive_map.end()) {
return ResultCode(ErrorDescription::NotFound, ErrorModule::FS,
@@ -240,7 +240,7 @@ ResultVal<Handle> OpenArchive(FileSys::Archive::IdCode id_code) {
return MakeResult<Handle>(itr->second);
}
-ResultCode CloseArchive(FileSys::Archive::IdCode id_code) {
+ResultCode CloseArchive(ArchiveIdCode id_code) {
auto itr = g_archive_map.find(id_code);
if (itr == g_archive_map.end()) {
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) {
* @param archive Pointer to the archive to mount
*/
ResultCode MountArchive(Archive* archive) {
- FileSys::Archive::IdCode id_code = archive->backend->GetIdCode();
+ ArchiveIdCode id_code = archive->id_code;
ResultVal<Handle> archive_handle = OpenArchive(id_code);
if (archive_handle.Succeeded()) {
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) {
return RESULT_SUCCESS;
}
-ResultCode CreateArchive(FileSys::Archive* backend, const std::string& name) {
+ResultCode CreateArchive(FileSys::Archive* backend, ArchiveIdCode id_code) {
Archive* archive = new Archive;
Handle handle = Kernel::g_object_pool.Create(archive);
- archive->name = name;
+ archive->id_code = id_code;
archive->backend = backend;
ResultCode result = MountArchive(archive);
@@ -411,7 +411,7 @@ void ArchiveInit() {
std::string sdmc_directory = FileUtil::GetUserPath(D_SDMC_IDX);
auto archive = new FileSys::Archive_SDMC(sdmc_directory);
if (archive->Initialize())
- CreateArchive(archive, "SDMC");
+ CreateArchive(archive, ArchiveIdCode::SDMC);
else
LOG_ERROR(Service_FS, "Can't instantiate SDMC archive with path %s", sdmc_directory.c_str());
}
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 @@
namespace Service {
namespace FS {
+/// Supported archive types
+enum class ArchiveIdCode : u32 {
+ RomFS = 0x00000003,
+ SaveData = 0x00000004,
+ ExtSaveData = 0x00000006,
+ SharedExtSaveData = 0x00000007,
+ SystemSaveData = 0x00000008,
+ SDMC = 0x00000009,
+ SDMCWriteOnly = 0x0000000A,
+};
+
/**
* Opens an archive
* @param id_code IdCode of the archive to open
* @return Handle to the opened archive
*/
-ResultVal<Handle> OpenArchive(FileSys::Archive::IdCode id_code);
+ResultVal<Handle> OpenArchive(ArchiveIdCode id_code);
/**
* Closes an archive
* @param id_code IdCode of the archive to open
*/
-ResultCode CloseArchive(FileSys::Archive::IdCode id_code);
+ResultCode CloseArchive(ArchiveIdCode id_code);
/**
* Creates an Archive
* @param backend File system backend interface to the archive
- * @param name Name of Archive
+ * @param id_code Id code used to access this type of archive
*/
-ResultCode CreateArchive(FileSys::Archive* backend, const std::string& name);
+ResultCode CreateArchive(FileSys::Archive* backend, ArchiveIdCode id_code);
/**
* 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) {
static void OpenFileDirectly(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[2]);
+ auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[2]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[3]);
u32 archivename_size = cmd_buff[4];
auto filename_type = static_cast<FileSys::LowPathType>(cmd_buff[5]);
@@ -334,7 +334,7 @@ static void OpenDirectory(Service::Interface* self) {
static void OpenArchive(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
- auto archive_id = static_cast<FileSys::Archive::IdCode>(cmd_buff[1]);
+ auto archive_id = static_cast<FS::ArchiveIdCode>(cmd_buff[1]);
auto archivename_type = static_cast<FileSys::LowPathType>(cmd_buff[2]);
u32 archivename_size = cmd_buff[3];
u32 archivename_ptr = cmd_buff[5];