diff --git a/README.md b/README.md index 352fe0c..64774a4 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,16 @@ For sorting Titles press R to change sorting method and press L to change betwee Use it at your own risk and please report any issues that may occur. ## Quick Notes + +Move across screen by using Up/Down D-Pad buttons. Cycle between options by using Left/Right D-Pad buttons. "A" to select a task / enter a menu. "B" to go back to the previous menu. Special functions can be accessed by using "X/Y/+/-" buttons, as described at the bottom line in each menu. + ### Wii U Title Management / vWii Title Management Allows you to backup/restore/wipe individual titles. 1. First select the title you want to manage. - 1. Wii U titles: If the title has not been initialized (you have not created an initial save by playing it beforehand) it will be marked as "Not init" and will appear in yellow. You can try to manage it (restore task), but the outcome is uncertain. It is recommended to first play to the game before trying to restore its savedata. - 1. An special case of this are vWii injects. They have a vWii title and an associated Wii U title with no savedata that will appear in Wii U title Management marked with "Not init". Savedata for these titles can be managed from the vWii Management tasks, and will appear ther after you create an initital save by playing it. Savemii allows yo to manage the Wii U title portion, but as stated, the real savedata should be managed from the "vWii Title managament" tasks. + 1. Wii U titles: If the title has not been initialized (you have not created an initial save by playing to it beforehand) it will be marked as "Not init" and will appear in yellow. You can try to manage it (restore from a previous backup), but the outcome is uncertain. It is recommended to first play and create "real" savedata before trying to restore any backup. + 1. An special case of this are vWii injects. They have both a Wii U title with no savedata that will appear in "Wii U Title Management" marked as "Not init", and a vWii title where the game's savedata is that will appear in vWii Title Management after you play it and create an initial game savedata. Savedata for these titles must be managed from the vWii Management tasks. Just in case, Savemii allows yo to manage the Wii U title portion, but it usually doesn't contain any savedata. 2. Select the task you want to do: 1. Backup: Copy savedata from USB/NAND to SD 2. Restore: Copy savedata from SD to USB/NAND @@ -27,51 +30,58 @@ Allows you to backup/restore/wipe individual titles. 5. Copy to other Device: If savedata for a title is present in USB and NAND, copy it from one storage to the other #### Backup -1. Select a slot to save the savedata. You can select a number from 0 to 255, each one representing a different folder in the SD card. After the backup is done, you can tag the slot with a meaningful name using the Option X -2. For Wii U titles, select which data to save - 1. All users: Recommended option Will backup all game data - 2. From user: xxxxx. Will only backup the data for the specified profile. In this case, must also specify if you want to save "common" data or not. "Common" savedata is data shared by all profiles +1. Select a slot to store the savedata. You can select any number from 0 to 255, each one representing a different folder in the SD card. +2. For Wii U titles, select which data to save: + 1. All users: Recommended option. Will backup all game data. + 2. From user: xxxxx. Will only backup the data for the specified user/profile. In this case, must also specify if you want to save "common" data or not. "Common" savedata is data shared by all profiles. Titles can have common save data, profile savedata or both. +3. Press "A" to initiate the backup. After the backup is done, you can tag the slot with a meaningful name pressing "+" button in this menu. If the slot is unneeded, you can delete it by pressing "-" button. +Wii U titles savedata layout: ``` -sd:/wiiu/backup/ - xxxxxxxx-yyyyyyy/ +sd:/wiiu/backups/ + xxxxxxxxyyyyyyyy/ # Title Id 0/ - saveMii.json - 80000001/ - ... + saveMiiMeta.json + 80000001/ # one folder for each profile + ... # savedata 80000002/ ... - ... one folder for each profile + ... common/ ... - 1/ + 1/ # one filder for each slot ... ``` +For vWii titles, savedata is directly under the slot folder. + #### Restore -1. Select a slot to get the data from. By default, data from the "root" backup set (the one where the manual backups are stored) is used. But you can also use slots from batch restore backup sets, by using option X and selecting the one you want to use. BackupSets can also be tagged by using option X in the backupSet list Menu. - To identify which data the slot contains: If the slot has been tagged, you will see its tag next to the slot number. On the top line, you can see which backupSet are you using. And at the last line, you can see when the savedata were taken, and from which console. +1. Select a slot to get the data from. By default, data from the "root" backup set (the one where the manual backups are stored) is used. But you can also use slots from batch backup sets, by pressing "X" button in this menu and selecting the backup set you want to use. BackupSets can be tagged by pressing "+" button in the BackupSet List Menu, or from the BackupSet Management in Main menu. + To identify which data the slot contains: If the slot has been tagged, you will see its tag next to the slot number. On the top scrren line, you will see which backupSet is being used. And at the last screen line, you can see when the savedata were taken, and from which console. 2. For Wii U titles, select witch data to restore: 1. From: All users / To: Same user than Source - 1. This wil restore all save data (profiles+common) from the selected slot keeping the same userid that was used to backup the data. This option can be only used to restore previous savedata from the same console, or if the profile ids in the new console are the same thant the ones in the source console. If profile ids from source and target differ, you must use fhe following option - 2. From: select source user / To: select target user. This will copy savedata from the specified profile id in the slotbackup to the specified profile id in the console. You can specify if copy common savedata or not. - If you are just copying the savedata from one profileid to a different one in the same console, choose `copy common savedata: no`. If you are restoring to a new console with different profile ids, just choose `copy common savedata: yes` once for any of the profile ids, and copy the rest of profiles with `copy common savedata: no` + 1. This wil restore all save data (profiles+common) from the selected slot keeping the same userid that was used to backup the data. This option can only be used to restore previous savedata from the same console, or if the profile ids in the new console are identical to the ones in the source console. If profile ids from source and target differ, you must use the following option + 2. From: select source user / To: select target user. This will copy savedata from the specified profile id in the slot backup to the specified profile id in the console. You can specify if copy common savedata or not. + If you are just copying the savedata from one profile id to a different one in the same console, choose `copy common savedata: no`. If you are restoring to a new console with different profile ids, just choose `copy common savedata: yes` once for any of the profile ids, and copy the rest of profiles with `copy common savedata: no` + 3. Press "A" to initiate the restore. + #### Wipe -1. Sometimes you will need to wipe savedata in the console before restoring a previous backup. If a restore is unsuccesful, please try to wipe previous data before attempting a new restore. Options are the same than in the *Backup* task, but now refer to savedata for the specified titel in the NAND or in the USB. +Sometimes you will need to wipe savedata in the console before restoring a previous backup: If a restore is unsuccesful, yo can try to wipe previous data before attempting a new restore. Options are the same than in the *Backup* task, but now refer to savedata for the specified title in the NAND or in the USB. + #### Copy to other device If a title has savedata in the NAND and in the USB, you can copy it between both storages. Options are the same than in the *Restore* task. - ### Batch Backup You can backup savedata for all Wii U titles and all Wii titles at once using this tasks. Savedata will be stored in a "Backup set" in the `batch` directori, and can after be used to restore individual titles or to batch restore all of them. -Batch backupsets can be tagged from the list batch backup set menu (accessible by pressing X in the Backup task for any title, or by entering the menu Backupset Management from the Main menu) +BackupSets can be tagged by pressing "+" button in the BackupSet List menu or by entering the menu Backupset Management from the Main menu. ``` -sd:/wiiu/backup/batch/ +sd:/wiiu/backups/batch/ ${timestamp}/ - xxxxxxxx-yyyyyyy/ - 0/ (USB or NAND savedata for the title) - saveMii.json + saveMiiMeta.json + xxxxxxxxyyyyyyyy/ # one folder for each title + 0/ # slot containing USB or NAND savedata for the title + saveMiiMeta.json 80000001/ ... 80000002/ @@ -79,7 +89,7 @@ sd:/wiiu/backup/batch/ ... one folder for each profile common/ ... - 1/ (NAND savedata only for titles simultanously installed in USB and NAND) + 1/ # slot containing NAND savedata for titles simultaneously installed in USB and NAND ... xxxxxxxxx-yyyyyyy/ 0/ @@ -88,17 +98,17 @@ sd:/wiiu/backup/batch/ ### Batch Restore -This task allows you to restore from a batch backupset the savedata for titles already installed in the Wii U or in the vWii +This task allows you to restore from a batch backupset the savedata for all titles already installed in the Wii U or in the vWii 1. Select wether you want to restore Wii U titles or vWii titles 2. Select the backupSet you want to restore from -3. Select wich data to restore. Options are the same than in the *Restore* task. You can also choose if you want to perform a full backup (recommended) or to wipe data before restoring it -4. The list of all titles that are installed, that have a backup in the backupset, and that match the savedata criteria choosen in the previous step will appear. You can select / deselect which titles to restore. Titles with "Not Init" savedata will be skipped by default. -5. Once you have reviewed the list of titles to be restored, press A. A summary screen will appear, and if is OK, you can inititiate the restore. -6. Once the restore is completed, a summary screen will show number of sucess/failed/skipped titles. +3. Select wich data to restore. Options are the same than in the *Restore* task. You can also choose if you want to perform a full backup (recommended) or to wipe data before restoring it. +4. The list of all titles that are installed, that have a backup in the backupset, and that match the savedata criteria choosen in the previous step will appear. You can select / deselect which titles to restore. Titles with "Not Init" will be skipped by default. +5. Once you have reviewed the list of titles to be restored, press A. A summary screen will appear, and if it is OK, you can inititiate the restore. +6. Once the restore is completed, a summary screen will show the number of sucess/failed/skipped titles. 7. The list of all titles will appear again, now showing the restored status. You can try to select failed titles and restore them again to see what the error is. Succesfully restored titles will be skipped. ### Backupset management -In this menu you can tag backupsets or delete the one you don't need. You cal also set the one you want to use to restore savedata (you cal also select it directrly from the savedata restore menu) +In this menu you can tag backupsets ("+") or delete the ones you don't need ("-"). You can also set the one you want to use to restore savedata ("A"). ---- diff --git a/include/utils/Colors.h b/include/utils/Colors.h index 4a3350c..8c10251 100644 --- a/include/utils/Colors.h +++ b/include/utils/Colors.h @@ -5,14 +5,14 @@ #define COLOR_BACKGROUND Color(0x00006F00) #define COLOR_TEXT COLOR_WHITE #define COLOR_TEXT_AT_CURSOR Color(0xBBBBEEFF) -#define COLOR_LIST_HIGH Color(0x40D050FF) +#define COLOR_LIST_HIGH Color(0x40D070FF) #define COLOR_LIST_HIGH_AT_CURSOR Color(0x40D0BBFF) #define COLOR_LIST Color(0x00FF00FF) #define COLOR_LIST_AT_CURSOR Color(0x00FFAAFF) #define COLOR_LIST_SKIPPED Color(0x888800FF) #define COLOR_LIST_SKIPPED_AT_CURSOR Color(0x8888AAFF) #define COLOR_LIST_SELECTED_NOSAVE Color(0xFFFF00FF) -#define COLOR_LIST_SELECTED_NOSAVE_AT_CURSOR Color(0xFFFF60FF) +#define COLOR_LIST_SELECTED_NOSAVE_AT_CURSOR Color(0xCCCC60FF) #define COLOR_LIST_NOSAVE Color(0xFFFF00FF) #define COLOR_LIST_NOSAVE_AT_CURSOR Color(0xFFFFBBFF) #define COLOR_LIST_DANGER Color(0xFF0000FF) @@ -21,6 +21,8 @@ #define COLOR_LIST_RESTORE_SUCCESS_AT_CURSOR Color(0xBBBBEEFF) #define COLOR_INFO Color(0x88CC88FF) #define COLOR_INFO_AT_CURSOR Color(0x88CCCCFF) +#define COLOR_CURRENT_BS Color(0xFFBB33FF) +#define COLOR_CURRENT_BS_AT_CURSOR Color(0xFFFF99FF) #define COLOR_KEY Color(0xFF3333FF) #define COLOR_KEY_S Color(0xFF666600) #define COLOR_KEY_C Color(0xFF0000FF) diff --git a/romfs/languages/SChinese.json b/romfs/languages/SChinese.json index 5468029..cb7c53b 100644 --- a/romfs/languages/SChinese.json +++ b/romfs/languages/SChinese.json @@ -174,7 +174,13 @@ "vWii Titles": "vWii Titles", "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", - "BS: %s": "BS: %s", + "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/TChinese.json b/romfs/languages/TChinese.json index bd6487e..4067a08 100644 --- a/romfs/languages/TChinese.json +++ b/romfs/languages/TChinese.json @@ -169,7 +169,13 @@ "vWii Titles": "vWii Titles", "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", - "BS: %s": "BS: %s", + "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/english.json b/romfs/languages/english.json index 320cc0b..f4f2181 100644 --- a/romfs/languages/english.json +++ b/romfs/languages/english.json @@ -204,6 +204,12 @@ "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/german.json b/romfs/languages/german.json index f29f9e3..f3345cb 100644 --- a/romfs/languages/german.json +++ b/romfs/languages/german.json @@ -175,6 +175,12 @@ "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/italian.json b/romfs/languages/italian.json index 2c116cc..542a154 100644 --- a/romfs/languages/italian.json +++ b/romfs/languages/italian.json @@ -174,7 +174,13 @@ "vWii Titles": "vWii Titles", "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", - "BS: %s": "BS: %s", + "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/japanese.json b/romfs/languages/japanese.json index 9c91840..0956be6 100644 --- a/romfs/languages/japanese.json +++ b/romfs/languages/japanese.json @@ -169,7 +169,13 @@ "vWii Titles": "vWii Titles", "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", - "BS: %s": "BS: %s", + "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/korean.json b/romfs/languages/korean.json index 2b2a897..bf1e796 100644 --- a/romfs/languages/korean.json +++ b/romfs/languages/korean.json @@ -170,6 +170,12 @@ "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/portuguese.json b/romfs/languages/portuguese.json index b0301ec..45fd47f 100644 --- a/romfs/languages/portuguese.json +++ b/romfs/languages/portuguese.json @@ -174,7 +174,13 @@ "vWii Titles": "vWii Titles", "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", - "BS: %s": "BS: %s", + "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/russian.json b/romfs/languages/russian.json index 69fc499..ab06d66 100644 --- a/romfs/languages/russian.json +++ b/romfs/languages/russian.json @@ -202,7 +202,13 @@ "vWii Titles": "vWii Titles", "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", - "BS: %s": "BS: %s", + "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/romfs/languages/spanish.json b/romfs/languages/spanish.json index de97408..88c8df0 100644 --- a/romfs/languages/spanish.json +++ b/romfs/languages/spanish.json @@ -197,6 +197,12 @@ "|Restored|": "|Restored|", " BackupSet Management": " BackupSet Management", "BS: %s": "BS: %s", + "pre-BatchRestore Backup (WiiU)": "pre-BatchRestore Backup (WiiU)", + "pre-BatchRestore Backup (vWii)": "pre-BatchRestore Backup (vWii)", + "pre-Restore backup": "pre-Restore backup", + "pre-Wipe backup": "pre-Wipe backup", + "pre-copyToOtherDev backup": "pre-copyToOtherDev backup", + "UNUSABLE SLOT - BACKUP FAILED": "UNUSABLE SLOT - BACKUP FAILED", "KB_N_0": "1234567890-=", "KB_N_1": "qwertyuiop[]|", "KB_N_2": "asdfghjkl;'", diff --git a/src/menu/BRTitleSelectState.cpp b/src/menu/BRTitleSelectState.cpp index d97595a..daf7a7d 100644 --- a/src/menu/BRTitleSelectState.cpp +++ b/src/menu/BRTitleSelectState.cpp @@ -277,9 +277,9 @@ ApplicationState::eSubState BRTitleSelectState::update(Input *input) { const std::string batchDatetime = getNowDateForFolder(); backupAllSave(this->titles, this->titlesCount, batchDatetime, true); if(isWiiUBatchRestore) - writeBackupAllMetadata(batchDatetime,"(pre)BatchRestore Backup (WiiU)"); + writeBackupAllMetadata(batchDatetime,LanguageUtils::gettext("pre-BatchRestore Backup (WiiU)")); else - writeBackupAllMetadata(batchDatetime,"(pre)BatchRestore Backup (vWii)"); + writeBackupAllMetadata(batchDatetime,LanguageUtils::gettext("pre-BatchRestore Backup (vWii)")); BackupSetList::setIsInitializationRequired(true); } diff --git a/src/menu/BackupSetListState.cpp b/src/menu/BackupSetListState.cpp index 10cc9d0..546e708 100644 --- a/src/menu/BackupSetListState.cpp +++ b/src/menu/BackupSetListState.cpp @@ -75,7 +75,7 @@ void BackupSetListState::render() { if ( backupSetItem == BackupSetList::ROOT_BS) DrawUtils::setFontColorByCursor(COLOR_LIST_HIGH,COLOR_LIST_HIGH_AT_CURSOR,cursorPos,i); if ( backupSetItem == BackupSetList::getBackupSetEntry()) - DrawUtils::setFontColorByCursor(COLOR_INFO,COLOR_INFO_AT_CURSOR,cursorPos,i); + DrawUtils::setFontColorByCursor(COLOR_CURRENT_BS,COLOR_CURRENT_BS_AT_CURSOR,cursorPos,i); consolePrintPos(M_OFF-1, i + 2, " %s", backupSetItem.substr(0,15).c_str()); consolePrintPos(21, i+2,"%s", BackupSetList::currentBackupSetList->getStretchedSerialIdAt(i+scroll).c_str()); @@ -175,9 +175,13 @@ ApplicationState::eSubState BackupSetListState::update(Input *input) { } } if (input->get(TRIGGER, PAD_BUTTON_PLUS)) { - this->state = STATE_DO_SUBSTATE; - this->substateCalled = STATE_KEYBOARD; - this->subState = std::make_unique(newTag); + int entry = cursorPos+scroll; + if (entry > 0) + { + this->state = STATE_DO_SUBSTATE; + this->substateCalled = STATE_KEYBOARD; + this->subState = std::make_unique(newTag); + } } } else if (this->state == STATE_DO_SUBSTATE) { auto retSubState = this->subState->update(input); diff --git a/src/savemng.cpp b/src/savemng.cpp index d5cbe26..64e87bd 100644 --- a/src/savemng.cpp +++ b/src/savemng.cpp @@ -114,12 +114,12 @@ Account *getSDacc() { int checkEntry(const char *fPath) { struct stat st {}; if (stat(fPath, &st) == -1) - return 0; + return 0; // path does not exist if (S_ISDIR(st.st_mode)) - return 2; + return 2; // is a directory - return 1; + return 1; // is a file } #else int checkEntry(const char *fPath) { @@ -474,7 +474,7 @@ void promptError(const char *message, ...) { free(tmp); DrawUtils::endDraw(); va_end(va); - sleep(4); + sleep(3); } void promptMessage(Color bgcolor, const char *message, ...) { @@ -996,7 +996,7 @@ void copySavedata(Title *title, Title *titleb, int8_t wiiuuser, int8_t wiiuuser_ return; int slotb = getEmptySlot(titleb->highID, titleb->lowID); if ((slotb >= 0) && promptConfirm(ST_YES_NO, LanguageUtils::gettext("Backup current savedata first to next empty slot?"))) { - backupSavedata(titleb, slotb, wiiuuser, common, "backup pre-copyToOtherDev"); + backupSavedata(titleb, slotb, wiiuuser, common, LanguageUtils::gettext("pre-copyToOtherDev backup")); promptError(LanguageUtils::gettext("Backup done. Now copying Savedata.")); } @@ -1138,6 +1138,7 @@ void backupAllSave(Title *titles, int count, const std::string & batchDatetime, } void backupSavedata(Title *title, uint8_t slot, int8_t wiiuuser, bool common, const std::string &tag /* = "" */) { + int errorCode = 0; if (!isSlotEmpty(title->highID, title->lowID, slot) && !promptConfirm(ST_WARNING, LanguageUtils::gettext("Backup found on this slot. Overwrite it?"))) { return; @@ -1148,10 +1149,86 @@ void backupSavedata(Title *title, uint8_t slot, int8_t wiiuuser, bool common, co bool isWii = title->is_Wii; const std::string path = (isWii ? "storage_slccmpt01:/title" : (isUSB ? (getUSB() + "/usr/save").c_str() : "storage_mlc01:/usr/save")); std::string srcPath = StringUtils::stringFormat("%s/%08x/%08x/%s", path.c_str(), highID, lowID, isWii ? "data" : "user"); - std::string dstPath; - dstPath = getDynamicBackupPath(highID, lowID, slot); + std::string dstPath = getDynamicBackupPath(highID, lowID, slot); createFolder(dstPath.c_str()); + + std::string srcCommonPath = srcPath + "/common"; + std::string dstCommonPath = dstPath + "/common"; + bool commonSaved = false; + bool doBase; + bool doCommon; + bool singleUser = false; + + if ( isWii ) { + doBase = true; + doCommon = false; + } + else + { + switch (wiiuuser) { + case -1: // allusers + doBase = true; + doCommon = false; + break; + default: // wiiuuser = 0 .. n + doBase = true; + doCommon = common; + singleUser = true; + srcPath.append(StringUtils::stringFormat("/%s", wiiuacc[wiiuuser].persistentID)); + dstPath.append(StringUtils::stringFormat("/%s", wiiuacc[wiiuuser].persistentID)); + break; + } + } + + + if (doCommon) { + if (copyDir(srcCommonPath, dstCommonPath)) + commonSaved = true; + else { + promptError(LanguageUtils::gettext("Common save not found.")); + errorCode = 1 ; + } + } + + if (doBase) { + if (singleUser) + { + if (checkEntry(srcPath.c_str()) == 0) { // no dir for user data + if (commonSaved) + writeMetadataWithTag(highID,lowID,slot,isUSB,tag); + else + { + promptError(LanguageUtils::gettext("No save found for this user.")); + dstPath = getDynamicBackupPath(highID, lowID, slot); + removeDir(dstPath); + unlink(dstPath.c_str()); + errorCode += 2; + } + + } + else { + if (!copyDir(srcPath, dstPath)) { + promptError(LanguageUtils::gettext("Backup failed. DO NOT restore from this slot.")); + writeMetadataWithTag(highID,lowID,slot,isUSB,LanguageUtils::gettext("UNUSABLE SLOT - BACKUP FAILED")); + errorCode += 4; + } + else + writeMetadataWithTag(highID,lowID,slot,isUSB,tag); + } + } + else // allusers + { + if (!copyDir(srcPath, dstPath)) { + promptError(LanguageUtils::gettext("Backup failed. DO NOT restore from this slot.")); + writeMetadataWithTag(highID,lowID,slot,isUSB,LanguageUtils::gettext("UNUSABLE SLOT - BACKUP FAILED")); + errorCode += 8; + } + else + writeMetadataWithTag(highID,lowID,slot,isUSB,tag); + } + } +/* if ((wiiuuser > -1) && !isWii) { if (common) { if (copyDir(srcPath+"/common", dstPath+"/common")) @@ -1174,10 +1251,10 @@ void backupSavedata(Title *title, uint8_t slot, int8_t wiiuuser, bool common, co return; } } - if (!copyDir(srcPath, dstPath)) promptError(LanguageUtils::gettext("Backup failed. DO NOT restore from this slot.")); else writeMetadataWithTag(highID,lowID,slot,isUSB,tag); +*/ } @@ -1195,7 +1272,7 @@ int restoreSavedata(Title *title, uint8_t slot, int8_t sduser, int8_t wiiuuser, BackupSetList::setBackupSetSubPathToRoot(); int slotb = getEmptySlot(title->highID, title->lowID); if ((slotb >= 0) && promptConfirm(ST_YES_NO, LanguageUtils::gettext("Backup current savedata first to next empty slot?"))) - backupSavedata(title, slotb, wiiuuser, common , "backup pre-Restore"); + backupSavedata(title, slotb, wiiuuser, common , LanguageUtils::gettext("pre-Restore backup")); BackupSetList::restoreBackupSetSubPath(); } uint32_t highID = title->highID; @@ -1333,7 +1410,7 @@ int wipeSavedata(Title *title, int8_t wiiuuser, bool common, bool interactive /* return -1; int slotb = getEmptySlot(title->highID, title->lowID); if ((slotb >= 0) && promptConfirm(ST_YES_NO, LanguageUtils::gettext("Backup current savedata first?"))) - backupSavedata(title, slotb, wiiuuser, common, "backup pre-Wipe"); + backupSavedata(title, slotb, wiiuuser, common, LanguageUtils::gettext("pre-Wipe backup")); } uint32_t highID = title->highID; uint32_t lowID = title->lowID;