From: Arvin Schnell Date: Thu, 10 Feb 2011 14:00:35 +0000 (+0100) Subject: - check file opening X-Git-Tag: v0.1.3~494 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=27cfb1b8d6a1eddf02ec9fb13e147515e98976f0;p=thirdparty%2Fsnapper.git - check file opening --- diff --git a/tools/snapper.cc b/tools/snapper.cc index 8a704200..3b0faa5b 100644 --- a/tools/snapper.cc +++ b/tools/snapper.cc @@ -267,6 +267,11 @@ command_diff() if ((it = opts.find("output")) != opts.end()) { file = fopen(it->second.c_str(), "w"); + if (!file) + { + cerr << sformat(_("Opening file '%s' failed."), it->second.c_str()) << endl; + exit(EXIT_FAILURE); + } } Snapshots::const_iterator snap1 = readNum(getopts.popArg()); @@ -320,6 +325,11 @@ command_rollback() if ((it = opts.find("file")) != opts.end()) { file = fopen(it->second.c_str(), "r"); + if (!file) + { + cerr << sformat(_("Opening file '%s' failed."), it->second.c_str()) << endl; + exit(EXIT_FAILURE); + } } sh->setComparison(snap1, snap2); @@ -438,6 +448,7 @@ main(int argc, char** argv) } GetOpts::parsed_opts::const_iterator it; + if ((it = opts.find("quiet")) != opts.end()) quiet = true;