From: Arvin Schnell Date: Tue, 20 Sep 2011 12:39:04 +0000 (+0200) Subject: - check for some utils X-Git-Tag: v0.1.3~284 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=554cd9249c9ed52728c2efbd8afdd5513ca78dc5;p=thirdparty%2Fsnapper.git - check for some utils --- diff --git a/snapper/Exception.h b/snapper/Exception.h index 14eb95c0..b885db76 100644 --- a/snapper/Exception.h +++ b/snapper/Exception.h @@ -62,6 +62,13 @@ namespace snapper virtual const char* what() const throw() { return "IO error"; } }; + struct ProgramNotInstalledException : public SnapperException + { + explicit ProgramNotInstalledException(const char* msg) throw() : msg(msg) {} + virtual const char* what() const throw() { return msg; } + const char* msg; + }; + } diff --git a/snapper/Filesystem.cc b/snapper/Filesystem.cc index 82376d76..8f5aef46 100644 --- a/snapper/Filesystem.cc +++ b/snapper/Filesystem.cc @@ -49,6 +49,16 @@ namespace snapper } + Btrfs::Btrfs(const string& subvolume) + : Filesystem(subvolume) + { + if (access(BTRFSBIN, X_OK) != 0) + { + throw ProgramNotInstalledException(BTRFSBIN " not installed"); + } + } + + void Btrfs::addConfig() const { @@ -118,6 +128,21 @@ namespace snapper } + Ext4::Ext4(const string& subvolume) + : Filesystem(subvolume) + { + if (access(CHSNAPBIN, X_OK) != 0) + { + throw ProgramNotInstalledException(CHSNAPBIN " not installed"); + } + + if (access(CHATTRBIN, X_OK) != 0) + { + throw ProgramNotInstalledException(CHATTRBIN " not installed"); + } + } + + void Ext4::addConfig() const { diff --git a/snapper/Filesystem.h b/snapper/Filesystem.h index 11c35c8a..7eb3ecd3 100644 --- a/snapper/Filesystem.h +++ b/snapper/Filesystem.h @@ -71,7 +71,7 @@ namespace snapper { public: - Btrfs(const string& subvolume) : Filesystem(subvolume) {} + Btrfs(const string& subvolume); virtual string name() const { return "btrfs"; } @@ -96,7 +96,7 @@ namespace snapper { public: - Ext4(const string& subvolume) : Filesystem(subvolume) {} + Ext4(const string& subvolume); virtual string name() const { return "ext4"; } diff --git a/snapper/Snapper.cc b/snapper/Snapper.cc index c593eed0..8dcd9626 100644 --- a/snapper/Snapper.cc +++ b/snapper/Snapper.cc @@ -586,6 +586,10 @@ namespace snapper { throw AddConfigFailedException("invalid filesystem type"); } + catch (const ProgramNotInstalledException& e) + { + throw AddConfigFailedException(e.what()); + } try {