mirror of
https://github.com/CTCaer/hekate.git
synced 2025-04-20 11:35:56 +00:00
allow for all files to unset archive bit, except Nintendo dir
This commit is contained in:
parent
eecdca3f03
commit
af70b2fd91
1 changed files with 34 additions and 15 deletions
49
ipl/main.c
49
ipl/main.c
|
@ -1906,7 +1906,7 @@ out:;
|
|||
btn_wait();
|
||||
}
|
||||
|
||||
int fix_attributes(char *path, u32 *total)
|
||||
int fix_attributes(char *path, u32 *total, u32 is_root, u32 check_first_run)
|
||||
{
|
||||
FRESULT res;
|
||||
DIR dir;
|
||||
|
@ -1914,9 +1914,20 @@ int fix_attributes(char *path, u32 *total)
|
|||
u32 k = 0;
|
||||
static FILINFO fno;
|
||||
|
||||
// Remove archive bit for selected "root" path.
|
||||
f_chmod(path, 0, AM_ARC);
|
||||
if (check_first_run)
|
||||
{
|
||||
res = f_stat(path, &fno);
|
||||
if (res != FR_OK)
|
||||
return res;
|
||||
|
||||
// Check if archive bit is set.
|
||||
if (fno.fattrib & AM_ARC)
|
||||
{
|
||||
*(u32 *)total = *(u32 *)total + 1;
|
||||
f_chmod(path, 0, AM_ARC);
|
||||
}
|
||||
}
|
||||
|
||||
// Open directory.
|
||||
res = f_opendir(&dir, path);
|
||||
if (res == FR_OK)
|
||||
|
@ -1929,6 +1940,12 @@ int fix_attributes(char *path, u32 *total)
|
|||
if (res != FR_OK || fno.fname[0] == 0)
|
||||
break;
|
||||
|
||||
if (is_root && !strcmp(fno.fname, "Nintendo"))
|
||||
{
|
||||
path[i] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set new directory.
|
||||
i = strlen(path);
|
||||
memcpy(&path[i], "/", 1);
|
||||
|
@ -1951,7 +1968,7 @@ int fix_attributes(char *path, u32 *total)
|
|||
if (fno.fattrib & AM_DIR)
|
||||
{
|
||||
// Enter the directory.
|
||||
res = fix_attributes(path, total);
|
||||
res = fix_attributes(path, total, 0, 0);
|
||||
if (res != FR_OK)
|
||||
break;
|
||||
}
|
||||
|
@ -1969,7 +1986,8 @@ void fix_sd_attr(u32 type)
|
|||
gfx_clear_grey(&gfx_ctxt, 0x1B);
|
||||
gfx_con_setpos(&gfx_con, 0, 0);
|
||||
|
||||
char buff[256];
|
||||
char path[256];
|
||||
char label[14];
|
||||
|
||||
u32 total = 0;
|
||||
if (sd_mount())
|
||||
|
@ -1977,25 +1995,26 @@ void fix_sd_attr(u32 type)
|
|||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
gfx_printf(&gfx_con, "Traversing all switch folder files!\nThis may take some time, please wait...\n");
|
||||
memcpy(buff, "/switch\0", 8);
|
||||
memcpy(path, "/", 2);
|
||||
memcpy(label, "sd card", 8);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
gfx_printf(&gfx_con, "Traversing all sd card files!\nThis may take some time, please wait...\n");
|
||||
memcpy(buff, "/\0", 2);
|
||||
memcpy(path, "/switch", 8);
|
||||
memcpy(label, "switch folder", 14);
|
||||
break;
|
||||
}
|
||||
|
||||
fix_attributes(buff, &total);
|
||||
gfx_printf(&gfx_con, "\n%kTotal archive bits cleared: %d!%k\n\nDone! Press any key...", 0xFF96FF00, total, 0xFFCCCCCC);
|
||||
gfx_printf(&gfx_con, "Traversing all %s files!\nThis may take some time, please wait...\n\n", label);
|
||||
fix_attributes(path, &total, !type, type);
|
||||
gfx_printf(&gfx_con, "%kTotal archive bits cleared: %d!%k\n\nDone! Press any key...", 0xFF96FF00, total, 0xFFCCCCCC);
|
||||
sd_unmount();
|
||||
}
|
||||
btn_wait();
|
||||
}
|
||||
|
||||
void fix_sd_switch_attr() { fix_sd_attr(0); }
|
||||
void fix_sd_all_attr() { fix_sd_attr(1); }
|
||||
void fix_sd_all_attr() { fix_sd_attr(0); }
|
||||
void fix_sd_switch_attr() { fix_sd_attr(1); }
|
||||
|
||||
void print_fuel_gauge_info()
|
||||
{
|
||||
|
@ -2431,8 +2450,8 @@ ment_t ment_tools[] = {
|
|||
MDEF_CAPTION("-------- Misc --------", 0xFF0AB9E6),
|
||||
MDEF_HANDLER("Dump package1", dump_package1),
|
||||
MDEF_HANDLER("Fix battery de-sync", fix_battery_desync),
|
||||
MDEF_HANDLER("Remove archive bit (switch folder)", fix_sd_switch_attr),
|
||||
//MDEF_HANDLER("Remove archive bit (all sd files)", fix_sd_all_attr),
|
||||
MDEF_HANDLER("Unset switch archive attributes", fix_sd_switch_attr),
|
||||
MDEF_HANDLER("Unset all archive attributes", fix_sd_all_attr),
|
||||
//MDEF_HANDLER("Fix fuel gauge configuration", fix_fuel_gauge_configuration),
|
||||
//MDEF_HANDLER("Reset all battery cfg", reset_pmic_fuel_gauge_charger_config),
|
||||
MDEF_CHGLINE(),
|
||||
|
|
Loading…
Add table
Reference in a new issue