ref: 8d296f03850a2b981a90a6a62bb3663bd9effd4f
parent: f3ff030869f51d5bb77b5337593580906ff7d7e7
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sun Oct 11 11:58:48 EDT 2020
Allow backend to specify data folder On the 3DS, I want the data files to go in the read-only ROMFS, while save data goes on the SD card. This is impossible with the current system, so I'm changing it. The other backends will need updating to support this.
--- a/src/Backends/Misc.h
+++ b/src/Backends/Misc.h
@@ -89,7 +89,7 @@
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);
--- a/src/Backends/Platform/3DS.cpp
+++ b/src/Backends/Platform/3DS.cpp
@@ -5,6 +5,9 @@
#include <string.h>
#include <string>
+#include <sys/stat.h>
+#include <sys/types.h>
+
#include <3ds.h>
bool Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(bool focus))
@@ -45,9 +48,17 @@
// 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;
}
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -106,8 +106,8 @@
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 @@
break;
}
}
- }
- // Get path of the data folder
- gDataPath = gModulePath + "/data";
+ gDataPath = gModulePath + "/data";
+ }
CONFIGDATA conf;
if (!LoadConfigData(&conf))