Skip to content

Commit

Permalink
Userland: Make rmdir take multiple paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ccapitalK authored and linusg committed Apr 26, 2021
1 parent 43956c9 commit b4e125c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Userland/Utilities/rmdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <errno.h>
#include <stdio.h>
Expand All @@ -16,16 +17,19 @@ int main(int argc, char** argv)
return 1;
}

const char* path;
Vector<const char*> paths;

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);

int rc = rmdir(path);
if (rc < 0) {
perror("rmdir");
return 1;
int status = 0;
for (auto path : paths) {
int rc = rmdir(path);
if (rc < 0) {
perror("rmdir");
status = 1;
}
}
return 0;
return status;
}

0 comments on commit b4e125c

Please sign in to comment.