]> git.notmuchmail.org Git - notmuch/blob - test/make-db-version.cc
lib/database: delete stemmer on destroy
[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
12 main (int argc, char **argv)
13 {
14     if (argc != 4) {
15         fprintf (stderr, "Usage: %s mailpath version features\n", argv[0]);
16         exit (2);
17     }
18
19     std::string nmpath (argv[1]);
20
21     nmpath += "/.notmuch";
22     if (mkdir (nmpath.c_str (), 0777) < 0) {
23         perror (("failed to create " + nmpath).c_str ());
24         exit (1);
25     }
26
27     try {
28         Xapian::WritableDatabase db (
29             nmpath + "/xapian", Xapian::DB_CREATE_OR_OPEN);
30         db.set_metadata ("version", argv[2]);
31         db.set_metadata ("features", argv[3]);
32         db.commit ();
33     } catch (const Xapian::Error &e) {
34         fprintf (stderr, "%s\n", e.get_description ().c_str ());
35         exit (1);
36     }
37 }