diff --git a/src/Backends/Misc.h b/src/Backends/Misc.h index b7be75d0..ece4bbae 100644 --- a/src/Backends/Misc.h +++ b/src/Backends/Misc.h @@ -89,7 +89,7 @@ enum bool Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(bool focus)); void Backend_Deinit(void); void Backend_PostWindowCreation(void); -bool Backend_GetBasePath(std::string *string_buffer); +bool Backend_GetPaths(std::string *module_path, std::string *data_path); void Backend_HideMouse(void); void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t height); void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height); diff --git a/src/Backends/Platform/3DS.cpp b/src/Backends/Platform/3DS.cpp index 78e0eea3..c684d761 100644 --- a/src/Backends/Platform/3DS.cpp +++ b/src/Backends/Platform/3DS.cpp @@ -5,6 +5,9 @@ #include #include +#include +#include + #include <3ds.h> bool Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(bool focus)) @@ -45,9 +48,17 @@ void Backend_PostWindowCreation(void) // Nothing to do here } -bool Backend_GetBasePath(std::string *string_buffer) +bool Backend_GetPaths(std::string *module_path, std::string *data_path) { - *string_buffer = "romfs:"; + // Create the CSE2 folder if it doesn't already exist + mkdir("sdmc:/3ds", 0777); + mkdir("sdmc:/3ds/cse2", 0777); + + // Configuration files and save data goes on the read-write SD card + *module_path = "sdmc:/3ds/cse2"; + + // Data goes in the read-only ROMFS + *data_path = "romfs:"; return true; } diff --git a/src/Main.cpp b/src/Main.cpp index b8b4aa17..f1301ca7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -106,8 +106,8 @@ int main(int argc, char *argv[]) if (!Backend_Init(DragAndDropCallback, WindowFocusCallback)) return EXIT_FAILURE; - // Get executable's path - if (!Backend_GetBasePath(&gModulePath)) + // Get executable's path, and path of the data folder + if (!Backend_GetPaths(&gModulePath, &gDataPath)) { // Fall back on argv[0] if the backend cannot provide a path gModulePath = argv[0]; @@ -120,10 +120,9 @@ int main(int argc, char *argv[]) break; } } - } - // Get path of the data folder - gDataPath = gModulePath + "/data"; + gDataPath = gModulePath + "/data"; + } CONFIGDATA conf; if (!LoadConfigData(&conf))