From 37dc1f9b071e2452ea0e6ee90f570f17d1e0b218 Mon Sep 17 00:00:00 2001 From: Stefan Haustein Date: Sun, 5 Jul 2020 13:15:42 +0200 Subject: [PATCH] Add an explicit error message for files that can't be opened --- src/main/cpp/tiv.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/cpp/tiv.cpp b/src/main/cpp/tiv.cpp index bafdd0d..2c9074a 100644 --- a/src/main/cpp/tiv.cpp +++ b/src/main/cpp/tiv.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -506,7 +507,12 @@ int main(int argc, char* argv[]) { } } } else { - file_names.push_back(arg); + std::ifstream fin(arg.c_str()); + if (fin) { + file_names.push_back(arg); + } else { + std::cerr << "Can't open file (permission?): " << arg << std::endl; + } } } }