]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- example program to help timeline cleanup development
authorArvin Schnell <aschnell@suse.de>
Wed, 2 Mar 2011 16:24:59 +0000 (17:24 +0100)
committerArvin Schnell <aschnell@suse.de>
Wed, 2 Mar 2011 16:24:59 +0000 (17:24 +0100)
examples/.gitignore
examples/CreateTimeline.cc [new file with mode: 0644]
examples/Makefile.am

index 629d65b3b5d865778b05fcdde5809ea3041771f0..6f5b1b863388435aea2ac921c68122b92ed9afa2 100644 (file)
@@ -4,3 +4,5 @@ Create.o
 Create
 CmpDirs.o
 CmpDirs
+CreateTimeline.o
+CreateTimeline
diff --git a/examples/CreateTimeline.cc b/examples/CreateTimeline.cc
new file mode 100644 (file)
index 0000000..fac5eda
--- /dev/null
@@ -0,0 +1,51 @@
+
+#include <stdlib.h>
+#include <iostream>
+
+#include <snapper/Factory.h>
+#include <snapper/Snapper.h>
+
+using namespace snapper;
+using namespace std;
+
+
+void
+deleteAll()
+{
+    Snapper* sh = createSnapper("testsuite");
+
+    Snapshots snapshots = sh->getSnapshots();
+
+    vector<Snapshots::iterator> tmp;
+    for (Snapshots::iterator it = snapshots.begin(); it != snapshots.end(); ++it)
+       if (!it->isCurrent())
+           tmp.push_back(it);
+
+    for (vector<Snapshots::iterator>::iterator it = tmp.begin(); it != tmp.end(); ++it)
+       sh->deleteSnapshot(*it);
+
+    deleteSnapper(sh);
+}
+
+
+int
+main()
+{
+    deleteAll();
+
+    Snapper* sh = createSnapper("testsuite");
+
+    time_t t = time(NULL) - 100 * 24*60*60;
+    while (t < time(NULL))
+    {
+       Snapshots::iterator snap = sh->createSingleSnapshot("testsuite");
+       // snap->setDate(t);
+       snap->setCleanup("timeline");
+
+       t += 60*60;
+    }
+
+    deleteSnapper(sh);
+
+    exit(EXIT_SUCCESS);
+}
index 72ddfdceae76795540783f6e7ca6db7fe00796bd..f7e7b6bd77533442f290dc3ff3550f6f6217de4d 100644 (file)
@@ -6,7 +6,7 @@ INCLUDES = -I$(top_srcdir)
 
 LDADD = ../snapper/libsnapper.la
 
-noinst_PROGRAMS = List Create CmpDirs
+noinst_PROGRAMS = List Create CmpDirs CreateTimeline
 
 List_SOURCES = List.cc
 
@@ -14,3 +14,5 @@ Create_SOURCES = Create.cc
 
 CmpDirs_SOURCES = CmpDirs.cc
 
+CreateTimeline_SOURCES = CreateTimeline.cc
+