]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- check file opening
authorArvin Schnell <aschnell@suse.de>
Thu, 10 Feb 2011 14:00:35 +0000 (15:00 +0100)
committerArvin Schnell <aschnell@suse.de>
Thu, 10 Feb 2011 14:00:35 +0000 (15:00 +0100)
tools/snapper.cc

index 8a70420028037d739a1f96029183fcfc992fbe7a..3b0faa5bf7bfd8b6d30086cc3cfc186b66045327 100644 (file)
@@ -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;