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

Method extdataCreate

3ds/source/script/scripthost.cpp:379–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377 }
378
379 int extdataCreate(uint64_t titleId, u32 extdataId, int maxDirs, int maxFiles) override
380 {
381 // Never over an existing archive: FS would take the create as a
382 // wipe-and-remake, so a mistyped id would erase a save.
383 if (extdataExists(extdataId)) {
384 return -2;
385 }
386
387 Title title;
388 const int idx = titleIndexOf(titleId);
389 if (idx < 0 || !catalogTitle(idx, title)) {
390 return -1;
391 }
392
393 // The archive keeps the title's SMDH as its icon, which is what the
394 // console's data-management screen shows for it. A title whose SMDH
395 // will not load still gets its archive: FS reads a zero-length icon
396 // as "none".
397 smdh_s* smdh = loadSMDH((u32)titleId, (u32)(titleId >> 32), (u8)title.mediaType());
398 if (smdh == NULL) {
399 Logging::warning("[script] extdata_create: no SMDH for title {:016X}, creating without an icon", (u64)titleId);
400 }
401
402 const Result res = FSUSER_CreateExtSaveData(
403 sdExtdataInfo(extdataId), (u32)maxDirs, (u32)maxFiles, 0xFFFFFFFFFFFFFFFFULL, smdh ? sizeof(smdh_s) : 0, (u8*)smdh);
404 delete smdh;
405
406 if (R_FAILED(res)) {
407 Logging::error("[script] extdata_create: title {:016X} id 0x{:08X} failed with result 0x{:08X}.", (u64)titleId, extdataId, res);
408 return (int)res;
409 }
410 Logging::info(
411 "[script] extdata_create: title {:016X} now has extdata 0x{:08X} ({} dirs, {} files).", (u64)titleId, extdataId, maxDirs, maxFiles);
412 return 0;
413 }
414
415 int extdataDelete(u32 extdataId) override
416 {

Callers 1

ckpt_extdata_createFunction · 0.45

Calls 7

extdataExistsFunction · 0.85
loadSMDHFunction · 0.85
warningFunction · 0.85
sdExtdataInfoFunction · 0.85
mediaTypeMethod · 0.80
errorFunction · 0.50
infoFunction · 0.50

Tested by

no test coverage detected