Imported Upstream version 0.1.2
[platform/upstream/snapper.git] / examples / CreateTimeline.cc
1
2 #include <stdlib.h>
3 #include <vector>
4 #include <iostream>
5
6 #include <snapper/Snapper.h>
7
8 using namespace snapper;
9 using namespace std;
10
11
12 void
13 deleteAll()
14 {
15     Snapper* sh = new Snapper("testsuite");
16
17     Snapshots snapshots = sh->getSnapshots();
18
19     vector<Snapshots::iterator> tmp;
20     for (Snapshots::iterator it = snapshots.begin(); it != snapshots.end(); ++it)
21         if (!it->isCurrent())
22             tmp.push_back(it);
23
24     for (vector<Snapshots::iterator>::iterator it = tmp.begin(); it != tmp.end(); ++it)
25         sh->deleteSnapshot(*it);
26
27     delete sh;
28 }
29
30
31 int
32 main()
33 {
34     deleteAll();
35
36     Snapper* sh = new Snapper("testsuite");
37
38     time_t t = time(NULL) - 100 * 24*60*60;
39     while (t < time(NULL))
40     {
41         Snapshots::iterator snap = sh->createSingleSnapshot("testsuite");
42         // snap->setDate(t);
43         snap->setCleanup("timeline");
44
45         t += 60*60;
46     }
47
48     delete sh;
49
50     exit(EXIT_SUCCESS);
51 }