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

Function extractCurrentSave

3ds/source/gbasave.cpp:151–163  ·  view source on GitHub ↗

Pulls the current slot's bare save out of the AGBSAVE container behind `file` into a fresh buffer. Used both on the PXI file (backup) and on a legacy full-container SD dump (restore of a pre-format-change backup).

Source from the content-addressed store, hash-verified

149 // `file` into a fresh buffer. Used both on the PXI file (backup) and on a
150 // legacy full-container SD dump (restore of a pre-format-change backup).
151 Result extractCurrentSave(FSStream& file, AgbSaveHeader& hdr, std::unique_ptr<u8[]>& save)
152 {
153 u32 slotOffset = 0;
154 if (!locateCurrentSlot(file, hdr, slotOffset)) {
155 return GbaSave::resNoSave;
156 }
157 save = std::make_unique<u8[]>(hdr.saveSize);
158 file.offset(slotOffset + kHeaderSize);
159 if (file.read(save.get(), hdr.saveSize) != hdr.saveSize || R_FAILED(file.result())) {
160 return R_FAILED(file.result()) ? file.result() : GbaSave::resBadBackup;
161 }
162 return 0;
163 }
164}
165
166Result GbaSave::backup(FSPXI_Archive arch, FS_Archive sdmc, const std::u16string& dstPath, ProgressSink& sink)

Callers 2

backupMethod · 0.85
restoreMethod · 0.85

Calls 5

locateCurrentSlotFunction · 0.85
resultMethod · 0.80
offsetMethod · 0.45
readMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected