X-Git-Url: http://git.maemo.org/git/?p=browser-switch;a=blobdiff_plain;f=config-ui%2Fbrowser-switchboard-cp.c;h=dad6b683d8e396081d72b8f3e2bea6040967b5fc;hp=1ed654bf4f0f3fcd715747f81686b847c793dcb0;hb=f8b21568ef2e249dbdd6f56d14e1f00aff6e75f7;hpb=04f201c15099b479ab6052496eff796c2d643cc4 diff --git a/config-ui/browser-switchboard-cp.c b/config-ui/browser-switchboard-cp.c index 1ed654b..dad6b68 100644 --- a/config-ui/browser-switchboard-cp.c +++ b/config-ui/browser-switchboard-cp.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -152,9 +153,19 @@ static void save_config(void) { int other_browser_cmd_seen = 0; struct swb_config_line line; - /* Put together the path to the new config file and the tempfile */ + /* If CONFIGFILE_DIR doesn't exist already, try to create it */ if (!(homedir = getenv("HOME"))) homedir = DEFAULT_HOMEDIR; + len = strlen(homedir) + strlen(CONFIGFILE_DIR) + 1; + if (!(newfile = calloc(len, sizeof(char)))) + return; + snprintf(newfile, len, "%s%s", homedir, CONFIGFILE_DIR); + if (access(newfile, F_OK) == -1 && errno == ENOENT) { + mkdir(newfile, 0750); + } + free(newfile); + + /* Put together the path to the new config file and the tempfile */ len = strlen(homedir) + strlen(CONFIGFILE_LOC) + 1; if (!(newfile = calloc(len, sizeof(char)))) return;