Use the g_get_home_dir() function instead of getenv("HOME"). The

former tries multiple places to get the path to the users home
directory.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12025 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2005-11-23 22:43:32 +00:00
parent c0c0398de1
commit 9771d0f80c
5 changed files with 15 additions and 13 deletions

View File

@ -1,5 +1,12 @@
2005-11-23 David Hampton <hampton@employees.org>
* src/gnome-utils/druid-gconf-setup.c:
* src/engine/test/test-resolve-file-path.c:
* src/app-utils/gnc-ui-util.c:
* lib/libqof/qof/guid.c: Use the g_get_home_dir() function instead
of getenv("HOME"). The former tries multiple places to get the
path to the users home directory.
* src/import-export/qif-import/qif-guess-map.scm:
* src/scm/command-line.scm:
* src/scm/main.scm:
@ -8,6 +15,7 @@
* src/engine/gnc-filepath-utils.c:
* src/engine/gnc-filepath-utils.h:
* src/engine/gw-engine-spec.scm:
* src/app-utils/file-utils.c:
* src/app-utils/gnc-exp-parser.c: Consolidate the creation of all
file names under ~/.gnucash, and also consolidate checks for the
existence of ~/.gnucash and ~/.gnucash/books. Add better error

View File

@ -350,7 +350,7 @@ guid_init(void)
for (i = 0; dirs[i] != NULL; i++)
bytes += init_from_dir(dirs[i], 32);
dirname = getenv("HOME");
dirname = g_get_home_dir();
if (dirname != NULL)
bytes += init_from_dir(dirname, 32);
}

View File

@ -168,7 +168,7 @@ void
gnc_init_default_directory (char **dirname)
{
if (*dirname == NULL)
*dirname = g_strdup_printf("%s/", getenv("HOME"));
*dirname = g_strdup_printf("%s/", g_get_home_dir());
}
void

View File

@ -46,12 +46,6 @@ test_strings strs[] = {
{ NULL, NULL, 0 },
};
static const char*
get_home_dir()
{
return getenv("HOME");
}
int
main(int argc, char **argv)
{
@ -65,14 +59,14 @@ main(int argc, char **argv)
if(strs[i].prefix_home == 1)
{
dain = g_strdup_printf("%s/%s", get_home_dir(), strs[i].input);
wantout = g_strdup_printf("%s/%s", get_home_dir(),
dain = g_strdup_printf("%s/%s", g_get_home_dir(), strs[i].input);
wantout = g_strdup_printf("%s/%s", g_get_home_dir(),
strs[i].output);
}
else if(strs[i].prefix_home == 2)
{
dain = g_strdup(strs[i].input);
wantout = g_strdup_printf("%s%s", get_home_dir(),
wantout = g_strdup_printf("%s%s", g_get_home_dir(),
strs[i].output);
}
else

View File

@ -115,8 +115,8 @@ druid_gconf_update_path (GError **error)
gboolean found_user_dir = FALSE;
FILE *output;
data_filename = g_strjoin("/", g_getenv("HOME"), ".gconf", (char *)NULL);
path_filename = g_strjoin("/", g_getenv("HOME"), ".gconf.path", (char *)NULL);
data_filename = g_build_filename(g_get_home_dir(), ".gconf", (char *)NULL);
path_filename = g_build_filename(g_get_home_dir(), ".gconf.path", (char *)NULL);
if (g_file_test(path_filename, G_FILE_TEST_EXISTS)) {
if (!g_file_get_contents(path_filename, &contents, NULL, error)) {
g_free(path_filename);