From: Arvin Schnell Date: Wed, 2 Mar 2011 16:24:59 +0000 (+0100) Subject: - example program to help timeline cleanup development X-Git-Tag: v0.1.3~441 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e533b43c9e8126f570d5e9e85cd3bfdb93d81848;p=thirdparty%2Fsnapper.git - example program to help timeline cleanup development --- diff --git a/examples/.gitignore b/examples/.gitignore index 629d65b3..6f5b1b86 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -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 index 00000000..fac5eda4 --- /dev/null +++ b/examples/CreateTimeline.cc @@ -0,0 +1,51 @@ + +#include +#include + +#include +#include + +using namespace snapper; +using namespace std; + + +void +deleteAll() +{ + Snapper* sh = createSnapper("testsuite"); + + Snapshots snapshots = sh->getSnapshots(); + + vector tmp; + for (Snapshots::iterator it = snapshots.begin(); it != snapshots.end(); ++it) + if (!it->isCurrent()) + tmp.push_back(it); + + for (vector::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); +} diff --git a/examples/Makefile.am b/examples/Makefile.am index 72ddfdce..f7e7b6bd 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -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 +