diff options
author | Subv <subv2112@gmail.com> | 2015-01-01 01:36:50 +0100 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2015-01-03 03:13:53 +0100 |
commit | 13efbdc2014177b84cae82e522b191e2f2f022df (patch) | |
tree | 836870810adfc1e5a5ae574c59cb446ce7ae1880 /src/core/file_sys | |
parent | Merge pull request #391 from lioncash/pedantic (diff) | |
download | yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.tar yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.tar.gz yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.tar.bz2 yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.tar.lz yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.tar.xz yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.tar.zst yuzu-13efbdc2014177b84cae82e522b191e2f2f022df.zip |
Diffstat (limited to 'src/core/file_sys')
-rw-r--r-- | src/core/file_sys/archive_romfs.cpp | 25 | ||||
-rw-r--r-- | src/core/file_sys/archive_romfs.h | 7 |
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 @@ #include <memory> #include "common/common_types.h" +#include "common/file_util.h" #include "common/make_unique.h" #include "core/file_sys/archive_romfs.h" @@ -23,6 +24,10 @@ Archive_RomFS::Archive_RomFS(const Loader::AppLoader& app_loader) { } } +Archive_RomFS::Archive_RomFS(std::string mountp) : mount_point(mountp) { + +} + std::unique_ptr<FileBackend> Archive_RomFS::OpenFile(const Path& path, const Mode mode) const { return Common::make_unique<File_RomFS>(this); } @@ -67,4 +72,24 @@ ResultCode Archive_RomFS::Format(const Path& path) const { return UnimplementedFunction(ErrorModule::FS); } +ResultCode Archive_RomFS::Open(const Path& path) { + if (mount_point.empty()) + return RESULT_SUCCESS; + auto vec = path.AsBinary(); + const u32* data = reinterpret_cast<u32*>(vec.data()); + std::string file_path = Common::StringFromFormat("%s%08X%08X.bin", mount_point.c_str(), data[1], data[0]); + FileUtil::IOFile file(file_path, "rb"); + + std::fill(raw_data.begin(), raw_data.end(), 0); + + if (!file.IsOpen()) { + return ResultCode(-1); // TODO(Subv): Find the right error code + } + auto size = file.GetSize(); + raw_data.resize(size); + file.ReadBytes(raw_data.data(), size); + file.Close(); + return RESULT_SUCCESS; +} + } // 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 { class Archive_RomFS final : public ArchiveBackend { public: Archive_RomFS(const Loader::AppLoader& app_loader); + Archive_RomFS(std::string mount_point); std::string GetName() const override { return "RomFS"; } @@ -83,15 +84,13 @@ public: */ std::unique_ptr<DirectoryBackend> OpenDirectory(const Path& path) const override; - ResultCode Open(const Path& path) override { - return RESULT_SUCCESS; - } + ResultCode Open(const Path& path) override; ResultCode Format(const Path& path) const override; private: friend class File_RomFS; - + std::string mount_point; std::vector<u8> raw_data; }; |