[PATCH] Allow override of the dotfile location

Christian Stimming stimming at tuhh.de
Wed Mar 21 14:43:47 EDT 2007


Am Mittwoch, 21. März 2007 09:53 schrieb Derek Atkins:
> Why not just run:
>
>   HOME=... gnucash
>
> ???   Or does this no longer work now that we've changed to
> g_get_home_dir()?

According to the documentation of g_get_home_dir, this does *not* work any 
longer. I think this is a good extension.

@James: The patch looks fine, except that you should use g_getenv instead of 
getenv (and IIRC there were some reversed semantics when changing from one 
such call to the other). Also, the result of g_build_filename is owned by the 
caller and will be freed later, and I'm not so sure whether this is correct 
for a string that was retrieved from getenv/g_getenv.

Thanks for the contribution in any case,

Christian

> > Index: src/engine/gnc-filepath-utils.c
> > ===================================================================
> > --- src/engine/gnc-filepath-utils.c	(revision 15738)
> > +++ src/engine/gnc-filepath-utils.c	(working copy)
> > @@ -382,14 +382,17 @@
> >    if (dotgnucash)
> >      return dotgnucash;
> >
> > -  home = g_get_home_dir();
> > -  if (!home) {
> > -    g_warning("Cannot find home directory. Using tmp directory
> > instead."); -    home = g_get_tmp_dir();
> > +  dotgnucash = getenv("GNC_DOT_DIR");
> > +  if(!dotgnucash) {
> > + 	 home = g_get_home_dir();
> > +  	if (!home) {
> > +   		 g_warning("Cannot find home directory. Using tmp directory
> > instead."); +   	 	home = g_get_tmp_dir();
> > +  	}
> > +  	g_assert(home);
> > +
> > +  	dotgnucash = g_build_filename(home, ".gnucash", (gchar *)NULL);
> >    }
> > -  g_assert(home);
> > -
> > -  dotgnucash = g_build_filename(home, ".gnucash", (gchar *)NULL);
> >    gnc_validate_directory(dotgnucash);
> >
> >    /* Since we're in code that is only executed once.... */
> > _______________________________________________
> > gnucash-devel mailing list
> > gnucash-devel at gnucash.org
> > https://lists.gnucash.org/mailman/listinfo/gnucash-devel



More information about the gnucash-devel mailing list