mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Show size of SD and flashcards in [root] menu
Credit to @JeffRuLz for the printBytes code and size grabbing code from TMFH
This commit is contained in:
parent
cf745d9ee1
commit
d855c84773
@ -30,6 +30,7 @@
|
||||
#include "date.h"
|
||||
#include "screenshot.h"
|
||||
#include "driveOperations.h"
|
||||
#include "fileOperations.h"
|
||||
|
||||
#define SCREEN_COLS 32
|
||||
#define ENTRIES_PER_SCREEN 22
|
||||
@ -216,13 +217,17 @@ void dm_drawBottomScreen(void) {
|
||||
if (sdLabel[0] != '\0') {
|
||||
iprintf (" (%s)", sdLabel);
|
||||
}
|
||||
printf ("\n(SD FAT)");
|
||||
printf ("\n(SD FAT, ");
|
||||
printBytes(sdSize);
|
||||
printf(")");
|
||||
} else if (dmAssignedOp[dmCursorPosition] == 1) {
|
||||
printf ("[fat:] FLASHCART");
|
||||
if (fatLabel[0] != '\0') {
|
||||
iprintf (" (%s)", fatLabel);
|
||||
}
|
||||
printf ("\n(Slot-1 SD FAT)");
|
||||
printf ("\n(Slot-1 SD FAT, ", fatSize);
|
||||
printBytes(fatSize);
|
||||
printf(")");
|
||||
} else if (dmAssignedOp[dmCursorPosition] == 2) {
|
||||
printf ("GBA GAMECART\n");
|
||||
printf ("(GBA Game)");
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include <nds/arm9/dldi.h>
|
||||
#include <fat.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "main.h"
|
||||
@ -24,6 +25,9 @@ bool nitroSecondaryDrive = false; // false == SD card, true == Flashcard
|
||||
char sdLabel[12];
|
||||
char fatLabel[12];
|
||||
|
||||
int sdSize = 0;
|
||||
int fatSize = 0;
|
||||
|
||||
void fixLabel(bool fat) {
|
||||
if (fat) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
@ -76,6 +80,10 @@ TWL_CODE bool sdMount(void) {
|
||||
sdMountedDone = true;
|
||||
fatGetVolumeLabel("sd", sdLabel);
|
||||
fixLabel(false);
|
||||
struct statvfs st;
|
||||
if (statvfs("sd:/", &st) == 0) {
|
||||
sdSize = st.f_bsize * st.f_blocks;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -84,6 +92,7 @@ TWL_CODE bool sdMount(void) {
|
||||
TWL_CODE void sdUnmount(void) {
|
||||
fatUnmount("sd");
|
||||
sdLabel[0] = '\0';
|
||||
sdSize = 0;
|
||||
sdMounted = false;
|
||||
}
|
||||
|
||||
@ -210,6 +219,10 @@ TWL_CODE bool twl_flashcardMount(void) {
|
||||
if (flashcardFound()) {
|
||||
fatGetVolumeLabel("fat", fatLabel);
|
||||
fixLabel(true);
|
||||
struct statvfs st;
|
||||
if (statvfs("fat:/", &st) == 0) {
|
||||
fatSize = st.f_bsize * st.f_blocks;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -222,6 +235,10 @@ bool flashcardMount(void) {
|
||||
if (flashcardFound()) {
|
||||
fatGetVolumeLabel("fat", fatLabel);
|
||||
fixLabel(true);
|
||||
struct statvfs st;
|
||||
if (statvfs("fat:/", &st) == 0) {
|
||||
fatSize = st.f_bsize * st.f_blocks;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -233,5 +250,6 @@ bool flashcardMount(void) {
|
||||
void flashcardUnmount(void) {
|
||||
fatUnmount("fat");
|
||||
fatLabel[0] = '\0';
|
||||
fatSize = 0;
|
||||
flashcardMounted = false;
|
||||
}
|
||||
|
||||
@ -14,6 +14,9 @@ extern bool nitroSecondaryDrive; // false == SD card, true == Flashcard
|
||||
extern char sdLabel[12];
|
||||
extern char fatLabel[12];
|
||||
|
||||
extern int sdSize;
|
||||
extern int fatSize;
|
||||
|
||||
extern bool sdFound(void);
|
||||
extern bool flashcardFound(void);
|
||||
extern bool bothSDandFlashcard(void);
|
||||
|
||||
@ -20,6 +20,21 @@ bool clipboardUsed = false;
|
||||
bool clipboardDrive = false; // false == SD card, true == Flashcard
|
||||
bool clipboardInNitro = false;
|
||||
|
||||
void printBytes(int bytes)
|
||||
{
|
||||
if (abs(bytes) < 1024)
|
||||
iprintf("%d B", bytes);
|
||||
|
||||
else if (abs(bytes) < 1024 * 1024)
|
||||
printf("%.1f KB", (float)bytes / 1024);
|
||||
|
||||
else if (abs(bytes) < 1024 * 1024 * 1024)
|
||||
printf("%.1f MB", (float)bytes / 1024 / 1024);
|
||||
|
||||
else
|
||||
printf("%.1f GB", (float)bytes / 1024 / 1024 / 1024);
|
||||
}
|
||||
|
||||
off_t getFileSize(const char *fileName)
|
||||
{
|
||||
FILE* fp = fopen(fileName, "rb");
|
||||
|
||||
@ -11,6 +11,8 @@ extern bool clipboardUsed;
|
||||
extern bool clipboardDrive; // false == SD card, true == Flashcard
|
||||
extern bool clipboardInNitro;
|
||||
|
||||
extern void printBytes(int bytes);
|
||||
|
||||
extern off_t getFileSize(const char *fileName);
|
||||
extern int fcopy(const char *sourcePath, const char *destinationPath);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user