mirror of
https://github.com/CTCaer/hekate.git
synced 2025-08-02 22:28:49 +00:00
negating the if statement to reduce conditional context
This commit is contained in:
parent
21f21da85d
commit
31b92d65ce
1 changed files with 40 additions and 40 deletions
80
ipl/main.c
80
ipl/main.c
|
@ -1932,53 +1932,53 @@ int fix_attributes(char *path, u32 *total, u32 is_root, u32 check_first_run)
|
||||||
|
|
||||||
// Open directory.
|
// Open directory.
|
||||||
res = f_opendir(&dir, path);
|
res = f_opendir(&dir, path);
|
||||||
if (res == FR_OK)
|
if (res != FR_OK)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
dirLength = strlen(path);
|
||||||
|
for (;;)
|
||||||
{
|
{
|
||||||
dirLength = strlen(path);
|
// Read a directory item.
|
||||||
for (;;)
|
res = f_readdir(&dir, &fno);
|
||||||
|
|
||||||
|
// Break on error or end of dir.
|
||||||
|
if (res != FR_OK || fno.fname[0] == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Skip official Nintendo dir.
|
||||||
|
if (is_root && !strcmp(fno.fname, "Nintendo"))
|
||||||
{
|
{
|
||||||
// Read a directory item.
|
|
||||||
res = f_readdir(&dir, &fno);
|
|
||||||
|
|
||||||
// Break on error or end of dir.
|
|
||||||
if (res != FR_OK || fno.fname[0] == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Skip official Nintendo dir.
|
|
||||||
if (is_root && !strcmp(fno.fname, "Nintendo"))
|
|
||||||
{
|
|
||||||
path[dirLength] = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set new directory or file.
|
|
||||||
memcpy(&path[dirLength], "/", 1);
|
|
||||||
fileLength = strlen(fno.fname);
|
|
||||||
memcpy(&path[dirLength+1], fno.fname, fileLength + 1);
|
|
||||||
|
|
||||||
// Check if archive bit is set.
|
|
||||||
if (fno.fattrib & AM_ARC)
|
|
||||||
{
|
|
||||||
*(u32 *)total = *(u32 *)total + 1;
|
|
||||||
f_chmod(path, 0, AM_ARC);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is it a directory?
|
|
||||||
if (fno.fattrib & AM_DIR)
|
|
||||||
{
|
|
||||||
// Enter the directory.
|
|
||||||
res = fix_attributes(path, total, 0, 0);
|
|
||||||
if (res != FR_OK)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear file or folder path.
|
|
||||||
path[dirLength] = 0;
|
path[dirLength] = 0;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
f_closedir(&dir);
|
// Set new directory or file.
|
||||||
|
memcpy(&path[dirLength], "/", 1);
|
||||||
|
fileLength = strlen(fno.fname);
|
||||||
|
memcpy(&path[dirLength+1], fno.fname, fileLength + 1);
|
||||||
|
|
||||||
|
// Check if archive bit is set.
|
||||||
|
if (fno.fattrib & AM_ARC)
|
||||||
|
{
|
||||||
|
*(u32 *)total = *(u32 *)total + 1;
|
||||||
|
f_chmod(path, 0, AM_ARC);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is it a directory?
|
||||||
|
if (fno.fattrib & AM_DIR)
|
||||||
|
{
|
||||||
|
// Enter the directory.
|
||||||
|
res = fix_attributes(path, total, 0, 0);
|
||||||
|
if (res != FR_OK)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear file or folder path.
|
||||||
|
path[dirLength] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f_closedir(&dir);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue