.gnucash and GNC_DOT_DIR
andi5.py at gmx.net
Thu Feb 4 20:53:27 EST 2010
-----BEGIN PGP SIGNED MESSAGE-----
I like code to be improved, but a few things come to my mind. You can
probably fix them rather easily.
- - Watch out for memory leaks. E.g. you must free the result of
gnc_path_get_pkgdatadir() after usage, otherwise you leak it. The
function documentation typically explains the memory management of
parameters and return values.
- - Try to use glib functionality to avoid mistakes and improve
portability. E.g. if you do not explicitly pass NULL to getcwd(2) then
you are expected to provide a char buffer for the function to fill in.
g_get_current_dir() is the solution and devhelp your friend :)
- - BEGIN and LEAVE should wrap all possible paths through a function (if
needed at all). I.e., start with BEGIN and add LEAVE before every return
or the end of the function.
- - I am picky wrt trailing whitespaces, no tab characters unless already
in the surrounding code, printfs (like g_printerr), unneeded code newly
I am more interested whether the removed functionality really is not
needed anymore or fully replaced. Is .gnucash created in time, do we
need to support file: or xml: schemas anywhere?
Personally, I could not guess about the patch on Windows, someone (not
me ;-)) would need to give it a try.
- -- andi5
John Ralls schrieb:
> Motivated by a recent issue in gnucash-users, where a MacOSX user had trouble because .gnucash is invisible to TextEdit (which normal users would use to edit a file), and because it's actually necessary to edit .gnucash/saved-reports-2.0 to clean old reports from the menu, I decided that for OSX the Gnucash prefs should live in the more Macish ~/Library/Application Support/Gnucash. So far, so good.
> Src/engine/gnc-filepath-utils.c has two ways to find the preferences directory: A public one, gnc_dot_gnucash_dir(), and a private one hard coded in xaccResolveFilePath() and some static functions which it uses. The former uses glib tools and provides an undocumented (at least as far as I can find) environment variable $GNC_DOT_DIR to easily override the directory (my goal). The latter has ~/.gnucash hardcoded along with some other inappropriate hard-coded paths and a rather bizarre indirection scheme for resolving filenames.
> The attached patch replaces the private static functions in xaccResolveFilePath() with calls to gnc_dot_gnucash_dir() and (I think) rationalizes the filename resolution using functions graciously provided in gnc-path.h.
> Before I commit it, I'd like some of the devs more experienced with GC to look it over and make sure I haven't done something overly stupid. It would probably be a good idea for one of the MSWin maintainers to make sure that it doesn't break anything there.
> John Ralls
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the gnucash-devel