From: Timo Sirainen Date: Thu, 19 Feb 2009 23:40:27 +0000 (-0500) Subject: idxview: Support specifying the name of dovecot.index file. X-Git-Tag: 1.2.beta2~81 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5ffac385d04a781a26b8a121fa205a4c0f60b410;p=thirdparty%2Fdovecot%2Fcore.git idxview: Support specifying the name of dovecot.index file. --HG-- branch : HEAD --- diff --git a/src/util/idxview.c b/src/util/idxview.c index e0e4ee1085..a5c297743f 100644 --- a/src/util/idxview.c +++ b/src/util/idxview.c @@ -426,6 +426,8 @@ int main(int argc, const char *argv[]) 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 @@ int main(int argc, const char *argv[]) if (argc < 2) i_fatal("Usage: idxview []"); - 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]);