| 641 | static void iSG_upd_icostat(CARDStat*, CARDStat*); |
| 642 | static void iSG_timestamp(CARDStat*); |
| 643 | S32 iSGSaveFile(st_ISGSESSION* isgdata, const char* fname, char* data, S32 n, S32 async, char* arg5) |
| 644 | { |
| 645 | void* alloc; |
| 646 | S32 allocsize; |
| 647 | char* icondata; |
| 648 | S32 iconsize; |
| 649 | |
| 650 | S32 writeret = 0; |
| 651 | en_ASYNC_OPERR operr = ISG_OPERR_NONE; |
| 652 | CARDStat statA = { 0 }; |
| 653 | CARDStat statB = { 0 }; |
| 654 | |
| 655 | ResetButton::DisableReset(); |
| 656 | if (isgdata->slot < 0) |
| 657 | { |
| 658 | isgdata->unk_26c = ISG_OPSTAT_FAILURE; |
| 659 | isgdata->unk_268 = ISG_OPERR_NOCARD; |
| 660 | return 0; |
| 661 | } |
| 662 | |
| 663 | st_ISG_MEMCARD_DATA* mcdata = &isgdata->mcdata[isgdata->slot]; |
| 664 | if (mcdata->unk_12c != 0) |
| 665 | { |
| 666 | isgdata->unk_26c = ISG_OPSTAT_FAILURE; |
| 667 | isgdata->unk_268 = ISG_OPERR_DAMAGE; |
| 668 | return 0; |
| 669 | } |
| 670 | |
| 671 | iTRCDisk::CheckDVDAndResetState(); |
| 672 | iconsize = iSG_cubeicon_size(isgdata->slot, mcdata->sectorSize); |
| 673 | S32 sectorsize200 = ALIGN_THING(mcdata->sectorSize, 0x200); |
| 674 | iconsize += ALIGN_THING(sectorsize200, n); |
| 675 | |
| 676 | allocsize = iconsize + 0x1f; |
| 677 | alloc = xMemPushTemp(allocsize); |
| 678 | memset(alloc, 0, allocsize); |
| 679 | icondata = (char*)((U32)alloc + 0x1f & 0xFFFFFFE0); |
| 680 | |
| 681 | memcpy(iSG_bfr_icondata(icondata, &statA, arg5, mcdata->sectorSize), data, n); |
| 682 | iTRCDisk::CheckDVDAndResetState(); |
| 683 | |
| 684 | if (iSG_mc_fopen(mcdata, fname, iconsize, ISG_IOMODE_WRITE, &operr) != 0) |
| 685 | { |
| 686 | if (iSG_mc_fwrite(mcdata, icondata, iconsize) != 0) |
| 687 | { |
| 688 | writeret = 1; |
| 689 | } |
| 690 | else |
| 691 | { |
| 692 | writeret = 0; |
| 693 | operr = ISG_OPERR_SVWRITE; |
| 694 | } |
| 695 | |
| 696 | if (writeret != 0) |
| 697 | { |
| 698 | iSG_upd_icostat(&statA, &mcdata->fstat); |
| 699 | iSG_timestamp(&mcdata->fstat); |
| 700 | s32 result; |
no test coverage detected