From e36b9635df73e8d044dbc0b835af6de9171135d7 Mon Sep 17 00:00:00 2001 From: Rok Povsic Date: Sun, 25 Aug 2019 18:17:47 +0200 Subject: [PATCH] Userland: Add realpath --- Userland/realpath.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Userland/realpath.cpp diff --git a/Userland/realpath.cpp b/Userland/realpath.cpp new file mode 100644 index 0000000000..680e23af0b --- /dev/null +++ b/Userland/realpath.cpp @@ -0,0 +1,22 @@ +#include +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + if (argc != 2) { + printf("usage: realpath \n"); + return 1; + } + + char* value = realpath(argv[1], nullptr); + if (value == nullptr) { + printf("realpath() error: %s\n", strerror(errno)); + return 1; + } + printf("%s\n", value); + free(value); + return 0; +}