Add paths to config file
This commit is contained in:
@@ -30,6 +30,8 @@ Config_s config;
|
||||
|
||||
void load_config(void)
|
||||
{
|
||||
Handle test_handle;
|
||||
Result res;
|
||||
memset(&config, 0, sizeof(Config_s));
|
||||
char *json_buf = NULL;
|
||||
u32 json_len = file_to_buf(fsMakePath(PATH_ASCII, "/3ds/" APP_TITLE "/config.json"), ArchiveSD, &json_buf);
|
||||
@@ -95,6 +97,54 @@ void load_config(void)
|
||||
config.yellow_color = C2D_Color32(r, g, b, a);
|
||||
}
|
||||
}
|
||||
else if (json_is_string(value) && !strcmp(key, "Themes Path"))
|
||||
{
|
||||
bool need_slash = json_string_value(value)[strlen(json_string_value(value)) - 1] != '/';
|
||||
char *theme_path = calloc(1, strlen(json_string_value(value)) + 1 + (need_slash ? 1 : 0));
|
||||
memcpy(theme_path, json_string_value(value), strlen(json_string_value(value)));
|
||||
if (need_slash) theme_path[strlen(json_string_value(value))] = '/';
|
||||
if (R_SUCCEEDED(res = FSUSER_OpenDirectory(&test_handle, ArchiveSD, fsMakePath(PATH_ASCII, theme_path))))
|
||||
{
|
||||
main_paths[REMOTE_MODE_THEMES] = theme_path;
|
||||
FSDIR_Close(test_handle);
|
||||
} else
|
||||
{
|
||||
DEBUG("Failed test - reverting to default. Err 0x%08lx\n", res);
|
||||
free(theme_path);
|
||||
}
|
||||
}
|
||||
else if (json_is_string(value) && !strcmp(key, "Splashes Path"))
|
||||
{
|
||||
bool need_slash = json_string_value(value)[strlen(json_string_value(value)) - 1] != '/';
|
||||
char *splash_path = calloc(1, strlen(json_string_value(value)) + 1 + (need_slash ? 1 : 0));
|
||||
memcpy(splash_path, json_string_value(value), strlen(json_string_value(value)));
|
||||
if (need_slash) splash_path[strlen(json_string_value(value))] = '/';
|
||||
if (R_SUCCEEDED(res = FSUSER_OpenDirectory(&test_handle, ArchiveSD, fsMakePath(PATH_ASCII, splash_path))))
|
||||
{
|
||||
main_paths[REMOTE_MODE_SPLASHES] = splash_path;
|
||||
FSDIR_Close(test_handle);
|
||||
} else
|
||||
{
|
||||
DEBUG("Failed test - reverting to default. Err 0x%08lx\n", res);
|
||||
free(splash_path);
|
||||
}
|
||||
}
|
||||
else if (json_is_string(value) && !strcmp(key, "Badges Path"))
|
||||
{
|
||||
bool need_slash = json_string_value(value)[strlen(json_string_value(value)) - 1] != '/';
|
||||
char *badge_path = calloc(1, strlen(json_string_value(value)) + 1 + (need_slash ? 1 : 0));
|
||||
memcpy(badge_path, json_string_value(value), strlen(json_string_value(value)));
|
||||
if (need_slash) badge_path[strlen(json_string_value(value))] = '/';
|
||||
if (R_SUCCEEDED(res = FSUSER_OpenDirectory(&test_handle, ArchiveSD, fsMakePath(PATH_ASCII, badge_path))))
|
||||
{
|
||||
main_paths[REMOTE_MODE_BADGES] = badge_path;
|
||||
FSDIR_Close(test_handle);
|
||||
} else
|
||||
{
|
||||
DEBUG("Failed test - reverting to default. Err 0x%08lx\n", res);
|
||||
free(badge_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user