mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Show the free space on each drive in the root menu (#76)
* show the free space on each of the drives in the root menu * round up to nearest 0.1GB, instead of nearest GB * remove redundant checks for bytes
This commit is contained in:
parent
f8cd65dd69
commit
d68ac105e6
@ -200,7 +200,9 @@ void dm_drawBottomScreen(void) {
|
||||
}
|
||||
printf ("\n(SD FAT, ");
|
||||
printDriveBytes(sdSize);
|
||||
printf(")");
|
||||
printf(")\n");
|
||||
printDriveBytes(getBytesFree("sd:/"));
|
||||
printf(" space free");
|
||||
} else if (dmAssignedOp[dmCursorPosition] == 1) {
|
||||
printf ("[fat:] FLASHCART");
|
||||
if (fatLabel[0] != '\0') {
|
||||
@ -208,7 +210,9 @@ void dm_drawBottomScreen(void) {
|
||||
}
|
||||
printf ("\n(Slot-1 SD FAT, ");
|
||||
printDriveBytes(fatSize);
|
||||
printf(")");
|
||||
printf(")\n");
|
||||
printDriveBytes(getBytesFree("fat:/"));
|
||||
printf(" space free");
|
||||
} else if (dmAssignedOp[dmCursorPosition] == 2) {
|
||||
printf ("GBA GAMECART\n");
|
||||
printf ("(GBA Game)");
|
||||
@ -228,7 +232,9 @@ void dm_drawBottomScreen(void) {
|
||||
printf ("[nand:] SYSNAND");
|
||||
printf ("\n(SysNAND FAT, ");
|
||||
printDriveBytes(nandSize);
|
||||
printf(")");
|
||||
printf(")\n");
|
||||
printDriveBytes(getBytesFree("nand:/"));
|
||||
printf(" space free");
|
||||
} else if (dmAssignedOp[dmCursorPosition] == 8) {
|
||||
printf ("[img:] FAT IMAGE");
|
||||
printf ("\n(Image FAT, ");
|
||||
|
||||
@ -42,41 +42,35 @@ u64 sdSize = 0;
|
||||
u64 fatSize = 0;
|
||||
u64 imgSize = 0;
|
||||
|
||||
static int getGbNumber(u64 bytes) {
|
||||
int gbNumber = 0;
|
||||
for (u64 i = 0; i <= bytes; i += 0x40000000) {
|
||||
gbNumber++;
|
||||
static float getGbNumber(u64 bytes) {
|
||||
float gbNumber = 0.0f;
|
||||
for (u64 i = 0; i <= bytes; i += 0x6666666) {
|
||||
gbNumber += 0.1f;
|
||||
}
|
||||
return gbNumber;
|
||||
}
|
||||
|
||||
static int getTbNumber(u64 bytes) {
|
||||
int tbNumber = 0;
|
||||
for (u64 i = 0; i <= bytes; i += 0x10000000000) {
|
||||
tbNumber++;
|
||||
static float getTbNumber(u64 bytes) {
|
||||
float tbNumber = 0.0f;
|
||||
for (u64 i = 0; i <= bytes; i += 0x1999999999) {
|
||||
tbNumber += 0.01f;
|
||||
}
|
||||
return tbNumber;
|
||||
}
|
||||
|
||||
void printDriveBytes(u64 bytes)
|
||||
{
|
||||
if (bytes == 1)
|
||||
iprintf("%d Byte", (int)bytes);
|
||||
|
||||
else if (bytes >= 0 && bytes < 1024)
|
||||
iprintf("%d Bytes", (int)bytes);
|
||||
|
||||
else if (bytes >= 1024 && bytes < (1024 * 1024))
|
||||
if (bytes < (1024 * 1024))
|
||||
printf("%d KB", (int)bytes / 1024);
|
||||
|
||||
else if (bytes >= (1024 * 1024) && bytes < (1024 * 1024 * 1024))
|
||||
printf("%d MB", (int)bytes / 1024 / 1024);
|
||||
|
||||
else if (bytes >= 0x40000000 && bytes < 0x10000000000)
|
||||
printf("%d GB", getGbNumber(bytes));
|
||||
printf("%.1f GB", getGbNumber(bytes));
|
||||
|
||||
else
|
||||
printf("%d TB", getTbNumber(bytes));
|
||||
printf("%.1f TB", getTbNumber(bytes));
|
||||
}
|
||||
|
||||
const char* getDrivePath(void) {
|
||||
@ -169,6 +163,12 @@ bool sdMount(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
u64 getBytesFree(const char* drivePath) {
|
||||
struct statvfs st;
|
||||
statvfs(drivePath, &st);
|
||||
return (u64)st.f_bsize * (u64)st.f_bavail;
|
||||
}
|
||||
|
||||
void sdUnmount(void) {
|
||||
fatUnmount("sd");
|
||||
sdLabel[0] = '\0';
|
||||
|
||||
@ -44,5 +44,6 @@ extern void ramdrive2Mount(void);
|
||||
extern void nitroUnmount(void);
|
||||
extern bool imgMount(const char* imgName);
|
||||
extern void imgUnmount(void);
|
||||
extern u64 getBytesFree(const char* drivePath);
|
||||
|
||||
#endif //FLASHCARD_H
|
||||
|
||||
Loading…
Reference in New Issue
Block a user