Serenity Operating System
1/*
2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#include <AK/Vector.h>
8#include <LibCore/ArgsParser.h>
9#include <LibCore/System.h>
10#include <LibMain/Main.h>
11#include <stdio.h>
12#include <unistd.h>
13
14ErrorOr<int> serenity_main(Main::Arguments arguments)
15{
16 TRY(Core::System::pledge("stdio cpath"));
17
18 Vector<DeprecatedString> paths;
19
20 Core::ArgsParser args_parser;
21 args_parser.add_positional_argument(paths, "Directories to remove", "paths");
22 args_parser.parse(arguments);
23
24 int status = 0;
25 for (auto path : paths) {
26 int rc = rmdir(path.characters());
27 if (rc < 0) {
28 perror("rmdir");
29 status = 1;
30 }
31 }
32 return status;
33}