FindPage
View Source:
realpath.c
<code brush="c"> #include <stdio.h> #include <limits.h> #include <stdlib.h> #include <errno.h> int main (int argc, char **argv) { char resolved_path[PATH_MAX]; if (argc != 2) { printf("Usage: realpath <path>\n"); return 1; } else { if(realpath(argv[1], resolved_path) != NULL) { printf("%s\n", resolved_path); return 0; } if (errno) { fprintf(stderr, "realpath: %s: %s\n", argv[1], strerror(errno)); return errno; } } return 255; } </code>