mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
37 lines
911 B
C++
37 lines
911 B
C++
#include <LibCore/CArgsParser.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
CArgsParser args_parser("ln");
|
|
|
|
args_parser.add_arg("s", "create a symlink");
|
|
args_parser.add_required_single_value("target");
|
|
args_parser.add_required_single_value("link-path");
|
|
|
|
CArgsParserResult args = args_parser.parse(argc, argv);
|
|
Vector<String> values = args.get_single_values();
|
|
if (values.size() == 0) {
|
|
args_parser.print_usage();
|
|
return 0;
|
|
}
|
|
|
|
if (args.is_present("s")) {
|
|
int rc = symlink(values[0].characters(), values[1].characters());
|
|
if (rc < 0) {
|
|
perror("symlink");
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int rc = link(values[0].characters(), values[1].characters());
|
|
if (rc < 0) {
|
|
perror("link");
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|