Check if file actually exists

This commit is contained in:
Jacob 2023-08-16 08:12:29 +02:00
parent 0abf3a803a
commit c4adc3b4dc

View file

@ -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<bool>(f.good())) {
set = 1;
getMetadataFromFile(format, av[i]);
}
}
if (!set) {
std::cout << "mcopy: File not found.\n";
exit(1);
}
}