]> git.notmuchmail.org Git - notmuch/blob - test/make-db-version.cc
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / test / make-db-version.cc
1 /* Create an empty notmuch database with a specific version and
2  * features. */
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <sys/stat.h>
7 #include <sys/types.h>
8
9 #include <xapian.h>
10
11 int main(int argc, char **argv)
12 {
13     if (argc != 4) {
14         fprintf (stderr, "Usage: %s mailpath version features\n", argv[0]);
15         exit (2);
16     }
17
18     std::string nmpath (argv[1]);
19     nmpath += "/.notmuch";
20     if (mkdir (nmpath.c_str (), 0777) < 0) {
21         perror (("failed to create " + nmpath).c_str ());
22         exit (1);
23     }
24
25     try {
26         Xapian::WritableDatabase db (
27             nmpath + "/xapian", Xapian::DB_CREATE_OR_OPEN);
28         db.set_metadata ("version", argv[2]);
29         db.set_metadata ("features", argv[3]);
30         db.commit ();
31     } catch (const Xapian::Error &e) {
32         fprintf (stderr, "%s\n", e.get_description ().c_str ());
33         exit (1);
34     }
35 }