MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / savOpenSystem

Method savOpenSystem

3ds/source/script/scripthost.cpp:238–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236 }
237
238 int savOpenSystem(u32 saveId) override
239 {
240 const int slot = freeSlot();
241 if (slot < 0) {
242 return -2;
243 }
244
245 // {mediatype, savedata id}, the same 8-byte path FBI's system
246 // savedata browser opens one with. The id belongs to a system
247 // module, not to a title: 0x00010035 is the NEWS module's, whose
248 // news.db holds the notification list.
249 FS_Archive archive;
250 const u32 path[2] = {MEDIATYPE_NAND, saveId};
251 const Result res = FSUSER_OpenArchive(&archive, ARCHIVE_SYSTEM_SAVEDATA, {PATH_BINARY, 8, path});
252 if (R_FAILED(res)) {
253 return (int)res;
254 }
255
256 // Every open lands in the log: this is the one archive kind a
257 // script can reach that the console itself depends on, so a report
258 // of a console misbehaving after a script run says which id it was
259 // pointed at.
260 Logging::warning("[script] opened NAND system savedata 0x{:08X}", saveId);
261
262 // Journalled like a title's own save archive, so it commits; but no
263 // title owns it, so the secure-value epilogue has nothing to drop
264 // and uniqueId stays 0 (see savCommit).
265 mSlots[slot].arch = ArchiveHandle::fromFs(archive);
266 mSlots[slot].commitable = true;
267 mSlots[slot].uniqueId = 0;
268 return slot;
269 }
270
271 bool savValid(int handle) override { return handle >= 0 && handle < MAX_SAV_HANDLES && mSlots[handle].arch; }
272

Callers 1

ckpt_sav_open_systemFunction · 0.45

Calls 1

warningFunction · 0.85

Tested by

no test coverage detected