changeset 8916:3ceb0878ab09 HEAD

idxview: Support specifying the name of dovecot.index file.
author Timo Sirainen <tss@iki.fi>
date Thu, 19 Feb 2009 18:39:43 -0500
parents 9a97b4f8f6d8
children 98c84ae0b659
files src/util/idxview.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/util/idxview.c	Tue Feb 17 16:40:45 2009 -0500
+++ b/src/util/idxview.c	Thu Feb 19 18:39:43 2009 -0500
@@ -426,6 +426,8 @@
 	struct mail_index *index;
 	struct mail_index_view *view;
 	struct mail_cache_view *cache_view;
+	struct stat st;
+	const char *p;
 	unsigned int seq, uid = 0;
 
 	lib_init();
@@ -433,7 +435,12 @@
 	if (argc < 2)
 		i_fatal("Usage: idxview <index dir> [<uid>]");
 
-	index = mail_index_alloc(argv[1], "dovecot.index");
+	if (stat(argv[1], &st) == 0 && S_ISDIR(st.st_mode))
+		index = mail_index_alloc(argv[1], "dovecot.index");
+	else if ((p = strrchr(argv[1], '/')) != NULL)
+		index = mail_index_alloc(t_strdup_until(argv[1], p), p + 1);
+	else
+		index = mail_index_alloc(".", argv[1]);
 	if (mail_index_open(index, MAIL_INDEX_OPEN_FLAG_READONLY,
 			    FILE_LOCK_METHOD_FCNTL) <= 0)
 		i_fatal("Couldn't open index %s", argv[1]);