1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

Userland: Make rmdir take multiple paths

This commit is contained in:
Sahan Fernando 2021-01-12 14:13:07 +11:00 committed by Linus Groh
parent 43956c9611
commit b4e125cf86

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
@ -16,16 +17,19 @@ int main(int argc, char** argv)
return 1; return 1;
} }
const char* path; Vector<const char*> paths;
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
args_parser.add_positional_argument(path, "Directory to remove", "path"); args_parser.add_positional_argument(paths, "Directories to remove", "paths");
args_parser.parse(argc, argv); args_parser.parse(argc, argv);
int rc = rmdir(path); int status = 0;
if (rc < 0) { for (auto path : paths) {
perror("rmdir"); int rc = rmdir(path);
return 1; if (rc < 0) {
perror("rmdir");
status = 1;
}
} }
return 0; return status;
} }