summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/ptm_u.cpp34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/core/hle/service/ptm_u.cpp b/src/core/hle/service/ptm_u.cpp
index 561849f32..7c8d9ce8c 100644
--- a/src/core/hle/service/ptm_u.cpp
+++ b/src/core/hle/service/ptm_u.cpp
@@ -139,37 +139,29 @@ const Interface::FunctionInfo FunctionTable[] = {
139Interface::Interface() { 139Interface::Interface() {
140 Register(FunctionTable); 140 Register(FunctionTable);
141 141
142 // TODO(Subv): This code needs to be updated to not directly create archives and use the 142 // Open the SharedExtSaveData archive 0xF000000B and the gamecoin.dat file
143 // standard archive.h interfaces.
144#if 0
145 // Create the SharedExtSaveData archive 0xF000000B and the gamecoin.dat file
146 // TODO(Subv): In the future we should use the FS service to query this archive
147 std::string nand_directory = FileUtil::GetUserPath(D_NAND_IDX);
148 ptm_shared_extsavedata = Common::make_unique<FileSys::Archive_ExtSaveData>(nand_directory, true);
149 if (!ptm_shared_extsavedata->Initialize()) {
150 LOG_CRITICAL(Service_PTM, "Could not initialize SharedExtSaveData archive for the PTM:U service");
151 return;
152 }
153 FileSys::Path archive_path(ptm_shared_extdata_id); 143 FileSys::Path archive_path(ptm_shared_extdata_id);
154 ResultCode result = ptm_shared_extsavedata->Open(archive_path); 144 auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
155 // If the archive didn't exist, create the files inside 145 // If the archive didn't exist, create the files inside
156 if (result.description == ErrorDescription::FS_NotFormatted) { 146 if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
157 // Format the archive to clear the directories 147 // Format the archive to create the directories
158 ptm_shared_extsavedata->Format(archive_path); 148 Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
159 // Open it again to get a valid archive now that the folder exists 149 // Open it again to get a valid archive now that the folder exists
160 ptm_shared_extsavedata->Open(archive_path); 150 archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
151 _assert_msg_(Service_PTM, archive_result.Succeeded(), "Could not open the PTM SharedExtSaveData archive!");
152
161 FileSys::Path gamecoin_path("gamecoin.dat"); 153 FileSys::Path gamecoin_path("gamecoin.dat");
162 FileSys::Mode open_mode = {}; 154 FileSys::Mode open_mode = {};
163 open_mode.write_flag = 1; 155 open_mode.write_flag = 1;
164 open_mode.create_flag = 1; 156 open_mode.create_flag = 1;
165 // Open the file and write the default gamecoin information 157 // Open the file and write the default gamecoin information
166 auto gamecoin = ptm_shared_extsavedata->OpenFile(gamecoin_path, open_mode); 158 auto gamecoin_result = Service::FS::OpenFileFromArchive(*archive_result, gamecoin_path, open_mode);
167 if (gamecoin != nullptr) { 159 if (gamecoin_result.Succeeded()) {
168 gamecoin->Write(0, sizeof(GameCoin), 1, reinterpret_cast<const u8*>(&default_game_coin)); 160 auto gamecoin = gamecoin_result.MoveFrom();
169 gamecoin->Close(); 161 gamecoin->backend->Write(0, sizeof(GameCoin), 1, reinterpret_cast<const u8*>(&default_game_coin));
162 gamecoin->backend->Close();
170 } 163 }
171 } 164 }
172#endif
173} 165}
174 166
175} // namespace 167} // namespace