# HG changeset patch # User Timo Sirainen # Date 1042299856 -7200 # Node ID f5658274245f00c7e4ba9cfdc3b2aa3f979b6cee # Parent 3681ff89f0e2dc5a905ae67a888d130bd7874d83 If ~/mail isn't found, create it. diff -r 3681ff89f0e2 -r f5658274245f src/lib-storage/index/mbox/mbox-storage.c --- a/src/lib-storage/index/mbox/mbox-storage.c Sat Jan 11 17:37:18 2003 +0200 +++ b/src/lib-storage/index/mbox/mbox-storage.c Sat Jan 11 17:44:16 2003 +0200 @@ -98,6 +98,26 @@ return NULL; } +static const char *create_root_dir(void) +{ + const char *home, *path; + + home = getenv("HOME"); + if (home == NULL) { + i_error("mbox: We need root IMAP folder, " + "but can't find it or HOME environment"); + return NULL; + } + + path = t_strconcat(home, "/mail", NULL); + if (mkdir(path, CREATE_MODE) < 0) { + i_error("mbox: Can't create root IMAP folder %s: %m", path); + return NULL; + } + + return path; +} + static struct mail_storage *mbox_create(const char *data, const char *user) { struct mail_storage *storage; @@ -140,8 +160,11 @@ } } - if (root_dir == NULL) - return NULL; + if (root_dir == NULL) { + root_dir = create_root_dir(); + if (root_dir == NULL) + return NULL; + } if (inbox_file == NULL) inbox_file = t_strconcat(root_dir, "/inbox", NULL);