/usr/share/doc/libsnapper-dev/examples/CreateNumber.cc is in libsnapper-dev 0.5.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <vector>
#include <iostream>
#include <snapper/Snapper.h>
using namespace snapper;
using namespace std;
void
delete_all()
{
Snapper snapper("testsuite", "/");
Snapshots snapshots = snapper.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)
snapper.deleteSnapshot(*it);
}
void
create_number()
{
Snapper snapper("testsuite", "/");
for (size_t i = 0; i < 100; ++i)
{
SCD scd;
scd.uid = getuid();
scd.description = "testsuite";
scd.cleanup = "number";
if (i % 5 == 0)
scd.userdata["important"] = "yes";
snapper.createSingleSnapshot(scd);
}
}
int
main()
{
delete_all();
create_number();
exit(EXIT_SUCCESS);
}
|