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

Method savOpen

3ds/source/script/scripthost.cpp:103–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 }
102
103 int savOpen(int titleIdx, int kind) override
104 {
105 if (titleIdx < 0 || titleIdx >= titleCount()) {
106 return -1;
107 }
108 const int slot = freeSlot();
109 if (slot < 0) {
110 return -2;
111 }
112
113 Title title;
114 TitleCatalog::get().getTitle(title, titleIdx, BackupKind::Save);
115
116 // Only regular CTR saves and extdata are file-level archives; GBA VC
117 // (FSPXI raw), DSiWare (TWL FAT) and SPI cart saves are not reachable here.
118 if (kind == 0) {
119 const bool spiCart = title.mediaType() == MEDIATYPE_GAME_CARD && title.cardType() != CARD_CTR;
120 if (!title.accessibleSave() || title.isGBAVC() || title.isDSiWare() || spiCart) {
121 return -1;
122 }
123 }
124 else if (!title.accessibleExtdata()) {
125 return -1;
126 }
127
128 Result res = 0;
129 ArchiveHandle handle = title.backup(kind == 0 ? BackupKind::Save : BackupKind::Extdata).open(res);
130 if (!handle) {
131 return R_FAILED(res) ? (int)res : -1;
132 }
133
134 mSlots[slot].arch = std::move(handle);
135 mSlots[slot].commitable = kind == 0;
136 mSlots[slot].uniqueId = title.uniqueId();
137 return slot;
138 }
139
140 int savOpenShared(uint64_t id) override
141 {

Callers 1

ckpt_sav_openFunction · 0.45

Calls 11

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

Tested by

no test coverage detected