* fix mu_util_guess_maildir, mu_util_guess_mu_homedir for freebsd

This commit is contained in:
djcb
2012-03-19 20:53:18 +02:00
parent 2a6c9bebd6
commit acf1cd63f2

View File

@ -178,39 +178,46 @@ mu_util_check_dir (const gchar* path, gboolean readable, gboolean writeable)
gchar* gchar*
mu_util_guess_maildir (void) mu_util_guess_maildir (void)
{ {
const gchar *mdir1; const gchar *mdir1, *home;
gchar *mdir2;
/* first, try MAILDIR */ /* first, try MAILDIR */
mdir1 = g_getenv ("MAILDIR"); mdir1 = g_getenv ("MAILDIR");
if (mdir1 && mu_util_check_dir (mdir1, TRUE, FALSE)) if (mdir1 && mu_util_check_dir (mdir1, TRUE, FALSE))
return g_strdup (mdir1); return g_strdup (mdir1);
/* then, try ~/Maildir */ /* then, try <home>/Maildir */
mdir2 = mu_util_dir_expand ("~/Maildir"); home = g_get_home_dir();
if (mu_util_check_dir (mdir2, TRUE, FALSE)) if (home) {
return mdir2; char *mdir2;
mdir2 = g_strdup_printf ("%s%cMaildir",
home, G_DIR_SEPARATOR);
if (mu_util_check_dir (mdir2, TRUE, FALSE))
return mdir2;
g_free (mdir2);
}
/* nope; nothing found */ /* nope; nothing found */
return NULL; return NULL;
} }
gchar* gchar*
mu_util_guess_mu_homedir (void) mu_util_guess_mu_homedir (void)
{ {
const char* home; const char* home;
/* g_get_home_dir use /etc/passwd, not $HOME; this is better, /* g_get_home_dir use /etc/passwd, not $HOME; this is better,
* as HOME may be wrong when using 'sudo' etc.*/ * as HOME may be wrong when using 'sudo' etc.*/
home = g_get_home_dir (); home = g_get_home_dir ();
if (!home) if (!home) {
MU_WRITE_LOG ("failed to determine homedir"); MU_WRITE_LOG ("failed to determine homedir");
return NULL;
}
return g_strdup_printf ("%s%c%s", home ? home : ".", G_DIR_SEPARATOR, return g_strdup_printf ("%s%c%s", home ? home : ".",
".mu"); G_DIR_SEPARATOR, ".mu");
} }
gboolean gboolean