Mercurial > repos > blastem
diff paths.c @ 2477:2972a8e16ed2
Make sticky_path respect save config with EXE option
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 05 Mar 2024 23:23:06 -0800 |
parents | bc68560b4a04 |
children | c4256ce2c45a |
line wrap: on
line diff
--- a/paths.c Sun Mar 03 13:47:59 2024 -0800 +++ b/paths.c Tue Mar 05 23:23:06 2024 -0800 @@ -2,6 +2,8 @@ #include <stdlib.h> #include "blastem.h" #include "util.h" +#include "config.h" +#include "paths.h" #ifdef _WIN32 #include <windows.h> #else @@ -11,9 +13,18 @@ static char **current_path; +static char *sticky_path_path(void) +{ + if (is_config_in_exe_dir(config)) { + return path_append(get_exe_dir(), "sticky_path"); + } else { + return path_append(get_config_dir(), "sticky_path"); + } +} + static void persist_path(void) { - char *pathfname = alloc_concat(get_userdata_dir(), PATH_SEP "blastem" PATH_SEP "sticky_path"); + char *pathfname = sticky_path_path(); FILE *f = fopen(pathfname, "wb"); if (f) { if (fwrite(*current_path, 1, strlen(*current_path), f) != strlen(*current_path)) { @@ -68,7 +79,7 @@ char *base = NULL; char *remember_path = tern_find_path(config, "ui\0remember_path\0", TVAL_PTR).ptrval; if (!remember_path || !strcmp("on", remember_path)) { - char *pathfname = alloc_concat(get_userdata_dir(), PATH_SEP "blastem" PATH_SEP "sticky_path"); + char *pathfname = sticky_path_path(); FILE *f = fopen(pathfname, "rb"); if (f) { long pathsize = file_size(f);