-#include <unistd.h>
-#include <sys/types.h>
-#include <stdlib.h>
+#include <cstdlib>
#include <iostream>
#include <snapper/Snapper.h>
using namespace snapper;
using namespace std;
+
int
main(int argc, char** argv)
{
- Snapper* sh = new Snapper("root", "/");
+ Snapper snapper("root", "/");
SCD scd;
scd.uid = getuid();
Plugins::Report report;
- sh->createSingleSnapshot(scd, report);
-
- delete sh;
+ snapper.createSingleSnapshot(scd, report);
exit(EXIT_SUCCESS);
}
-#include <stdlib.h>
+#include <cstdlib>
#include <iostream>
#include <snapper/Snapper.h>
using namespace snapper;
using namespace std;
+
int
main(int argc, char** argv)
{
- Snapper* sh = new Snapper("root", "/");
+ Snapper snapper("root", "/");
- const Snapshots& snapshots = sh->getSnapshots();
- for (Snapshots::const_iterator it = snapshots.begin(); it != snapshots.end(); ++it)
- {
- cout << *it << endl;
- }
+ const Snapshots& snapshots = snapper.getSnapshots();
- delete sh;
+ for (const Snapshot& snapshot : snapshots)
+ cout << snapshot << '\n';
exit(EXIT_SUCCESS);
}
-#include <stdlib.h>
+#include <cstdlib>
#include <iostream>
+#include <memory>
#include <snapper/Snapper.h>
using namespace snapper;
using namespace std;
+
int
main(int argc, char** argv)
{
list<ConfigInfo> config_infos = Snapper::getConfigs("/");
- list<Snapper*> sh;
-
- for (list<ConfigInfo>::const_iterator it = config_infos.begin(); it != config_infos.end(); ++it)
- sh.push_back(new Snapper(it->get_config_name(), "/"));
+ list<unique_ptr<Snapper>> snappers;
- for (list<Snapper*>::const_iterator it = sh.begin(); it != sh.end(); ++it)
- cout << (*it)->configName() << " " << (*it)->subvolumeDir() << " "
- << (*it)->getSnapshots().size() << endl;
+ for (const ConfigInfo& config_info : config_infos)
+ snappers.push_back(make_unique<Snapper>(config_info.get_config_name(), "/"));
- for (list<Snapper*>::const_iterator it = sh.begin(); it != sh.end(); ++it)
- delete *it;
+ for (const unique_ptr<Snapper>& snapper : snappers)
+ cout << snapper->configName() << " " << snapper->subvolumeDir() << " "
+ << snapper->getSnapshots().size() << endl;
exit(EXIT_SUCCESS);
}