#define FACTORY_H
+#include <string>
+
+
namespace snapper
{
+ using std::string;
+
class Snapper;
// Only one Snapper can be created at a time.
- Snapper* createSnapper();
+ Snapper* createSnapper(const string& root = "/");
void deleteSnapper(Snapper*);
using namespace std;
- Snapper::Snapper()
- : snapshots(this), files(this), compare_callback(NULL)
+ Snapper::Snapper(const string& root)
+ : root(root), snapshots(this), files(this), compare_callback(NULL)
{
y2mil("Snapper constructor");
string
Snapper::rootDir() const
{
- return "/";
+ return root;
}
GetOpts getopts;
bool quiet = false;
+string root = "/";
Snapper* sh = NULL;
cout << _(" Global options:") << endl
<< _("\t--quiet, -q\t\t\tSuppress normal output.") << endl
<< _("\t--table-style, -s <style>\tTable style (integer).") << endl
+ << _("\t--root, -r <path>\t\tSet root directory.") << endl
<< endl;
help_list();
const struct option options[] = {
{ "quiet", no_argument, 0, 'q' },
{ "table-style", required_argument, 0, 's' },
+ { "root", required_argument, 0, 'r' },
{ 0, 0, 0, 0 }
};
Table::defaultStyle = (TableLineStyle) s;
}
- sh = createSnapper();
+ if ((it = opts.find("root")) != opts.end())
+ root = it->second;
+
+ sh = createSnapper(root);
if (!quiet)
sh->setCompareCallback(&compare_callback_impl);