diff --git a/edifyscripting.c b/edifyscripting.c index 3b0d4c9..f7616ef 100644 --- a/edifyscripting.c +++ b/edifyscripting.c @@ -174,6 +174,7 @@ Value* RestoreFn(const char* name, State* state, int argc, Expr* argv[]) { int restoredata = 1; int restorecache = 1; int restoresdext = 1; + int restorewimax = 1; int i; for (i = 1; i < argc; i++) { @@ -189,6 +190,8 @@ Value* RestoreFn(const char* name, State* state, int argc, Expr* argv[]) { restorecache = 0; else if (strcmp(args2[i], "nosd-ext") == 0) restoresdext = 0; + else if (strcmp(args2[i], "nowimax") == 0) + restorewimax = 0; } for (i = 0; i < argc; ++i) { @@ -197,7 +200,7 @@ Value* RestoreFn(const char* name, State* state, int argc, Expr* argv[]) { free(args); free(args2); - if (0 != nandroid_restore(path, restoreboot, restoresystem, restoredata, restorecache, restoresdext)) { + if (0 != nandroid_restore(path, restoreboot, restoresystem, restoredata, restorecache, restoresdext, restorewimax)) { free(path); return StringValue(strdup("")); } diff --git a/extendedcommands.c b/extendedcommands.c index 297f811..3113ab8 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -214,20 +214,20 @@ char** gather_files(const char* directory, const char* fileExtensionOrDirectory, return NULL; } - // sort the result - if (files != NULL) { - for (i = 0; i < total; i++) { - int curMax = -1; - int j; - for (j = 0; j < total - i; j++) { - if (curMax == -1 || strcmp(files[curMax], files[j]) < 0) - curMax = j; - } - char* temp = files[curMax]; - files[curMax] = files[total - i - 1]; - files[total - i - 1] = temp; - } - } + // sort the result + if (files != NULL) { + for (i = 0; i < total; i++) { + int curMax = -1; + int j; + for (j = 0; j < total - i; j++) { + if (curMax == -1 || strcmp(files[curMax], files[j]) < 0) + curMax = j; + } + char* temp = files[curMax]; + files[curMax] = files[total - i - 1]; + files[total - i - 1] = temp; + } + } return files; } @@ -337,7 +337,7 @@ void show_nandroid_restore_menu() return; if (confirm_selection("Confirm restore?", "Yes - Restore")) - nandroid_restore(file, 1, 1, 1, 1, 1); + nandroid_restore(file, 1, 1, 1, 1, 1, 1); } void show_mount_usb_storage_menu() @@ -648,6 +648,7 @@ void show_nandroid_advanced_restore_menu() "Restore data", "Restore cache", "Restore sd-ext", + "Restore wimax", NULL }; @@ -659,23 +660,27 @@ void show_nandroid_advanced_restore_menu() { case 0: if (confirm_selection(confirm_restore, "Yes - Restore boot")) - nandroid_restore(file, 1, 0, 0, 0, 0); + nandroid_restore(file, 1, 0, 0, 0, 0, 0); break; case 1: if (confirm_selection(confirm_restore, "Yes - Restore system")) - nandroid_restore(file, 0, 1, 0, 0, 0); + nandroid_restore(file, 0, 1, 0, 0, 0, 0); break; case 2: if (confirm_selection(confirm_restore, "Yes - Restore data")) - nandroid_restore(file, 0, 0, 1, 0, 0); + nandroid_restore(file, 0, 0, 1, 0, 0, 0); break; case 3: if (confirm_selection(confirm_restore, "Yes - Restore cache")) - nandroid_restore(file, 0, 0, 0, 1, 0); + nandroid_restore(file, 0, 0, 0, 1, 0, 0); break; case 4: if (confirm_selection(confirm_restore, "Yes - Restore sd-ext")) - nandroid_restore(file, 0, 0, 0, 0, 1); + nandroid_restore(file, 0, 0, 0, 0, 1, 0); + break; + case 5: + if (confirm_selection(confirm_restore, "Yes - Restore wimax")) + nandroid_restore(file, 0, 0, 0, 0, 0, 1); break; } } @@ -997,7 +1002,7 @@ void process_volumes() { ui_print("in case of error.\n"); nandroid_backup(backup_path); - nandroid_restore(backup_path, 1, 1, 1, 1, 1); + nandroid_restore(backup_path, 1, 1, 1, 1, 1, 1); ui_set_show_text(0); } diff --git a/nandroid.c b/nandroid.c index 5d174a7..4a92e33 100644 --- a/nandroid.c +++ b/nandroid.c @@ -141,6 +141,15 @@ int nandroid_backup(const char* backup_path) return print_and_error("Error while dumping recovery image!\n"); #endif + if (0 == (ret = get_partition_device("wimax", tmp))) + { + ui_print("Backing up wimax...\n"); + sprintf(tmp, "%s/%s", backup_path, "wimax.img"); + ret = backup_raw_partition("wimax", tmp); + if (0 != ret) + return print_and_error("Error while dumping wimax image!\n"); + } + if (0 != (ret = nandroid_backup_partition(backup_path, "/system"))) return ret; @@ -253,7 +262,7 @@ int nandroid_restore_partition(const char* backup_path, const char* root) { return nandroid_restore_partition_extended(backup_path, root, 1); } -int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext) +int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext, int restore_wimax) { ui_set_background(BACKGROUND_ICON_INSTALLING); ui_show_indeterminate_progress(); @@ -285,6 +294,26 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst } #endif + if (restore_wimax && 0 == (ret = get_partition_device("wimax", tmp))) + { + sprintf(tmp, "%s/wimax.img", backup_path); + + struct stat st; + if (0 != stat(tmp, &st)) + { + ui_print("WARNING: Wimax partition exists, but nandroid\n"); + ui_print(" backup does not contain wimax image.\n"); + ui_print(" You should create a new backup to\n"); + ui_print(" protect your wimax data.\n"); + } + else + { + ui_print("Restoring wimax image...\n"); + if (0 != (ret = restore_raw_partition("wimax", tmp))) + return ret; + } + } + if (restore_system && 0 != (ret = nandroid_restore_partition(backup_path, "/system"))) return ret; @@ -354,7 +383,7 @@ int nandroid_main(int argc, char** argv) { if (argc != 3) return nandroid_usage(); - return nandroid_restore(argv[2], 1, 1, 1, 1, 1); + return nandroid_restore(argv[2], 1, 1, 1, 1, 1, 1); } return nandroid_usage(); diff --git a/nandroid.h b/nandroid.h index f124e11..926bf30 100644 --- a/nandroid.h +++ b/nandroid.h @@ -3,7 +3,7 @@ int nandroid_main(int argc, char** argv); int nandroid_backup(const char* backup_path); -int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext); +int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext, int restore_wimax); void nandroid_generate_timestamp_path(char* backup_path); #endif \ No newline at end of file