diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 25 | ||||
| -rw-r--r-- | src/core/file_sys/archive_romfs.h | 7 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.cpp | 37 | ||||
| -rw-r--r-- | src/core/hle/service/fs/archive.h | 1 |
4 files changed, 63 insertions, 7 deletions
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index 2fc3831b7..df07eb657 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <memory> | 5 | #include <memory> |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "common/file_util.h" | ||
| 8 | #include "common/make_unique.h" | 9 | #include "common/make_unique.h" |
| 9 | 10 | ||
| 10 | #include "core/file_sys/archive_romfs.h" | 11 | #include "core/file_sys/archive_romfs.h" |
| @@ -23,6 +24,10 @@ Archive_RomFS::Archive_RomFS(const Loader::AppLoader& app_loader) { | |||
| 23 | } | 24 | } |
| 24 | } | 25 | } |
| 25 | 26 | ||
| 27 | Archive_RomFS::Archive_RomFS(std::string mountp) : mount_point(mountp) { | ||
| 28 | |||
| 29 | } | ||
| 30 | |||
| 26 | std::unique_ptr<FileBackend> Archive_RomFS::OpenFile(const Path& path, const Mode mode) const { | 31 | std::unique_ptr<FileBackend> Archive_RomFS::OpenFile(const Path& path, const Mode mode) const { |
| 27 | return Common::make_unique<File_RomFS>(this); | 32 | return Common::make_unique<File_RomFS>(this); |
| 28 | } | 33 | } |
| @@ -67,4 +72,24 @@ ResultCode Archive_RomFS::Format(const Path& path) const { | |||
| 67 | return UnimplementedFunction(ErrorModule::FS); | 72 | return UnimplementedFunction(ErrorModule::FS); |
| 68 | } | 73 | } |
| 69 | 74 | ||
| 75 | ResultCode Archive_RomFS::Open(const Path& path) { | ||
| 76 | if (mount_point.empty()) | ||
| 77 | return RESULT_SUCCESS; | ||
| 78 | auto vec = path.AsBinary(); | ||
| 79 | const u32* data = reinterpret_cast<u32*>(vec.data()); | ||
| 80 | std::string file_path = Common::StringFromFormat("%s%08X%08X.bin", mount_point.c_str(), data[1], data[0]); | ||
| 81 | FileUtil::IOFile file(file_path, "rb"); | ||
| 82 | |||
| 83 | std::fill(raw_data.begin(), raw_data.end(), 0); | ||
| 84 | |||
| 85 | if (!file.IsOpen()) { | ||
| 86 | return ResultCode(-1); // TODO(Subv): Find the right error code | ||
| 87 | } | ||
| 88 | auto size = file.GetSize(); | ||
| 89 | raw_data.resize(size); | ||
| 90 | file.ReadBytes(raw_data.data(), size); | ||
| 91 | file.Close(); | ||
| 92 | return RESULT_SUCCESS; | ||
| 93 | } | ||
| 94 | |||
| 70 | } // namespace FileSys | 95 | } // namespace FileSys |
diff --git a/src/core/file_sys/archive_romfs.h b/src/core/file_sys/archive_romfs.h index d4b1eb7f2..b657dd38b 100644 --- a/src/core/file_sys/archive_romfs.h +++ b/src/core/file_sys/archive_romfs.h | |||
| @@ -20,6 +20,7 @@ namespace FileSys { | |||
| 20 | class Archive_RomFS final : public ArchiveBackend { | 20 | class Archive_RomFS final : public ArchiveBackend { |
| 21 | public: | 21 | public: |
| 22 | Archive_RomFS(const Loader::AppLoader& app_loader); | 22 | Archive_RomFS(const Loader::AppLoader& app_loader); |
| 23 | Archive_RomFS(std::string mount_point); | ||
| 23 | 24 | ||
| 24 | std::string GetName() const override { return "RomFS"; } | 25 | std::string GetName() const override { return "RomFS"; } |
| 25 | 26 | ||
| @@ -83,15 +84,13 @@ public: | |||
| 83 | */ | 84 | */ |
| 84 | std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; | 85 | std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; |
| 85 | 86 | ||
| 86 | ResultCode Open(const Path& path) override { | 87 | ResultCode Open(const Path& path) override; |
| 87 | return RESULT_SUCCESS; | ||
| 88 | } | ||
| 89 | 88 | ||
| 90 | ResultCode Format(const Path& path) const override; | 89 | ResultCode Format(const Path& path) const override; |
| 91 | 90 | ||
| 92 | private: | 91 | private: |
| 93 | friend class File_RomFS; | 92 | friend class File_RomFS; |
| 94 | 93 | std::string mount_point; | |
| 95 | std::vector<u8> raw_data; | 94 | std::vector<u8> raw_data; |
| 96 | }; | 95 | }; |
| 97 | 96 | ||
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index 9a91bcb8b..a8383d4e5 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp | |||
| @@ -10,9 +10,10 @@ | |||
| 10 | #include "common/make_unique.h" | 10 | #include "common/make_unique.h" |
| 11 | #include "common/math_util.h" | 11 | #include "common/math_util.h" |
| 12 | 12 | ||
| 13 | #include "core/file_sys/archive_savedata.h" | ||
| 14 | #include "core/file_sys/archive_extsavedata.h" | ||
| 15 | #include "core/file_sys/archive_backend.h" | 13 | #include "core/file_sys/archive_backend.h" |
| 14 | #include "core/file_sys/archive_extsavedata.h" | ||
| 15 | #include "core/file_sys/archive_romfs.h" | ||
| 16 | #include "core/file_sys/archive_savedata.h" | ||
| 16 | #include "core/file_sys/archive_sdmc.h" | 17 | #include "core/file_sys/archive_sdmc.h" |
| 17 | #include "core/file_sys/directory_backend.h" | 18 | #include "core/file_sys/directory_backend.h" |
| 18 | #include "core/hle/service/fs/archive.h" | 19 | #include "core/hle/service/fs/archive.h" |
| @@ -50,6 +51,9 @@ enum class FileCommand : u32 { | |||
| 50 | SetAttributes = 0x08070040, | 51 | SetAttributes = 0x08070040, |
| 51 | Close = 0x08080000, | 52 | Close = 0x08080000, |
| 52 | Flush = 0x08090000, | 53 | Flush = 0x08090000, |
| 54 | SetPriority = 0x080A0040, | ||
| 55 | GetPriority = 0x080B0000, | ||
| 56 | OpenLinkFile = 0x080C0000, | ||
| 53 | }; | 57 | }; |
| 54 | 58 | ||
| 55 | // Command to access directory | 59 | // Command to access directory |
| @@ -75,12 +79,13 @@ public: | |||
| 75 | class File : public Kernel::Session { | 79 | class File : public Kernel::Session { |
| 76 | public: | 80 | public: |
| 77 | File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path) | 81 | File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path) |
| 78 | : path(path), backend(std::move(backend)) { | 82 | : path(path), backend(std::move(backend)), priority(0) { |
| 79 | } | 83 | } |
| 80 | 84 | ||
| 81 | std::string GetName() const override { return "Path: " + path.DebugStr(); } | 85 | std::string GetName() const override { return "Path: " + path.DebugStr(); } |
| 82 | 86 | ||
| 83 | FileSys::Path path; ///< Path of the file | 87 | FileSys::Path path; ///< Path of the file |
| 88 | u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means | ||
| 84 | std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface | 89 | std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface |
| 85 | 90 | ||
| 86 | ResultVal<bool> SyncRequest() override { | 91 | ResultVal<bool> SyncRequest() override { |
| @@ -145,6 +150,27 @@ public: | |||
| 145 | break; | 150 | break; |
| 146 | } | 151 | } |
| 147 | 152 | ||
| 153 | case FileCommand::OpenLinkFile: | ||
| 154 | { | ||
| 155 | LOG_WARNING(Service_FS, "(STUBBED) File command OpenLinkFile %s", GetName().c_str()); | ||
| 156 | cmd_buff[3] = GetHandle(); | ||
| 157 | break; | ||
| 158 | } | ||
| 159 | |||
| 160 | case FileCommand::SetPriority: | ||
| 161 | { | ||
| 162 | priority = cmd_buff[1]; | ||
| 163 | LOG_TRACE(Service_FS, "SetPriority %u", priority); | ||
| 164 | break; | ||
| 165 | } | ||
| 166 | |||
| 167 | case FileCommand::GetPriority: | ||
| 168 | { | ||
| 169 | cmd_buff[2] = priority; | ||
| 170 | LOG_TRACE(Service_FS, "GetPriority"); | ||
| 171 | break; | ||
| 172 | } | ||
| 173 | |||
| 148 | // Unknown command... | 174 | // Unknown command... |
| 149 | default: | 175 | default: |
| 150 | LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd); | 176 | LOG_ERROR(Service_FS, "Unknown command=0x%08X!", cmd); |
| @@ -435,6 +461,11 @@ void ArchiveInit() { | |||
| 435 | else | 461 | else |
| 436 | LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s", | 462 | LOG_ERROR(Service_FS, "Can't instantiate SharedExtSaveData archive with path %s", |
| 437 | sharedextsavedata_directory.c_str()); | 463 | sharedextsavedata_directory.c_str()); |
| 464 | |||
| 465 | // Create the SaveDataCheck archive, basically a small variation of the RomFS archive | ||
| 466 | std::string savedatacheck_directory = FileUtil::GetUserPath(D_SAVEDATA_IDX) + "../savedatacheck/"; | ||
| 467 | auto savedatacheck_archive = Common::make_unique<FileSys::Archive_RomFS>(savedatacheck_directory); | ||
| 468 | CreateArchive(std::move(savedatacheck_archive), ArchiveIdCode::SaveDataCheck); | ||
| 438 | } | 469 | } |
| 439 | 470 | ||
| 440 | /// Shutdown archives | 471 | /// Shutdown archives |
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index c23b8cc46..f2e4e4a53 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h | |||
| @@ -22,6 +22,7 @@ enum class ArchiveIdCode : u32 { | |||
| 22 | SystemSaveData = 0x00000008, | 22 | SystemSaveData = 0x00000008, |
| 23 | SDMC = 0x00000009, | 23 | SDMC = 0x00000009, |
| 24 | SDMCWriteOnly = 0x0000000A, | 24 | SDMCWriteOnly = 0x0000000A, |
| 25 | SaveDataCheck = 0x2345678A, | ||
| 25 | }; | 26 | }; |
| 26 | 27 | ||
| 27 | typedef u64 ArchiveHandle; | 28 | typedef u64 ArchiveHandle; |