diff --git a/include/arm11/menu_fb3ds.h b/include/arm11/menu_fb3ds.h index 42a0398..a237c1b 100644 --- a/include/arm11/menu_fb3ds.h +++ b/include/arm11/menu_fb3ds.h @@ -125,10 +125,11 @@ } }, { // 7 - "Miscellaneous", 2, + "Miscellaneous", 3, { { "Update fastboot3DS", DESC_UPDATE, &DummyFunc, 1 }, - { "Credits", DESC_CREDITS, &ShowCredits, 0 } + { "Credits", DESC_CREDITS, &ShowCredits, 0 }, + { "View current settings", "View current settings", &SetView, 0 } } } }; diff --git a/include/arm11/menu_func.h b/include/arm11/menu_func.h index 2da0f2e..f779825 100644 --- a/include/arm11/menu_func.h +++ b/include/arm11/menu_func.h @@ -21,4 +21,5 @@ #include "types.h" u32 DummyFunc(PrintConsole* con, u32 param); +u32 SetView(PrintConsole* con, u32 param); u32 ShowCredits(PrintConsole* con, u32 param); diff --git a/source/arm11/config.c b/source/arm11/config.c index 90f93d9..0d0de2b 100644 --- a/source/arm11/config.c +++ b/source/arm11/config.c @@ -148,7 +148,7 @@ if(fileSize > MAX_FILE_SIZE) { - //uiPrintIfVerbose("Invalid config-file size!\n"); + ee_printf("Invalid config-file size!\n"); goto fail; } @@ -156,19 +156,19 @@ if(!filebuf) { - //uiPrintIfVerbose("Out of memory!\n"); + ee_printf("Out of memory!\n"); goto fail; } if((file = fOpen(filepath, FS_OPEN_READ)) < 0) { - //uiPrintIfVerbose("Failed to open config-file for reading!\n"); + ee_printf("Failed to open config-file for reading!\n"); goto fail; } - if(fRead(file, filebuf, fileSize) != (s32) fileSize) + if(fRead(file, filebuf, fileSize) != FR_OK) { - //uiPrintIfVerbose("Failed to read from config-file!\n"); + ee_printf("Failed to read from config-file!\n"); fClose(file); goto fail; } @@ -237,7 +237,7 @@ if(fileSize) { - if(fWrite(file, filebuf, fileSize) != (s32) fileSize) + if(fWrite(file, filebuf, fileSize) != 0) { fClose(file); goto fail; @@ -361,7 +361,7 @@ } else { // TODO: what to do if ret == false ? - ////uiPrintIfVerbose("Parsing attr text with size %i\n%s\n", curAttr->textLength, curAttr->textData); + //ee_printf("Parsing attr text with size %i\n%s\n", curAttr->textLength, curAttr->textData); keyFunctions[i].parse(curAttr); } } diff --git a/source/arm11/fsutils.c b/source/arm11/fsutils.c index 30698da..8e44f98 100644 --- a/source/arm11/fsutils.c +++ b/source/arm11/fsutils.c @@ -86,16 +86,20 @@ s32 fhandle; FILINFO fno; + /* memory check */ + if (!tempBuf) + { + return false; // out of memory + } + /* create directories */ for (char *p = (char*) filepath; *p; p++) { if ((*p == '/') || (*p == '\\')) { *tempPtr = '\0'; - if (fStat(tempBuf, &fno) == 0) - { - if (!(fno.fattrib & AM_DIR)) goto fail; - } + s32 dhandle = fOpenDir(tempBuf); + if (dhandle >= 0) fCloseDir(dhandle); else if (fMkdir(tempBuf) != 0) goto fail; } *(tempPtr++) = *p; @@ -108,7 +112,7 @@ if (fno.fattrib & AM_DIR) goto fail; } - fhandle = fOpen(tempPtr, FS_CREATE_ALWAYS); + fhandle = fOpen(tempBuf, FS_CREATE_ALWAYS); if (fhandle < 0) goto fail; fClose(fhandle); @@ -117,7 +121,7 @@ return true; fail: - + free(tempBuf); return false; diff --git a/source/arm11/main.c b/source/arm11/main.c index e8ef697..5bc8723 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -29,9 +29,11 @@ #include "arm11/menu_fb3ds.h" #include "arm11/console.h" #include "arm11/fmt.h" +#include "arm11/fsutils.h" +#include "arm11/config.h" -volatile bool g_poweroffAllowed = false; +volatile bool g_poweroffAllowed = true; volatile bool g_startFirmLaunch = false; @@ -39,6 +41,11 @@ int main(void) { hardwareInit(); + + fsMountSdmc(); + fsMountNandFilesystems(); + loadConfigFile(); + // configRestoreDefaults(); GFX_init(); @@ -52,6 +59,9 @@ // run menu menuProcess(&menu_con, &desc_con, menu_fb3ds); + + // take over any changes to the config + writeConfigFile(); // power off if(g_poweroffAllowed) power_off(); diff --git a/source/arm11/menu_func.c b/source/arm11/menu_func.c index 89f35de..4553f96 100644 --- a/source/arm11/menu_func.c +++ b/source/arm11/menu_func.c Binary files differ