mirror of
https://github.com/RGBCube/serenity
synced 2025-07-04 21:17:36 +00:00
file: Don't exit immediately after file open error
Instead just remember that a file failed to open, carry on and return 1 at the end.
This commit is contained in:
parent
85a7dae391
commit
d7446e05db
1 changed files with 5 additions and 2 deletions
|
@ -81,11 +81,14 @@ int main(int argc, char** argv)
|
||||||
args_parser.add_positional_argument(paths, "Files to identify", "files", Core::ArgsParser::Required::Yes);
|
args_parser.add_positional_argument(paths, "Files to identify", "files", Core::ArgsParser::Required::Yes);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
|
bool all_ok = true;
|
||||||
|
|
||||||
for (auto path : paths) {
|
for (auto path : paths) {
|
||||||
auto file = Core::File::construct(path);
|
auto file = Core::File::construct(path);
|
||||||
if (!file->open(Core::File::ReadOnly)) {
|
if (!file->open(Core::File::ReadOnly)) {
|
||||||
perror(path);
|
perror(path);
|
||||||
return 1;
|
all_ok = false;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
auto bytes = file->read(25);
|
auto bytes = file->read(25);
|
||||||
auto file_name_guess = Core::guess_mime_type_based_on_filename(path);
|
auto file_name_guess = Core::guess_mime_type_based_on_filename(path);
|
||||||
|
@ -94,5 +97,5 @@ int main(int argc, char** argv)
|
||||||
outln("{}: {}", path, flag_mime_only ? mime_type : human_readable_description);
|
outln("{}: {}", path, flag_mime_only ? mime_type : human_readable_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return all_ok ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue