summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/configfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/lib/configfile.c')
-rw-r--r--apps/plugins/lib/configfile.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c
index 3ca38052e5..54c067c4a7 100644
--- a/apps/plugins/lib/configfile.c
+++ b/apps/plugins/lib/configfile.c
@@ -26,6 +26,23 @@ void configfile_init(struct plugin_api* newrb)
26 cfg_rb = newrb; 26 cfg_rb = newrb;
27} 27}
28 28
29void get_cfg_filename(char* buf, int buf_len, const char* filename)
30{
31 char *s;
32 cfg_rb->strcpy(buf, cfg_rb->plugin_get_current_filename());
33 s = cfg_rb->strrchr(buf, '/');
34 if (!s) /* should never happen */
35 {
36 cfg_rb->snprintf(buf, buf_len, "/.rockbox/rocks/%s", filename);
37 }
38 else
39 {
40 s++;
41 *s = '\0';
42 cfg_rb->strcat(s, filename);
43 }
44}
45
29int configfile_save(const char *filename, struct configdata *cfg, 46int configfile_save(const char *filename, struct configdata *cfg,
30 int num_items, int version) 47 int num_items, int version)
31{ 48{
@@ -33,7 +50,7 @@ int configfile_save(const char *filename, struct configdata *cfg,
33 int i; 50 int i;
34 char buf[MAX_PATH]; 51 char buf[MAX_PATH];
35 52
36 cfg_rb->snprintf(buf, MAX_PATH, "/.rockbox/rocks/%s", filename); 53 get_cfg_filename(buf, MAX_PATH, filename);
37 fd = cfg_rb->creat(buf); 54 fd = cfg_rb->creat(buf);
38 if(fd < 0) 55 if(fd < 0)
39 return fd*10 - 1; 56 return fd*10 - 1;
@@ -78,7 +95,7 @@ int configfile_load(const char *filename, struct configdata *cfg,
78 int file_version = -1; 95 int file_version = -1;
79 int tmp; 96 int tmp;
80 97
81 cfg_rb->snprintf(buf, MAX_PATH, "/.rockbox/rocks/%s", filename); 98 get_cfg_filename(buf, MAX_PATH, filename);
82 fd = cfg_rb->open(buf, O_RDONLY); 99 fd = cfg_rb->open(buf, O_RDONLY);
83 if(fd < 0) 100 if(fd < 0)
84 return fd*10 - 1; 101 return fd*10 - 1;