diff options
author | neonloop | 2023-01-22 20:50:00 +0000 |
---|---|---|
committer | neonloop | 2023-01-22 20:50:00 +0000 |
commit | 48f9bc6f61f8b93bad00c931b21b9b53e1154ed7 (patch) | |
tree | 69ca3ed41f1abae8debf7bbab1b8e6a01a763ceb | |
parent | 8aa3a79bbed36430f48466a3f7f1e5de7f5cd8af (diff) | |
download | picoarch-48f9bc6f61f8b93bad00c931b21b9b53e1154ed7.tar.gz picoarch-48f9bc6f61f8b93bad00c931b21b9b53e1154ed7.tar.bz2 picoarch-48f9bc6f61f8b93bad00c931b21b9b53e1154ed7.zip |
Moves save / config dir under .picoarch
Still uses old dir if exists to not need migration
-rw-r--r-- | README.funkey-s.md | 2 | ||||
-rw-r--r-- | core.c | 51 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | menu.c | 2 |
4 files changed, 44 insertions, 13 deletions
diff --git a/README.funkey-s.md b/README.funkey-s.md index 8a8410e..54fc104 100644 --- a/README.funkey-s.md +++ b/README.funkey-s.md @@ -1,6 +1,6 @@ # picoarch - a libretro frontend designed for small screens and low power -picoarch runs libretro cores (emulators) for various systems with low overhead and UI designed for small screen, low-powered devices like the Trimui Model S (PowKiddy A66) and Funkey S. +picoarch runs libretro cores (emulators) for various systems with low overhead and UI designed for small screen, low-powered devices like the Trimui Model S (PowKiddy A66) and FunKey S. It supports: @@ -1,4 +1,5 @@ #include <dlfcn.h> +#include <dirent.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -274,32 +275,62 @@ static void set_directories(const char *core_name) { #ifndef MINUI char cwd[MAX_PATH]; #endif + + char picoarch_root[MAX_PATH] = ""; + DIR* dir; + + /* Example: + * Old save / config dir: ~/.picoarch-gambatte + * New save / config dir: ~/.picoarch/data/gambatte + * System dir: ./system + * + * FunKey S: + * System dir: ~/.picoarch/system + * + * MinUI: + * Save / config dir: ~/.picoarch-gambatte + * System dir: ~/.picoarch-gambatte + */ if (home != NULL) { snprintf(dst, len, "%s/.picoarch-%s/", home, core_name); +#ifdef MINUI mkdir(dst, 0755); + strncpy(config_dir, save_dir, MAX_PATH-1); + strncpy(system_dir, save_dir, MAX_PATH-1); +#else + snprintf(picoarch_root, MAX_PATH, "%s/.picoarch", home); + mkdir(picoarch_root, 0755); + + dir = opendir(dst); + if (dir) { + /* Use old save dir if exists */ + closedir(dir); + } else { + snprintf(dst, len, "%s/data", picoarch_root); + mkdir(dst, 0755); + snprintf(dst, len, "%s/data/%s/", picoarch_root, core_name); + mkdir(dst, 0755); + } } strncpy(config_dir, save_dir, MAX_PATH-1); -#ifdef MINUI - strncpy(system_dir, save_dir, MAX_PATH-1); -#else - #ifdef FUNKEY_S - if (home != NULL) { - snprintf(system_dir, MAX_PATH, "%s/.picoarch", home); - mkdir(system_dir, 0755); - snprintf(system_dir, MAX_PATH, "%s/.picoarch/system", home); + if (strlen(picoarch_root)) { + snprintf(system_dir, MAX_PATH, "%s/system", picoarch_root); mkdir(system_dir, 0755); } else -#endif +#endif /* FUNKEY_S */ if (getcwd(cwd, MAX_PATH)) { snprintf(system_dir, MAX_PATH, "%s/system", cwd); mkdir(system_dir, 0755); } else { PA_FATAL("Can't find system directory"); } -#endif +#endif /* MINUI */ + PA_INFO("Config dir: %s\n", config_dir); + PA_INFO("Save dir: %s\n", save_dir); + PA_INFO("System dir: %s\n", system_dir); } static bool pa_environment(unsigned cmd, void *data) { @@ -393,7 +393,7 @@ void handle_emu_action(emu_action action) sram_write(); in_menu = true; #if defined(MMENU) - if (mmenu && content && content->path) { + if (mmenu && content && strlen(content->path)) { ShowMenu_t ShowMenu = (ShowMenu_t)dlsym(mmenu, "ShowMenu"); SDL_Surface *screen = SDL_GetVideoSurface(); MenuReturnStatus status = ShowMenu(content->path, state_allowed() ? save_template_path : NULL, screen, kMenuEventKeyDown); @@ -240,7 +240,7 @@ const char *select_content(void) { const char **exts_with_zip = NULL; int i = 0, size = 0; - if (content && content->path) { + if (content && strlen(content->path)) { strncpy(content_path, content->path, sizeof(content_path) - 1); } else if (getenv("CONTENT_DIR")) { strncpy(content_path, getenv("CONTENT_DIR"), sizeof(content_path) - 1); |