# HG changeset patch # User Sascha Wilde # Date 1395829503 -3600 # Node ID d4e97c9b199f4efdb61dc9f5588bd070b7698370 # Parent bea93c8651b7dc0fec47388c034c931388c17fe5 Use %APPDATA% as config bse dir on windows. Much simpler. diff -r bea93c8651b7 -r d4e97c9b199f cinst/mozilla.c --- a/cinst/mozilla.c Tue Mar 25 17:56:56 2014 +0100 +++ b/cinst/mozilla.c Wed Mar 26 11:25:03 2014 +0100 @@ -79,44 +79,28 @@ int return_code = 0; /** - * @brief Return users home path, on windows including drive letter - * @returns a pointer to a string containing the home path, it should - * be freed by the caller. + * @brief Return configuration base directory. + * @returns A pointer to a string containing the path to the base + * directory holding the configuration directories for e.g. mozilla + * and thunderbird. */ static char * -get_home() +get_conf_basedir() { - char *home, *homevar, *fqhome; - char *homedrive = NULL; + char *cdir, *envvar; - size_t len; if (LINUX) - homevar = "HOME"; + envvar = "HOME" ; else - homevar = "HOMEPATH"; + envvar = "APPDATA"; - if ((home = getenv(homevar)) == NULL) + if ((cdir = getenv(envvar)) != NULL) + return cdir; + else { - DEBUGFPRINT("DEBUG: FATAL! No HOME in environment.\n"); + DEBUGFPRINT("DEBUG: FATAL! No %s in environment.\n", envvar); exit(ERR_MOZ_HOMELESS); } - - len = strlen(home); - if (!LINUX) - homedrive = getenv("HOMEDRIVE"); - - if (homedrive != NULL) - len += strlen(homedrive); - - len++; /* Room for \0 */ - fqhome = xmalloc(len); - - if (homedrive == NULL) - snprintf(fqhome, len, "%s", home); - else - snprintf(fqhome, len, "%s%s", homedrive, home); - - return fqhome; } /** @@ -217,7 +201,7 @@ char *mozdirname; DIR *mozdir; struct dirent *mozdirent; - char *home = get_home(); + char *confbase = get_conf_basedir(); if (LINUX) { @@ -225,22 +209,24 @@ } else { - mozdirname = "AppData/Roaming/Mozilla"; + mozdirname = "Mozilla"; } - snprintf(path, LINEBUFLEN, "%s/%s", home, mozdirname); + snprintf(path, LINEBUFLEN, "%s/%s", + confbase, + mozdirname); if ((mozdir = opendir(path)) != NULL) { while ((mozdirent = readdir(mozdir)) != NULL) { snprintf(path, LINEBUFLEN, "%s/%s/%s", - home, + confbase, mozdirname, mozdirent->d_name); if (port_isdir(path)) { snprintf(path, LINEBUFLEN, "%s/%s/%s/%s", - home, + confbase, mozdirname, mozdirent->d_name, "profiles.ini"); @@ -257,7 +243,7 @@ } else { - DEBUGFPRINT("DEBUG: Could not open %s/%s\n", home, mozdirname); + DEBUGFPRINT("DEBUG: Could not open %s/%s\n", confbase, mozdirname); exit(WARN_MOZ_NO_PROFILES); } return inis;