[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c,1.30,1.31

cras at procontrol.fi cras at procontrol.fi
Sat Jan 11 17:44:18 EET 2003


Update of /home/cvs/dovecot/src/lib-storage/index/mbox
In directory danu:/tmp/cvs-serv7845/lib-storage/index/mbox

Modified Files:
	mbox-storage.c 
Log Message:
If ~/mail isn't found, create it.



Index: mbox-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- mbox-storage.c	5 Jan 2003 13:09:53 -0000	1.30
+++ mbox-storage.c	11 Jan 2003 15:44:16 -0000	1.31
@@ -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);




More information about the dovecot-cvs mailing list