dissect: warn when specified file cannot be opened
refs #3539
Change-Id: Ife650100469e1123f0f6610a25422e98020f1f49
diff --git a/tools/dissect/main.cpp b/tools/dissect/main.cpp
index fa1a962..7232e32 100644
--- a/tools/dissect/main.cpp
+++ b/tools/dissect/main.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California.
+ * Copyright (c) 2014-2016, Regents of the University of California.
*
* This file is part of ndn-tools (Named Data Networking Essential Tools).
* See AUTHORS.md for complete list of ndn-tools authors and contributors.
@@ -71,7 +71,7 @@
vm);
po::notify(vm);
}
- catch (po::error& e) {
+ catch (const po::error& e) {
std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
usage(std::cerr, argv[0], visibleOptions);
return 2;
@@ -92,6 +92,10 @@
if (vm.count("input-file") > 0 && inputFileName != "-") {
inputFile.open(inputFileName);
+ if (!inputFile.is_open()) {
+ std::cerr << argv[0] << ": " << inputFileName << ": File does not exist or is unreadable" << std::endl;
+ return 3;
+ }
inputStream = &inputFile;
}
else {