mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +00:00
Userland: Add realpath
This commit is contained in:
parent
2ca8158a73
commit
e36b9635df
1 changed files with 22 additions and 0 deletions
22
Userland/realpath.cpp
Normal file
22
Userland/realpath.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
printf("usage: realpath <path>\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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue