#include <unistd.h>
#include <sys/mman.h>
#include <errno.h>
+#include <sys/stat.h>
#include "../plat.h"
return 0;
}
-int plat_get_root_dir(char *dst, int len)
+static int plat_get_data_dir(char *dst, int len)
{
- int j, ret;
-
- ret = readlink("/proc/self/exe", dst, len - 1);
+#ifdef PICO_DATA_DIR
+ memcpy(dst, PICO_DATA_DIR, sizeof PICO_DATA_DIR);
+ return sizeof(PICO_DATA_DIR) - 1;
+#else
+ int j, ret = readlink("/proc/self/exe", dst, len - 1);
if (ret < 0) {
perror("readlink");
ret = 0;
}
dst[ret] = 0;
- for (j = strlen(dst); j > 0; j--)
+ for (j = ret - 1; j > 0; j--)
if (dst[j] == '/') {
dst[++j] = 0;
break;
}
-
return j;
+#endif
+}
+
+int plat_get_skin_dir(char *dst, int len)
+{
+ int ret = plat_get_data_dir(dst, len);
+ if (ret < 0)
+ return ret;
+
+ memcpy(dst + ret, "skin/", sizeof "skin/");
+ return ret + sizeof("skin/") - 1;
+}
+
+#ifndef PICO_HOME_DIR
+#define PICO_HOME_DIR "/.picodrive/"
+#endif
+int plat_get_root_dir(char *dst, int len)
+{
+#if defined(__GP2X__) || defined(PANDORA)
+ return plat_get_data_dir(dst, len);
+#else
+ char *home = getenv("HOME");
+ size_t nb = strlen(home);
+
+ memcpy(dst, home, nb);
+ memcpy(dst + nb, PICO_HOME_DIR, sizeof PICO_HOME_DIR);
+ mkdir(dst, 0755);
+ return nb + sizeof(PICO_HOME_DIR) - 1;
+#endif
}
#ifdef __GP2X__
\r
void menu_init_base(void)\r
{\r
- int i, c, l;\r
+ int i, c, l, pos;\r
unsigned char *fd, *fds;\r
char buff[256];\r
FILE *f;\r
}\r
\r
// load custom font and selector (stored as 1st symbol in font table)\r
- emu_make_path(buff, "skin/font.png", sizeof(buff));\r
+ pos = plat_get_skin_dir(buff, sizeof(buff));\r
+ strcpy(buff + pos, "font.png");\r
readpng(menu_font_data, buff, READPNG_FONT,\r
MENU_X2 ? 256 : 128, MENU_X2 ? 320 : 160);\r
// default selector symbol is '>'\r
memcpy(menu_font_data, menu_font_data + ((int)'>') * me_mfont_w * me_mfont_h / 2,\r
me_mfont_w * me_mfont_h / 2);\r
- emu_make_path(buff, "skin/selector.png", sizeof(buff));\r
+ strcpy(buff + pos, "selector.png");\r
readpng(menu_font_data, buff, READPNG_SELECTOR, me_mfont_w, me_mfont_h);\r
\r
// load custom colors\r
- emu_make_path(buff, "skin/skin.txt", sizeof(buff));\r
+ strcpy(buff + pos, "skin.txt");\r
f = fopen(buff, "r");\r
if (f != NULL)\r
{\r
/* return the dir/ where configs, saves, bios, etc. are found */
int plat_get_root_dir(char *dst, int len);
+/* return the dir/ where skin files are found */
+int plat_get_skin_dir(char *dst, int len);
+
int plat_is_dir(const char *path);
int plat_wait_event(int *fds_hnds, int count, int timeout_ms);
void plat_sleep_ms(int ms);