cp: Port to LibMain :^)

This commit is contained in:
Andreas Kling 2021-11-26 22:35:16 +01:00
parent f1cc3d0fc4
commit 0b8fb8358e
Notes: sideshowbarker 2024-07-18 00:38:45 +09:00
2 changed files with 7 additions and 10 deletions

View File

@ -64,6 +64,7 @@ target_link_libraries(chres LibGUI)
target_link_libraries(cksum LibCrypto)
target_link_libraries(config LibConfig)
target_link_libraries(copy LibGUI LibMain)
target_link_libraries(cp LibMain)
target_link_libraries(diff LibDiff)
target_link_libraries(disasm LibX86)
target_link_libraries(dmesg LibMain)

View File

@ -7,15 +7,14 @@
#include <AK/LexicalPath.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
if (pledge("stdio rpath wpath cpath fattr chown", nullptr) < 0) {
perror("pledge");
return 1;
}
TRY(Core::System::pledge("stdio rpath wpath cpath fattr chown", nullptr));
bool link = false;
bool preserve = false;
@ -32,15 +31,12 @@ int main(int argc, char** argv)
args_parser.add_option(verbose, "Verbose", "verbose", 'v');
args_parser.add_positional_argument(sources, "Source file paths", "source");
args_parser.add_positional_argument(destination, "Destination file path", "destination");
args_parser.parse(argc, argv);
args_parser.parse(arguments);
if (preserve) {
umask(0);
} else {
if (pledge("stdio rpath wpath cpath fattr", nullptr) < 0) {
perror("pledge");
return 1;
}
TRY(Core::System::pledge("stdio rpath wpath cpath fattr", nullptr));
}
bool destination_is_existing_dir = Core::File::is_directory(destination);