1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-12-23 08:32:04 +00:00

Fix archive bits V2

It can now fix the whole nintendo folder.

A proposed usage is by using the first option and then the 2nd.
This commit is contained in:
Kostas Missos 2018-12-16 16:57:49 +02:00
parent 5ed875ce90
commit 0d9aebda7b
3 changed files with 20 additions and 14 deletions

View file

@ -329,7 +329,7 @@ void menu_autorcm()
tui_do_menu(&gfx_con, &menu); tui_do_menu(&gfx_con, &menu);
} }
int _fix_attributes(char *path, u32 *total, u32 is_root, u32 check_first_run) int _fix_attributes(char *path, u32 *total, u32 hos_folder, u32 check_first_run)
{ {
FRESULT res; FRESULT res;
DIR dir; DIR dir;
@ -369,8 +369,8 @@ int _fix_attributes(char *path, u32 *total, u32 is_root, u32 check_first_run)
if (res != FR_OK || fno.fname[0] == 0) if (res != FR_OK || fno.fname[0] == 0)
break; break;
// Skip official Nintendo dir. // Skip official Nintendo dir if started from root.
if (is_root && !strcmp(fno.fname, "Nintendo")) if (!hos_folder && !strcmp(fno.fname, "Nintendo"))
continue; continue;
// Set new directory or file. // Set new directory or file.
@ -380,15 +380,21 @@ int _fix_attributes(char *path, u32 *total, u32 is_root, u32 check_first_run)
// Check if archive bit is set. // Check if archive bit is set.
if (fno.fattrib & AM_ARC) if (fno.fattrib & AM_ARC)
{ {
*(u32 *)total = *(u32 *)total + 1; *total = *total + 1;
f_chmod(path, 0, AM_ARC); f_chmod(path, 0, AM_ARC);
} }
// Is it a directory? // Is it a directory?
if (fno.fattrib & AM_DIR) if (fno.fattrib & AM_DIR)
{ {
// Set archive bit to NCA folders.
if (hos_folder && !strcmp(fno.fname + strlen(fno.fname) - 4, ".nca"))
{
*total = *total + 1;
f_chmod(path, AM_ARC, AM_ARC);
}
// Enter the directory. // Enter the directory.
res = _fix_attributes(path, total, 0, 0); res = _fix_attributes(path, total, hos_folder, 0);
if (res != FR_OK) if (res != FR_OK)
break; break;
} }
@ -405,7 +411,7 @@ void _fix_sd_attr(u32 type)
gfx_con_setpos(&gfx_con, 0, 0); gfx_con_setpos(&gfx_con, 0, 0);
char path[256]; char path[256];
char label[14]; char label[16];
u32 total = 0; u32 total = 0;
if (sd_mount()) if (sd_mount())
@ -418,21 +424,21 @@ void _fix_sd_attr(u32 type)
break; break;
case 1: case 1:
default: default:
memcpy(path, "/switch", 8); memcpy(path, "/Nintendo", 10);
memcpy(label, "switch folder", 14); memcpy(label, "Nintendo folder", 16);
break; break;
} }
gfx_printf(&gfx_con, "Traversing all %s files!\nThis may take some time, please wait...\n\n", label); gfx_printf(&gfx_con, "Traversing all %s files!\nThis may take some time, please wait...\n\n", label);
_fix_attributes(path, &total, !type, type); _fix_attributes(path, &total, type, type);
gfx_printf(&gfx_con, "%kTotal archive bits cleared: %d!%k\n\nDone! Press any key...", 0xFF96FF00, total, 0xFFCCCCCC); gfx_printf(&gfx_con, "%kTotal archive bits cleared: %d!%k\n\nDone! Press any key...", 0xFF96FF00, total, 0xFFCCCCCC);
sd_unmount(); sd_unmount();
} }
btn_wait(); btn_wait();
} }
void fix_sd_all_attr() { _fix_sd_attr(0); } void fix_sd_all_attr() { _fix_sd_attr(0); }
void fix_sd_switch_attr() { _fix_sd_attr(1); } void fix_sd_nin_attr() { _fix_sd_attr(1); }
void fix_battery_desync() void fix_battery_desync()
{ {

View file

@ -20,7 +20,7 @@
void dump_packages12(); void dump_packages12();
void fix_sd_all_attr(); void fix_sd_all_attr();
void fix_sd_switch_attr(); void fix_sd_nin_attr();
void fix_battery_desync(); void fix_battery_desync();
void menu_autorcm(); void menu_autorcm();

View file

@ -1106,8 +1106,8 @@ ment_t ment_tools[] = {
MDEF_CAPTION("-------- Misc --------", 0xFF0AB9E6), MDEF_CAPTION("-------- Misc --------", 0xFF0AB9E6),
MDEF_HANDLER("Dump package1/2", dump_packages12), MDEF_HANDLER("Dump package1/2", dump_packages12),
MDEF_HANDLER("Fix battery de-sync", fix_battery_desync), MDEF_HANDLER("Fix battery de-sync", fix_battery_desync),
MDEF_HANDLER("Unset archive bit (switch folder)", fix_sd_switch_attr), MDEF_HANDLER("Fix archive bit (except Nintendo folder)", fix_sd_all_attr),
MDEF_HANDLER("Unset archive bit (all sd files)", fix_sd_all_attr), MDEF_HANDLER("Fix archive bit (Nintendo folder)", fix_sd_nin_attr),
//MDEF_HANDLER("Fix fuel gauge configuration", fix_fuel_gauge_configuration), //MDEF_HANDLER("Fix fuel gauge configuration", fix_fuel_gauge_configuration),
//MDEF_HANDLER("Reset all battery cfg", reset_pmic_fuel_gauge_charger_config), //MDEF_HANDLER("Reset all battery cfg", reset_pmic_fuel_gauge_charger_config),
//MDEF_HANDLER("Minerva", minerva), // Uncomment for testing Minerva Training Cell //MDEF_HANDLER("Minerva", minerva), // Uncomment for testing Minerva Training Cell