From c4adc3b4dc0ad9e69f02c0f5eaa58bcae3b0e8b0 Mon Sep 17 00:00:00 2001 From: speedie Date: Wed, 16 Aug 2023 08:12:29 +0200 Subject: [PATCH] Check if file actually exists --- mcopy.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mcopy.cpp b/mcopy.cpp index 4cb42c0..3f45d88 100644 --- a/mcopy.cpp +++ b/mcopy.cpp @@ -157,11 +157,19 @@ int main(int argc, char **argv) { exit(1); } + int set{0}; + for (int i{1}; i < ac; i++) { std::ifstream f(av[i]); if (static_cast(f.good())) { + set = 1; getMetadataFromFile(format, av[i]); } } + + if (!set) { + std::cout << "mcopy: File not found.\n"; + exit(1); + } }