summaryrefslogtreecommitdiff
path: root/src/core/file_sys
diff options
context:
space:
mode:
authorGravatar Subv2014-12-31 19:36:50 -0500
committerGravatar Subv2015-01-02 21:13:53 -0500
commit13efbdc2014177b84cae82e522b191e2f2f022df (patch)
tree836870810adfc1e5a5ae574c59cb446ce7ae1880 /src/core/file_sys
parentMerge pull request #391 from lioncash/pedantic (diff)
downloadyuzu-13efbdc2014177b84cae82e522b191e2f2f022df.tar.gz
yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.tar.xz
yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.zip
SaveDataCheck: Preliminary work in this archive.
This allows Steel Diver to boot further, some files are needed. This is still not ready and needs a big cleanup, this will possibly be delayed until the way we handle archives is fixed (with factory classes instead of ahead-of-time creation of archives)
Diffstat (limited to 'src/core/file_sys')
-rw-r--r--src/core/file_sys/archive_romfs.cpp25
-rw-r--r--src/core/file_sys/archive_romfs.h7
2 files changed, 28 insertions, 4 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
27Archive_RomFS::Archive_RomFS(std::string mountp) : mount_point(mountp) {
28
29}
30
26std::unique_ptr<FileBackend> Archive_RomFS::OpenFile(const Path& path, const Mode mode) const { 31std::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
75ResultCode 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 {
20class Archive_RomFS final : public ArchiveBackend { 20class Archive_RomFS final : public ArchiveBackend {
21public: 21public:
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
92private: 91private:
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