diff options
author | bunnei <bunneidev@gmail.com> | 2015-01-03 03:50:57 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-01-03 03:50:57 +0100 |
commit | 031237e52cb1a32eb2a3ba37115170913e33e5dc (patch) | |
tree | 1d46509e07d20e2be2c25157b89b1061a7f75ba7 /src/core/file_sys/archive_savedatacheck.cpp | |
parent | Merge pull request #392 from lioncash/sm (diff) | |
parent | IVFCArchive: Use a critical log to notify of invalid operations. (diff) | |
download | yuzu-031237e52cb1a32eb2a3ba37115170913e33e5dc.tar yuzu-031237e52cb1a32eb2a3ba37115170913e33e5dc.tar.gz yuzu-031237e52cb1a32eb2a3ba37115170913e33e5dc.tar.bz2 yuzu-031237e52cb1a32eb2a3ba37115170913e33e5dc.tar.lz yuzu-031237e52cb1a32eb2a3ba37115170913e33e5dc.tar.xz yuzu-031237e52cb1a32eb2a3ba37115170913e33e5dc.tar.zst yuzu-031237e52cb1a32eb2a3ba37115170913e33e5dc.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/file_sys/archive_savedatacheck.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/core/file_sys/archive_savedatacheck.cpp b/src/core/file_sys/archive_savedatacheck.cpp new file mode 100644 index 000000000..233158a0c --- /dev/null +++ b/src/core/file_sys/archive_savedatacheck.cpp @@ -0,0 +1,41 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/file_util.h" + +#include "core/file_sys/archive_savedatacheck.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////// +// FileSys namespace + +namespace FileSys { + +Archive_SaveDataCheck::Archive_SaveDataCheck(const std::string& mount_loc) : mount_point(mount_loc) { +} + +ResultCode Archive_SaveDataCheck::Open(const Path& path) { + // TODO(Subv): We should not be overwriting raw_data everytime this function is called, + // but until we use factory classes to create the archives at runtime instead of creating them beforehand + // and allow multiple archives of the same type to be open at the same time without clobbering each other, + // we won't be able to maintain the state of each archive, hence we overwrite it every time it's needed. + // There are a number of problems with this, for example opening a file in this archive, then opening + // this archive again with a different path, will corrupt the previously open file. + 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 |