2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2021-01-12 14:13:07 +11:00
|
|
|
#include <AK/Vector.h>
|
2020-08-05 20:30:18 +02:00
|
|
|
#include <LibCore/ArgsParser.h>
|
2022-01-24 20:59:22 -05:00
|
|
|
#include <LibCore/System.h>
|
|
|
|
#include <LibMain/Main.h>
|
2019-06-07 11:49:31 +02:00
|
|
|
#include <stdio.h>
|
2019-01-28 04:16:01 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2022-01-24 20:59:22 -05:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2019-01-28 04:16:01 +01:00
|
|
|
{
|
2022-01-24 20:59:22 -05:00
|
|
|
TRY(Core::System::pledge("stdio cpath"));
|
2020-02-18 10:45:23 +01:00
|
|
|
|
2022-04-02 16:48:05 +01:00
|
|
|
Vector<String> paths;
|
2020-08-05 20:30:18 +02:00
|
|
|
|
|
|
|
Core::ArgsParser args_parser;
|
2021-01-12 14:13:07 +11:00
|
|
|
args_parser.add_positional_argument(paths, "Directories to remove", "paths");
|
2022-01-24 20:59:22 -05:00
|
|
|
args_parser.parse(arguments);
|
2020-08-05 20:30:18 +02:00
|
|
|
|
2021-01-12 14:13:07 +11:00
|
|
|
int status = 0;
|
|
|
|
for (auto path : paths) {
|
2022-04-02 16:48:05 +01:00
|
|
|
int rc = rmdir(path.characters());
|
2021-01-12 14:13:07 +11:00
|
|
|
if (rc < 0) {
|
|
|
|
perror("rmdir");
|
|
|
|
status = 1;
|
|
|
|
}
|
2019-01-28 04:16:01 +01:00
|
|
|
}
|
2021-01-12 14:13:07 +11:00
|
|
|
return status;
|
2019-01-28 04:16:01 +01:00
|
|
|
}
|