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 "date.h"
|
||||||
#include "screenshot.h"
|
#include "screenshot.h"
|
||||||
#include "driveOperations.h"
|
#include "driveOperations.h"
|
||||||
|
#include "fileOperations.h"
|
||||||
|
|
||||||
#define SCREEN_COLS 32
|
#define SCREEN_COLS 32
|
||||||
#define ENTRIES_PER_SCREEN 22
|
#define ENTRIES_PER_SCREEN 22
|
||||||
@ -216,13 +217,17 @@ void dm_drawBottomScreen(void) {
|
|||||||
if (sdLabel[0] != '\0') {
|
if (sdLabel[0] != '\0') {
|
||||||
iprintf (" (%s)", sdLabel);
|
iprintf (" (%s)", sdLabel);
|
||||||
}
|
}
|
||||||
printf ("\n(SD FAT)");
|
printf ("\n(SD FAT, ");
|
||||||
|
printBytes(sdSize);
|
||||||
|
printf(")");
|
||||||
} else if (dmAssignedOp[dmCursorPosition] == 1) {
|
} else if (dmAssignedOp[dmCursorPosition] == 1) {
|
||||||
printf ("[fat:] FLASHCART");
|
printf ("[fat:] FLASHCART");
|
||||||
if (fatLabel[0] != '\0') {
|
if (fatLabel[0] != '\0') {
|
||||||
iprintf (" (%s)", fatLabel);
|
iprintf (" (%s)", fatLabel);
|
||||||
}
|
}
|
||||||
printf ("\n(Slot-1 SD FAT)");
|
printf ("\n(Slot-1 SD FAT, ", fatSize);
|
||||||
|
printBytes(fatSize);
|
||||||
|
printf(")");
|
||||||
} else if (dmAssignedOp[dmCursorPosition] == 2) {
|
} else if (dmAssignedOp[dmCursorPosition] == 2) {
|
||||||
printf ("GBA GAMECART\n");
|
printf ("GBA GAMECART\n");
|
||||||
printf ("(GBA Game)");
|
printf ("(GBA Game)");
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#include <nds/arm9/dldi.h>
|
#include <nds/arm9/dldi.h>
|
||||||
#include <fat.h>
|
#include <fat.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -24,6 +25,9 @@ bool nitroSecondaryDrive = false; // false == SD card, true == Flashcard
|
|||||||
char sdLabel[12];
|
char sdLabel[12];
|
||||||
char fatLabel[12];
|
char fatLabel[12];
|
||||||
|
|
||||||
|
int sdSize = 0;
|
||||||
|
int fatSize = 0;
|
||||||
|
|
||||||
void fixLabel(bool fat) {
|
void fixLabel(bool fat) {
|
||||||
if (fat) {
|
if (fat) {
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
@ -76,6 +80,10 @@ TWL_CODE bool sdMount(void) {
|
|||||||
sdMountedDone = true;
|
sdMountedDone = true;
|
||||||
fatGetVolumeLabel("sd", sdLabel);
|
fatGetVolumeLabel("sd", sdLabel);
|
||||||
fixLabel(false);
|
fixLabel(false);
|
||||||
|
struct statvfs st;
|
||||||
|
if (statvfs("sd:/", &st) == 0) {
|
||||||
|
sdSize = st.f_bsize * st.f_blocks;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -84,6 +92,7 @@ TWL_CODE bool sdMount(void) {
|
|||||||
TWL_CODE void sdUnmount(void) {
|
TWL_CODE void sdUnmount(void) {
|
||||||
fatUnmount("sd");
|
fatUnmount("sd");
|
||||||
sdLabel[0] = '\0';
|
sdLabel[0] = '\0';
|
||||||
|
sdSize = 0;
|
||||||
sdMounted = false;
|
sdMounted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,6 +219,10 @@ TWL_CODE bool twl_flashcardMount(void) {
|
|||||||
if (flashcardFound()) {
|
if (flashcardFound()) {
|
||||||
fatGetVolumeLabel("fat", fatLabel);
|
fatGetVolumeLabel("fat", fatLabel);
|
||||||
fixLabel(true);
|
fixLabel(true);
|
||||||
|
struct statvfs st;
|
||||||
|
if (statvfs("fat:/", &st) == 0) {
|
||||||
|
fatSize = st.f_bsize * st.f_blocks;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,6 +235,10 @@ bool flashcardMount(void) {
|
|||||||
if (flashcardFound()) {
|
if (flashcardFound()) {
|
||||||
fatGetVolumeLabel("fat", fatLabel);
|
fatGetVolumeLabel("fat", fatLabel);
|
||||||
fixLabel(true);
|
fixLabel(true);
|
||||||
|
struct statvfs st;
|
||||||
|
if (statvfs("fat:/", &st) == 0) {
|
||||||
|
fatSize = st.f_bsize * st.f_blocks;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -233,5 +250,6 @@ bool flashcardMount(void) {
|
|||||||
void flashcardUnmount(void) {
|
void flashcardUnmount(void) {
|
||||||
fatUnmount("fat");
|
fatUnmount("fat");
|
||||||
fatLabel[0] = '\0';
|
fatLabel[0] = '\0';
|
||||||
|
fatSize = 0;
|
||||||
flashcardMounted = false;
|
flashcardMounted = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,9 @@ extern bool nitroSecondaryDrive; // false == SD card, true == Flashcard
|
|||||||
extern char sdLabel[12];
|
extern char sdLabel[12];
|
||||||
extern char fatLabel[12];
|
extern char fatLabel[12];
|
||||||
|
|
||||||
|
extern int sdSize;
|
||||||
|
extern int fatSize;
|
||||||
|
|
||||||
extern bool sdFound(void);
|
extern bool sdFound(void);
|
||||||
extern bool flashcardFound(void);
|
extern bool flashcardFound(void);
|
||||||
extern bool bothSDandFlashcard(void);
|
extern bool bothSDandFlashcard(void);
|
||||||
|
|||||||
@ -20,6 +20,21 @@ bool clipboardUsed = false;
|
|||||||
bool clipboardDrive = false; // false == SD card, true == Flashcard
|
bool clipboardDrive = false; // false == SD card, true == Flashcard
|
||||||
bool clipboardInNitro = false;
|
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)
|
off_t getFileSize(const char *fileName)
|
||||||
{
|
{
|
||||||
FILE* fp = fopen(fileName, "rb");
|
FILE* fp = fopen(fileName, "rb");
|
||||||
|
|||||||
@ -11,6 +11,8 @@ extern bool clipboardUsed;
|
|||||||
extern bool clipboardDrive; // false == SD card, true == Flashcard
|
extern bool clipboardDrive; // false == SD card, true == Flashcard
|
||||||
extern bool clipboardInNitro;
|
extern bool clipboardInNitro;
|
||||||
|
|
||||||
|
extern void printBytes(int bytes);
|
||||||
|
|
||||||
extern off_t getFileSize(const char *fileName);
|
extern off_t getFileSize(const char *fileName);
|
||||||
extern int fcopy(const char *sourcePath, const char *destinationPath);
|
extern int fcopy(const char *sourcePath, const char *destinationPath);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user