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.
This commit is contained in:
parent
f3ff030869
commit
8d296f0385
3 changed files with 18 additions and 8 deletions
|
@ -89,7 +89,7 @@ enum
|
||||||
bool Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(bool focus));
|
bool Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(bool focus));
|
||||||
void Backend_Deinit(void);
|
void Backend_Deinit(void);
|
||||||
void Backend_PostWindowCreation(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_HideMouse(void);
|
||||||
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, size_t width, size_t height);
|
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);
|
void Backend_SetCursor(const unsigned char *rgba_pixels, size_t width, size_t height);
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
|
|
||||||
bool Backend_Init(void (*drag_and_drop_callback)(const char *path), void (*window_focus_callback)(bool focus))
|
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
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,8 +106,8 @@ int main(int argc, char *argv[])
|
||||||
if (!Backend_Init(DragAndDropCallback, WindowFocusCallback))
|
if (!Backend_Init(DragAndDropCallback, WindowFocusCallback))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// Get executable's path
|
// Get executable's path, and path of the data folder
|
||||||
if (!Backend_GetBasePath(&gModulePath))
|
if (!Backend_GetPaths(&gModulePath, &gDataPath))
|
||||||
{
|
{
|
||||||
// Fall back on argv[0] if the backend cannot provide a path
|
// Fall back on argv[0] if the backend cannot provide a path
|
||||||
gModulePath = argv[0];
|
gModulePath = argv[0];
|
||||||
|
@ -120,10 +120,9 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Get path of the data folder
|
|
||||||
gDataPath = gModulePath + "/data";
|
gDataPath = gModulePath + "/data";
|
||||||
|
}
|
||||||
|
|
||||||
CONFIGDATA conf;
|
CONFIGDATA conf;
|
||||||
if (!LoadConfigData(&conf))
|
if (!LoadConfigData(&conf))
|
||||||
|
|
Loading…
Add table
Reference in a new issue