comparison paths.c @ 1673:ab3b465c052c

Fix Windows implentation of get_config_dir() so config file gets saved to the right place. Fix location for sticky_path file on all platforms
author Michael Pavone <pavone@retrodev.com>
date Thu, 03 Jan 2019 19:30:41 -0800
parents b96f9fae757f
children dda7479f3bbb
comparison
equal deleted inserted replaced
1672:12d0c7c4ad80 1673:ab3b465c052c
5 5
6 static char **current_path; 6 static char **current_path;
7 7
8 static void persist_path(void) 8 static void persist_path(void)
9 { 9 {
10 char const *parts[] = {get_userdata_dir(), PATH_SEP, "sticky_path"}; 10 char *pathfname = alloc_concat(get_userdata_dir(), PATH_SEP "blastem" PATH_SEP "sticky_path");
11 char *pathfname = alloc_concat_m(3, parts);
12 FILE *f = fopen(pathfname, "wb"); 11 FILE *f = fopen(pathfname, "wb");
13 if (f) { 12 if (f) {
14 if (fwrite(*current_path, 1, strlen(*current_path), f) != strlen(*current_path)) { 13 if (fwrite(*current_path, 1, strlen(*current_path), f) != strlen(*current_path)) {
15 warning("Failed to save menu path"); 14 warning("Failed to save menu path");
16 } 15 }
61 void get_initial_browse_path(char **dst) 60 void get_initial_browse_path(char **dst)
62 { 61 {
63 *dst = NULL; 62 *dst = NULL;
64 char *remember_path = tern_find_path(config, "ui\0remember_path\0", TVAL_PTR).ptrval; 63 char *remember_path = tern_find_path(config, "ui\0remember_path\0", TVAL_PTR).ptrval;
65 if (!remember_path || !strcmp("on", remember_path)) { 64 if (!remember_path || !strcmp("on", remember_path)) {
66 char const *parts[] = {get_userdata_dir(), PATH_SEP, "sticky_path"}; 65 char *pathfname = alloc_concat(get_userdata_dir(), PATH_SEP "blastem" PATH_SEP "sticky_path");
67 char *pathfname = alloc_concat_m(3, parts);
68 FILE *f = fopen(pathfname, "rb"); 66 FILE *f = fopen(pathfname, "rb");
69 if (f) { 67 if (f) {
70 long pathsize = file_size(f); 68 long pathsize = file_size(f);
71 if (pathsize > 0) { 69 if (pathsize > 0) {
72 *dst = malloc(pathsize + 1); 70 *dst = malloc(pathsize + 1);