diff --git a/source/godmode.c b/source/godmode.c index 7d11b38..030bd61 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -1570,11 +1570,13 @@ u32 GodMode(bool is_b9s) { int srch_t = ((strncmp(curr_entry->path + 1, ":/title", 7) == 0) || (*tpath && PathExist(tpath))) ? ++n_opt : -1; int srch_f = ++n_opt; + int fixcmac = (!*current_path && (strspn(curr_entry->path, "14AB") == 1)) ? ++n_opt : -1; int dirnfo = ++n_opt; int drvnfo = (!*current_path) ? ++n_opt : -1; int stdcpy = (*current_path && strncmp(current_path, OUTPUT_PATH, 256) != 0) ? ++n_opt : -1; if (srch_t > 0) optionstr[srch_t-1] = "Search for titles"; if (srch_f > 0) optionstr[srch_f-1] = "Search for files..."; + if (fixcmac > 0) optionstr[fixcmac-1] = "Fix CMACs for drive"; if (dirnfo > 0) optionstr[dirnfo-1] = "Directory info"; if (drvnfo > 0) optionstr[drvnfo-1] = "Drive info"; if (stdcpy > 0) optionstr[stdcpy-1] = "Copy to " OUTPUT_PATH; @@ -1593,6 +1595,9 @@ u32 GodMode(bool is_b9s) { cursor = 1; scroll = 0; } + } else if (user_select == fixcmac) { + ShowString("%s\nFixing CMACs for drive...", namestr); + RecursiveFixFileCmac(curr_entry->path); } else if (user_select == dirnfo) { u64 tsize = 0; u32 tdirs = 0; diff --git a/source/nand/nandcmac.c b/source/nand/nandcmac.c index 119ee82..4f85a64 100644 --- a/source/nand/nandcmac.c +++ b/source/nand/nandcmac.c @@ -236,12 +236,10 @@ u32 FixFileCmac(const char* path) { u32 RecursiveFixFileCmacWorker(char* path) { FILINFO fno; + DIR pdir; - if (fvx_stat(path, &fno) != FR_OK) return 1; // path does not exist - if (fno.fattrib & AM_DIR) { // process folder contents - DIR pdir; + if (fvx_opendir(&pdir, path) == FR_OK) { // process folder contents char* fname = path + strnlen(path, 255); - if (fvx_opendir(&pdir, path) != FR_OK) return 1; *(fname++) = '/'; while (f_readdir(&pdir, &fno) == FR_OK) { @@ -258,7 +256,7 @@ u32 RecursiveFixFileCmacWorker(char* path) { } f_closedir(&pdir); *(--fname) = '\0'; - } else if (CheckCmacPath(path) == 0) + } else if (CheckCmacPath(path) == 0) // fix single file CMAC return FixFileCmac(path); return 0;