From ab34bbe232a6e5d4cc129e851ddd0d6b9d5ef9ff Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 8 Mar 2019 07:03:17 +0100 Subject: move config files to ~/.config/ --- fbiconfig.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'fbiconfig.c') diff --git a/fbiconfig.c b/fbiconfig.c index a986c3b..a8244a1 100644 --- a/fbiconfig.c +++ b/fbiconfig.c @@ -262,7 +262,7 @@ struct cfg_cmdline fbpdf_cfg[] = { static char *fbi_config = NULL; -static void init_config(const char *name) +static void init_config(const char *name, const char *old_name) { char *home; @@ -270,13 +270,19 @@ static void init_config(const char *name) if (NULL == home) return; + fbi_config = malloc(strlen(home) + strlen(old_name) + 2); + sprintf(fbi_config, "%s/%s", home, old_name); + if (access(fbi_config, F_OK) == 0) + return; + + free(fbi_config); fbi_config = malloc(strlen(home) + strlen(name) + 2); - sprintf(fbi_config,"%s/%s", home, name); + sprintf(fbi_config, "%s/%s", home, name); } -void fbi_read_config(const char *name) +void fbi_read_config(const char *name, const char *old_name) { - init_config(name); + init_config(name, old_name); if (fbi_config) cfg_parse_file("config", fbi_config); } -- cgit