Mercurial > dovecot > original-hg > dovecot-1.2
changeset 947:f5658274245f HEAD
If ~/mail isn't found, create it.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 11 Jan 2003 17:44:16 +0200 |
parents | 3681ff89f0e2 |
children | 70083370cc84 |
files | src/lib-storage/index/mbox/mbox-storage.c |
diffstat | 1 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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);