From 4729646e8df941b1018d3e31d0d27009ac50b8cc Mon Sep 17 00:00:00 2001 From: JeffRuLz Date: Wed, 26 Jun 2019 20:26:57 -0500 Subject: [PATCH] 0.7.0 --- arm9/src/installmenu.c | 7 ++++++- arm9/src/main.c | 2 +- arm9/src/storage.c | 38 +++++++++++++++++--------------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/arm9/src/installmenu.c b/arm9/src/installmenu.c index 2aeb64b..cf443e6 100644 --- a/arm9/src/installmenu.c +++ b/arm9/src/installmenu.c @@ -148,7 +148,12 @@ static void generateList(Menu* m) bool done = false; struct dirent* ent; - DIR* dir = opendir(currentDir); + DIR* dir = NULL; + + if (currentDir[0] == '\0') + dir = opendir("/"); + else + dir = opendir(currentDir); if (dir) { diff --git a/arm9/src/main.c b/arm9/src/main.c index 6eb2952..b521b31 100644 --- a/arm9/src/main.c +++ b/arm9/src/main.c @@ -3,7 +3,7 @@ #include "message.h" #include -#define VERSION "0.6.8.1" +#define VERSION "0.7.0" enum { MAIN_MENU_INSTALL, diff --git a/arm9/src/storage.c b/arm9/src/storage.c index ad8a2b9..4dd9118 100644 --- a/arm9/src/storage.c +++ b/arm9/src/storage.c @@ -504,33 +504,29 @@ unsigned long long getSDCardFree() unsigned long long getDsiSize() { //The DSi has 256MB of internal storage. Some is unavailable and used by other things. - //Find a better way to do this - return 240 * 1024 * 1024; + //An empty DSi reads 1024 open blocks + return 1024 * BYTES_PER_BLOCK; } unsigned long long getDsiFree() { //Get free space by subtracting file sizes in emulated nand folders - //Find a better way to do this - long long size = getDsiSize(); + unsigned long long size = getDsiSize(); + unsigned long long appSize = getDirSize("/title/00030004"); - size -= getDirSize("/sys"); - size -= getDirSize("/title/0003000f"); - size -= getDirSize("/title/00030004"); - size -= getDirSize("/title/00030005"); - size -= getDirSize("/title/00030017"); - size -= getDirSize("/ticket"); - size -= getDirSize("/shared1"); - size -= getDirSize("/shared2"); - size -= getDirSize("/import"); - size -= getDirSize("/tmp"); - size -= getDirSize("/progress"); + //round up to a full block + if (appSize % BYTES_PER_BLOCK != 0) + appSize = ((int)(appSize / BYTES_PER_BLOCK) * BYTES_PER_BLOCK) + BYTES_PER_BLOCK; - size -= getDirSize("/photo"); - size -= getDirSize("/private"); - - if (size < 0) - return 0; + //subtract, but don't go under 0 + if (appSize > size) + { + size = 0; + } + else + { + size -= appSize; + } - return (unsigned long long)size; + return size; } \ No newline at end of file