| 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 | { |
no test coverage detected