apps: Add ln

This commit is contained in:
apio 2023-05-20 21:48:28 +02:00
parent 7a8ef52408
commit 4ec1af5e51
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 25 additions and 0 deletions

View File

@ -28,3 +28,4 @@ luna_app(mount.cpp mount)
luna_app(umount.cpp umount) luna_app(umount.cpp umount)
luna_app(ps.cpp ps) luna_app(ps.cpp ps)
luna_app(time.cpp time) luna_app(time.cpp time)
luna_app(ln.cpp ln)

24
apps/ln.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <os/ArgumentParser.h>
#include <stdio.h>
#include <unistd.h>
Result<int> luna_main(int argc, char** argv)
{
StringView target;
StringView link;
os::ArgumentParser parser;
parser.add_description("Create symbolic links.");
parser.add_system_program_info("ln"_sv);
parser.add_positional_argument(target, "target", true);
parser.add_positional_argument(link, "linkpath", true);
parser.parse(argc, argv);
if (symlink(target.chars(), link.chars()) < 0)
{
perror("ln");
return 1;
}
return 0;
}