mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:44:58 +00:00
LibCore: Remove the force
parameter from File::remove
About half of the usages were not using `force` anyways, and the other half presumably just got confused about what "force" really means in this context (which is "ignore nonexistent files"). The only 'legitimate' user, which is `rm`, instead now handles this completely internally instead.
This commit is contained in:
parent
355e761a02
commit
9805f73704
10 changed files with 22 additions and 20 deletions
|
@ -25,7 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(recursive, "Delete directories recursively", "recursive", 'r');
|
||||
args_parser.add_option(force, "Force", "force", 'f');
|
||||
args_parser.add_option(force, "Ignore nonexistent files", "force", 'f');
|
||||
args_parser.add_option(verbose, "Verbose", "verbose", 'v');
|
||||
args_parser.add_option(no_preserve_root, "Do not consider '/' specially", "no-preserve-root", 0);
|
||||
args_parser.add_positional_argument(paths, "Path(s) to remove", "path", Core::ArgsParser::Required::No);
|
||||
|
@ -43,10 +43,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
continue;
|
||||
}
|
||||
|
||||
auto result = Core::File::remove(path, recursive ? Core::File::RecursionMode::Allowed : Core::File::RecursionMode::Disallowed, force);
|
||||
auto result = Core::File::remove(path, recursive ? Core::File::RecursionMode::Allowed : Core::File::RecursionMode::Disallowed);
|
||||
|
||||
if (result.is_error()) {
|
||||
warnln("rm: cannot remove '{}': {}", path, static_cast<Error const&>(result.error()));
|
||||
auto error = result.error();
|
||||
|
||||
if (force && error.is_errno() && error.code() == ENOENT)
|
||||
continue;
|
||||
|
||||
warnln("rm: cannot remove '{}': {}", path, error);
|
||||
had_errors = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue