summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/archive_extsavedata.cpp
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2015-12-28 19:51:44 +0100
committerSubv <subv2112@gmail.com>2016-03-20 20:30:01 +0100
commitd26c6b3212ed36970410814593ee5ec082b1d95a (patch)
tree3b03822761cbec083ea57719b0c8a9df530c4899 /src/core/file_sys/archive_extsavedata.cpp
parentHLE/FS: Don't return an error when deleting the ExtSaveData if it does not exist. (diff)
downloadyuzu-d26c6b3212ed36970410814593ee5ec082b1d95a.tar
yuzu-d26c6b3212ed36970410814593ee5ec082b1d95a.tar.gz
yuzu-d26c6b3212ed36970410814593ee5ec082b1d95a.tar.bz2
yuzu-d26c6b3212ed36970410814593ee5ec082b1d95a.tar.lz
yuzu-d26c6b3212ed36970410814593ee5ec082b1d95a.tar.xz
yuzu-d26c6b3212ed36970410814593ee5ec082b1d95a.tar.zst
yuzu-d26c6b3212ed36970410814593ee5ec082b1d95a.zip
Diffstat (limited to '')
-rw-r--r--src/core/file_sys/archive_extsavedata.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp
index 92dad8e6f..e83a6153d 100644
--- a/src/core/file_sys/archive_extsavedata.cpp
+++ b/src/core/file_sys/archive_extsavedata.cpp
@@ -82,13 +82,45 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_ExtSaveData::Open(cons
return MakeResult<std::unique_ptr<ArchiveBackend>>(std::move(archive));
}
-ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path) {
+ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info) {
// These folders are always created with the ExtSaveData
std::string user_path = GetExtSaveDataPath(mount_point, path) + "user/";
std::string boss_path = GetExtSaveDataPath(mount_point, path) + "boss/";
FileUtil::CreateFullPath(user_path);
FileUtil::CreateFullPath(boss_path);
- return RESULT_SUCCESS;
+
+ // Write the format metadata
+ std::string metadata_path = GetExtSaveDataPath(mount_point, path) + "metadata";
+ FileUtil::IOFile file(metadata_path, "wb");
+
+ if (file.IsOpen()) {
+ file.WriteBytes(&format_info, sizeof(format_info));
+ return RESULT_SUCCESS;
+ }
+
+ // TODO(Subv): Find the correct error code
+ return ResultCode(-1);
+}
+
+ResultVal<ArchiveFormatInfo> ArchiveFactory_ExtSaveData::GetFormatInfo(const Path& path) const {
+ std::string metadata_path = GetExtSaveDataPath(mount_point, path) + "metadata";
+ FileUtil::IOFile file(metadata_path, "rb");
+
+ if (file.IsOpen()) {
+ ArchiveFormatInfo info;
+ file.ReadBytes(&info, sizeof(info));
+ return MakeResult<ArchiveFormatInfo>(info);
+ }
+
+ LOG_ERROR(Service_FS, "Could not open metadata information for archive");
+ // TODO(Subv): Verify error code
+ return ResultCode(ErrorDescription::FS_NotFormatted, ErrorModule::FS, ErrorSummary::InvalidState, ErrorLevel::Status);
+}
+
+void ArchiveFactory_ExtSaveData::WriteIcon(const Path& path, u8* icon_data, u32 icon_size) {
+ std::string game_path = FileSys::GetExtSaveDataPath(GetMountPoint(), path);
+ FileUtil::IOFile icon_file(game_path + "icon", "wb+");
+ icon_file.WriteBytes(icon_data, icon_size);
}
} // namespace FileSys