Re: g_get_home_dir, g_get_tmp_dir



On Wed, 28 Oct 1998, Tor Lillqvist wrote:

> I think some specification for the semantics of g_get_home_dir and
> g_get_tmp_dir should be decided upon. In my gimp for Windows work, I
> had assumed that g_get_home_dir can and should return an empty string
> if the user has no recognisable home directory (as typically is the
> case on single-user Windoze machines).
> 
> (I already have code in gimp for Windows that takes this into
> consideration, and uses the gimp installation directory for per-user
> rc files in that case.)
> 
> When applying the Windows patch to GLib, however, g_get_home_dir was
> changed to return the same as g_get_tmp_dir always on Windows. (Becase
> g_get_any_init was changed to always set g_home_dir to NULL on
> Windows, even if the HOME env var exists.) (I mean, it was not like
> that in my suggested patch, but TJ changed it that way.) Is this
> really a good idea?

uhm, that's a bug, the non PWD_H code shouldn't reset the homedir
to NULL, since it already has been setup from
  g_home_dir = g_strdup (g_getenv ("HOME"));
(resetting this to NULL is a memory leak also).
what i meant to do is to provide
  if (!g_home_dir)
      g_home_dir = g_strdup (g_tmp_dir);
as a last resort, if HOME is not set and the system doesn't provide
a home directory through the pwd.h interface.

g_get_home_dir() is actually meant (at least on unixen) to return the
directory that you'd want to find/put an applications config files, and
to return the string that is needed to expand ~/... paths.
since you mention you already handled this in your gimp patches specifically,
what heuristics do you actually use to find a home dir if g_get_home_dir()
returns NULL?
are you hiding something there, that should eventually go into
g_get_home_dir() itself? ;)))

> --tml
> 

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]