Merge pull request #12659 from jdgleaver/rs90-appdata-sd
(RS-90) Move appdata (retroarch) base directory to external microsd card
This commit is contained in:
commit
2ea76c6188
|
@ -17,12 +17,13 @@
|
||||||
|
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <streams/file_stream.h>
|
#include <streams/file_stream.h>
|
||||||
|
|
||||||
#if defined(DINGUX_BETA)
|
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
#include <stdlib.h>
|
#if defined(RS90)
|
||||||
|
#include <lists/dir_list.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "dingux_utils.h"
|
#include "dingux_utils.h"
|
||||||
|
|
||||||
#define DINGUX_ALLOW_DOWNSCALING_FILE "/sys/devices/platform/jz-lcd.0/allow_downscaling"
|
#define DINGUX_ALLOW_DOWNSCALING_FILE "/sys/devices/platform/jz-lcd.0/allow_downscaling"
|
||||||
|
@ -32,6 +33,14 @@
|
||||||
#define DINGUX_SHARPNESS_DOWNSCALING_FILE "/sys/devices/platform/jz-lcd.0/sharpness_downscaling"
|
#define DINGUX_SHARPNESS_DOWNSCALING_FILE "/sys/devices/platform/jz-lcd.0/sharpness_downscaling"
|
||||||
#define DINGUX_BATTERY_CAPACITY_FILE "/sys/class/power_supply/battery/capacity"
|
#define DINGUX_BATTERY_CAPACITY_FILE "/sys/class/power_supply/battery/capacity"
|
||||||
|
|
||||||
|
/* Base path defines */
|
||||||
|
#define DINGUX_HOME_ENVAR "HOME"
|
||||||
|
#define DINGUX_BASE_DIR "retroarch"
|
||||||
|
#define DINGUX_BASE_DIR_HIDDEN ".retroarch"
|
||||||
|
#define DINGUX_RS90_MEDIA_PATH "/media"
|
||||||
|
#define DINGUX_RS90_DEFAULT_SD_PATH "/media/mmcblk0p1"
|
||||||
|
#define DINGUX_RS90_DATA_PATH "/media/data"
|
||||||
|
|
||||||
/* OpenDingux Beta defines */
|
/* OpenDingux Beta defines */
|
||||||
#define DINGUX_BATTERY_VOLTAGE_MIN "/sys/class/power_supply/jz-battery/voltage_min_design"
|
#define DINGUX_BATTERY_VOLTAGE_MIN "/sys/class/power_supply/jz-battery/voltage_min_design"
|
||||||
#define DINGUX_BATTERY_VOLTAGE_MAX "/sys/class/power_supply/jz-battery/voltage_max_design"
|
#define DINGUX_BATTERY_VOLTAGE_MAX "/sys/class/power_supply/jz-battery/voltage_max_design"
|
||||||
|
@ -302,3 +311,80 @@ int dingux_get_battery_level(void)
|
||||||
return dingux_read_battery_sys_file(DINGUX_BATTERY_CAPACITY_FILE);
|
return dingux_read_battery_sys_file(DINGUX_BATTERY_CAPACITY_FILE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fetches the path of the base 'retroarch'
|
||||||
|
* directory */
|
||||||
|
void dingux_get_base_path(char *path, size_t len)
|
||||||
|
{
|
||||||
|
const char *home = NULL;
|
||||||
|
#if defined(RS90)
|
||||||
|
struct string_list *dir_list = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!path || (len < 1))
|
||||||
|
return;
|
||||||
|
|
||||||
|
#if defined(RS90)
|
||||||
|
/* The RS-90 home directory is located on the
|
||||||
|
* device's internal storage. This has limited
|
||||||
|
* space (a total of only 256MB), such that it
|
||||||
|
* is impractical to store cores and user files
|
||||||
|
* here. We therefore attempt to use a base
|
||||||
|
* path on the external microsd card */
|
||||||
|
|
||||||
|
/* Get list of directories in /media */
|
||||||
|
dir_list = dir_list_new(DINGUX_RS90_MEDIA_PATH,
|
||||||
|
NULL, true, true, false, false);
|
||||||
|
|
||||||
|
if (dir_list)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
bool path_found = false;
|
||||||
|
|
||||||
|
for (i = 0; i < dir_list->size; i++)
|
||||||
|
{
|
||||||
|
const char *dir_path = dir_list->elems[i].data;
|
||||||
|
int dir_type = dir_list->elems[i].attr.i;
|
||||||
|
|
||||||
|
/* Skip files and invalid entries */
|
||||||
|
if ((dir_type != RARCH_DIRECTORY) ||
|
||||||
|
string_is_empty(dir_path) ||
|
||||||
|
string_is_equal(dir_path, DINGUX_RS90_DATA_PATH))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Build 'retroarch' subdirectory path */
|
||||||
|
snprintf(path, len, "%s%c%s", dir_path,
|
||||||
|
PATH_DEFAULT_SLASH_C(), DINGUX_BASE_DIR);
|
||||||
|
|
||||||
|
/* We can use this subdirectory path if:
|
||||||
|
* - Directory corresponds to an unlabelled
|
||||||
|
* microsd card
|
||||||
|
* - Subdirectory already exists */
|
||||||
|
if (string_is_equal(dir_path, DINGUX_RS90_DEFAULT_SD_PATH) ||
|
||||||
|
path_is_directory(path))
|
||||||
|
{
|
||||||
|
path_found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dir_list_free(dir_list);
|
||||||
|
|
||||||
|
if (path_found)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* Get home directory */
|
||||||
|
home = getenv(DINGUX_HOME_ENVAR);
|
||||||
|
|
||||||
|
/* If a home directory is found (which should
|
||||||
|
* always be the case), base path is "$HOME/.retroarch"
|
||||||
|
* > If home path is unset, use existing UNIX frontend
|
||||||
|
* driver default of "retroarch" (this will ultimately
|
||||||
|
* fail, but there is nothing else we can do...) */
|
||||||
|
if (home)
|
||||||
|
snprintf(path, len, "%s%c%s", home,
|
||||||
|
PATH_DEFAULT_SLASH_C(), DINGUX_BASE_DIR_HIDDEN);
|
||||||
|
else
|
||||||
|
strlcpy(path, DINGUX_BASE_DIR, len);
|
||||||
|
}
|
||||||
|
|
|
@ -101,6 +101,10 @@ bool dingux_ipu_reset(void);
|
||||||
/* Fetches internal battery level */
|
/* Fetches internal battery level */
|
||||||
int dingux_get_battery_level(void);
|
int dingux_get_battery_level(void);
|
||||||
|
|
||||||
|
/* Fetches the path of the base 'retroarch'
|
||||||
|
* directory */
|
||||||
|
void dingux_get_base_path(char *path, size_t len);
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,6 +37,10 @@
|
||||||
#include <kernel/image.h>
|
#include <kernel/image.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(DINGUX)
|
||||||
|
#include "dingux/dingux_utils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -104,13 +108,8 @@ bool fill_pathname_application_data(char *s, size_t len)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#elif defined(DINGUX)
|
#elif defined(DINGUX)
|
||||||
const char *appdata = getenv("HOME");
|
dingux_get_base_path(s, len);
|
||||||
|
|
||||||
if (appdata)
|
|
||||||
{
|
|
||||||
fill_pathname_join(s, appdata, "/.retroarch", len);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
#elif !defined(RARCH_CONSOLE)
|
#elif !defined(RARCH_CONSOLE)
|
||||||
const char *xdg = getenv("XDG_CONFIG_HOME");
|
const char *xdg = getenv("XDG_CONFIG_HOME");
|
||||||
const char *appdata = getenv("HOME");
|
const char *appdata = getenv("HOME");
|
||||||
|
|
|
@ -1792,6 +1792,9 @@ static void frontend_unix_get_env(int *argc,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
char base_path[PATH_MAX] = {0};
|
char base_path[PATH_MAX] = {0};
|
||||||
|
#if defined(DINGUX)
|
||||||
|
dingux_get_base_path(base_path, sizeof(base_path));
|
||||||
|
#else
|
||||||
const char *xdg = getenv("XDG_CONFIG_HOME");
|
const char *xdg = getenv("XDG_CONFIG_HOME");
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
|
|
||||||
|
@ -1803,14 +1806,11 @@ static void frontend_unix_get_env(int *argc,
|
||||||
else if (home)
|
else if (home)
|
||||||
{
|
{
|
||||||
strlcpy(base_path, home, sizeof(base_path));
|
strlcpy(base_path, home, sizeof(base_path));
|
||||||
#if defined(DINGUX)
|
|
||||||
strlcat(base_path, "/.retroarch", sizeof(base_path));
|
|
||||||
#else
|
|
||||||
strlcat(base_path, "/.config/retroarch", sizeof(base_path));
|
strlcat(base_path, "/.config/retroarch", sizeof(base_path));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strcpy_literal(base_path, "retroarch");
|
strcpy_literal(base_path, "retroarch");
|
||||||
|
#endif
|
||||||
|
|
||||||
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path,
|
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path,
|
||||||
"cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
"cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]));
|
||||||
|
@ -2154,10 +2154,14 @@ static int frontend_unix_parse_drive_list(void *data, bool load_content)
|
||||||
#else
|
#else
|
||||||
char base_path[PATH_MAX] = {0};
|
char base_path[PATH_MAX] = {0};
|
||||||
char udisks_media_path[PATH_MAX] = {0};
|
char udisks_media_path[PATH_MAX] = {0};
|
||||||
const char *xdg = getenv("XDG_CONFIG_HOME");
|
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
const char *user = getenv("USER");
|
const char *user = getenv("USER");
|
||||||
|
|
||||||
|
#if defined(DINGUX)
|
||||||
|
dingux_get_base_path(base_path, sizeof(base_path));
|
||||||
|
#else
|
||||||
|
const char *xdg = getenv("XDG_CONFIG_HOME");
|
||||||
|
|
||||||
if (xdg)
|
if (xdg)
|
||||||
{
|
{
|
||||||
strlcpy(base_path, xdg, sizeof(base_path));
|
strlcpy(base_path, xdg, sizeof(base_path));
|
||||||
|
@ -2166,12 +2170,9 @@ static int frontend_unix_parse_drive_list(void *data, bool load_content)
|
||||||
else if (home)
|
else if (home)
|
||||||
{
|
{
|
||||||
strlcpy(base_path, home, sizeof(base_path));
|
strlcpy(base_path, home, sizeof(base_path));
|
||||||
#if defined(DINGUX)
|
|
||||||
strlcat(base_path, "/.retroarch", sizeof(base_path));
|
|
||||||
#else
|
|
||||||
strlcat(base_path, "/.config/retroarch", sizeof(base_path));
|
strlcat(base_path, "/.config/retroarch", sizeof(base_path));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
strlcpy(udisks_media_path, "/run/media", sizeof(udisks_media_path));
|
strlcpy(udisks_media_path, "/run/media", sizeof(udisks_media_path));
|
||||||
if (user)
|
if (user)
|
||||||
|
|
Loading…
Reference in New Issue