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

Method savOpen

3ds/source/script/scripthost.cpp:156–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154 }
155
156 int savOpen(int titleIdx, int kind) override
157 {
158 Title title;
159 if (!catalogTitle(titleIdx, title)) {
160 return -1;
161 }
162 const int slot = freeSlot();
163 if (slot < 0) {
164 return -2;
165 }
166
167 // Only regular CTR saves and extdata are file-level archives; GBA VC
168 // (FSPXI raw), DSiWare (TWL FAT) and SPI cart saves are not reachable here.
169 if (kind == 0) {
170 const bool spiCart = title.mediaType() == MEDIATYPE_GAME_CARD && title.cardType() != CARD_CTR;
171 if (!title.accessibleSave() || title.isGBAVC() || title.isDSiWare() || spiCart) {
172 return -1;
173 }
174 }
175 else if (!title.accessibleExtdata()) {
176 return -1;
177 }
178
179 Result res = 0;
180 ArchiveHandle handle = title.backup(kind == 0 ? BackupKind::Save : BackupKind::Extdata).open(res);
181 if (!handle) {
182 return R_FAILED(res) ? (int)res : -1;
183 }
184
185 mSlots[slot].arch = std::move(handle);
186 mSlots[slot].commitable = kind == 0;
187 mSlots[slot].uniqueId = title.uniqueId();
188 return slot;
189 }
190
191 int savOpenShared(uint64_t id) override
192 {

Callers 1

ckpt_sav_openFunction · 0.45

Calls 9

mediaTypeMethod · 0.80
cardTypeMethod · 0.80
accessibleSaveMethod · 0.80
isGBAVCMethod · 0.80
isDSiWareMethod · 0.80
accessibleExtdataMethod · 0.80
uniqueIdMethod · 0.80
openMethod · 0.45
backupMethod · 0.45

Tested by

no test coverage detected