mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
77dfd419e9
Also rename the classes to match LibCore naming style. This means that it's no longer incorrectly linked into LibC and Kernel.
38 lines
926 B
C++
38 lines
926 B
C++
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <LibCore/CArgsParser.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, (const char**)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;
|
|
}
|
|
|