| 412 | } |
| 413 | |
| 414 | int extdataCreate(uint64_t titleId, u32 extdataId, int maxDirs, int maxFiles) override |
| 415 | { |
| 416 | // Never over an existing archive: FS would take the create as a |
| 417 | // wipe-and-remake, so a mistyped id would erase a save. |
| 418 | if (extdataExists(extdataId)) { |
| 419 | return -2; |
| 420 | } |
| 421 | |
| 422 | Title title; |
| 423 | const int idx = titleIndexOf(titleId); |
| 424 | if (idx < 0 || !catalogTitle(idx, title)) { |
| 425 | return -1; |
| 426 | } |
| 427 | |
| 428 | // The archive keeps the title's SMDH as its icon, which is what the |
| 429 | // console's data-management screen shows for it. A title whose SMDH |
| 430 | // will not load still gets its archive: FS reads a zero-length icon |
| 431 | // as "none". |
| 432 | smdh_s* smdh = loadSMDH((u32)titleId, (u32)(titleId >> 32), (u8)title.mediaType()); |
| 433 | if (smdh == NULL) { |
| 434 | Logging::warning("[script] extdata_create: no SMDH for title {:016X}, creating without an icon", (u64)titleId); |
| 435 | } |
| 436 | |
| 437 | const Result res = FSUSER_CreateExtSaveData( |
| 438 | sdExtdataInfo(extdataId), (u32)maxDirs, (u32)maxFiles, 0xFFFFFFFFFFFFFFFFULL, smdh ? sizeof(smdh_s) : 0, (u8*)smdh); |
| 439 | delete smdh; |
| 440 | |
| 441 | if (R_FAILED(res)) { |
| 442 | Logging::error("[script] extdata_create: title {:016X} id 0x{:08X} failed with result 0x{:08X}.", (u64)titleId, extdataId, res); |
| 443 | return (int)res; |
| 444 | } |
| 445 | Logging::info( |
| 446 | "[script] extdata_create: title {:016X} now has extdata 0x{:08X} ({} dirs, {} files).", (u64)titleId, extdataId, maxDirs, maxFiles); |
| 447 | return 0; |
| 448 | } |
| 449 | |
| 450 | int extdataDelete(u32 extdataId) override |
| 451 | { |
no test coverage detected