From 13efbdc2014177b84cae82e522b191e2f2f022df Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 31 Dec 2014 19:36:50 -0500 Subject: 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) --- src/core/file_sys/archive_romfs.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/core/file_sys/archive_romfs.cpp') 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 #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 Archive_RomFS::OpenFile(const Path& path, const Mode mode) const { return Common::make_unique(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(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 -- cgit v1.2.3 From aade417b143a756da10b69747793c707ef8316fd Mon Sep 17 00:00:00 2001 From: Subv Date: Thu, 1 Jan 2015 12:39:27 -0500 Subject: Archives: Reduced duplicate code in RomFS and SaveCheck. Fixed a few warnings and cleaned up the code --- src/core/file_sys/archive_romfs.cpp | 70 ------------------------------------- 1 file changed, 70 deletions(-) (limited to 'src/core/file_sys/archive_romfs.cpp') diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp index df07eb657..a30f73d0e 100644 --- a/src/core/file_sys/archive_romfs.cpp +++ b/src/core/file_sys/archive_romfs.cpp @@ -9,8 +9,6 @@ #include "common/make_unique.h" #include "core/file_sys/archive_romfs.h" -#include "core/file_sys/directory_romfs.h" -#include "core/file_sys/file_romfs.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // FileSys namespace @@ -24,72 +22,4 @@ Archive_RomFS::Archive_RomFS(const Loader::AppLoader& app_loader) { } } -Archive_RomFS::Archive_RomFS(std::string mountp) : mount_point(mountp) { - -} - -std::unique_ptr Archive_RomFS::OpenFile(const Path& path, const Mode mode) const { - return Common::make_unique(this); -} - -bool Archive_RomFS::DeleteFile(const Path& path) const { - LOG_WARNING(Service_FS, "Attempted to delete a file from ROMFS."); - return false; -} - -bool Archive_RomFS::RenameFile(const Path& src_path, const Path& dest_path) const { - LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS."); - return false; -} - -bool Archive_RomFS::DeleteDirectory(const Path& path) const { - LOG_WARNING(Service_FS, "Attempted to delete a directory from ROMFS."); - return false; -} - -ResultCode Archive_RomFS::CreateFile(const Path& path, u32 size) const { - LOG_WARNING(Service_FS, "Attempted to create a file in ROMFS."); - // TODO: Verify error code - return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported, ErrorLevel::Permanent); -} - -bool Archive_RomFS::CreateDirectory(const Path& path) const { - LOG_WARNING(Service_FS, "Attempted to create a directory in ROMFS."); - return false; -} - -bool Archive_RomFS::RenameDirectory(const Path& src_path, const Path& dest_path) const { - LOG_WARNING(Service_FS, "Attempted to rename a file within ROMFS."); - return false; -} - -std::unique_ptr Archive_RomFS::OpenDirectory(const Path& path) const { - return Common::make_unique(); -} - -ResultCode Archive_RomFS::Format(const Path& path) const { - LOG_WARNING(Service_FS, "Attempted to format ROMFS."); - 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(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 -- cgit v1.2.3