From 9771d0f80caa60030b27bae652d6b76fcb77e5cc Mon Sep 17 00:00:00 2001 From: David Hampton Date: Wed, 23 Nov 2005 22:43:32 +0000 Subject: [PATCH] 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 --- ChangeLog | 8 ++++++++ lib/libqof/qof/guid.c | 2 +- src/app-utils/gnc-ui-util.c | 2 +- src/engine/test/test-resolve-file-path.c | 12 +++--------- src/gnome-utils/druid-gconf-setup.c | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0270d5e69a..b67e53caf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2005-11-23 David Hampton + * 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 diff --git a/lib/libqof/qof/guid.c b/lib/libqof/qof/guid.c index 1636cbcea6..1f3ad2ea97 100644 --- a/lib/libqof/qof/guid.c +++ b/lib/libqof/qof/guid.c @@ -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); } diff --git a/src/app-utils/gnc-ui-util.c b/src/app-utils/gnc-ui-util.c index b070e74bee..21f958cfce 100644 --- a/src/app-utils/gnc-ui-util.c +++ b/src/app-utils/gnc-ui-util.c @@ -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 diff --git a/src/engine/test/test-resolve-file-path.c b/src/engine/test/test-resolve-file-path.c index 998c3e6a7d..2261933f0f 100644 --- a/src/engine/test/test-resolve-file-path.c +++ b/src/engine/test/test-resolve-file-path.c @@ -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 diff --git a/src/gnome-utils/druid-gconf-setup.c b/src/gnome-utils/druid-gconf-setup.c index b49186fb84..d36cc54477 100644 --- a/src/gnome-utils/druid-gconf-setup.c +++ b/src/gnome-utils/druid-gconf-setup.c @@ -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);