* 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,8 +178,7 @@ mu_util_check_dir (const gchar* path, gboolean readable, gboolean writeable)
gchar*
mu_util_guess_maildir (void)
{
const gchar *mdir1;
gchar *mdir2;
const gchar *mdir1, *home;
/* first, try MAILDIR */
mdir1 = g_getenv ("MAILDIR");
@ -187,10 +186,16 @@ mu_util_guess_maildir (void)
if (mdir1 && mu_util_check_dir (mdir1, TRUE, FALSE))
return g_strdup (mdir1);
/* then, try ~/Maildir */
mdir2 = mu_util_dir_expand ("~/Maildir");
/* then, try <home>/Maildir */
home = g_get_home_dir();
if (home) {
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 */
return NULL;
@ -206,11 +211,13 @@ mu_util_guess_mu_homedir (void)
* as HOME may be wrong when using 'sudo' etc.*/
home = g_get_home_dir ();
if (!home)
if (!home) {
MU_WRITE_LOG ("failed to determine homedir");
return NULL;
}
return g_strdup_printf ("%s%c%s", home ? home : ".", G_DIR_SEPARATOR,
".mu");
return g_strdup_printf ("%s%c%s", home ? home : ".",
G_DIR_SEPARATOR, ".mu");
}
gboolean