modified: diffout.py
[GalaxyCodeBases.git] / funny / realpath.c
bloba4baaf5a42fe8ea8149e6d431427f5577ea2259b
1 // http://stackoverflow.com/questions/284662/how-do-you-normalize-a-file-path-in-bash
2 // also readlink -nf ~/xxx
3 // realpath.c: display the absolute path to a file or directory.
4 // Adam Liss, August, 2007
5 // This program is provided "as-is" to the public domain, without express or
6 // implied warranty, for any non-profit use, provided this notice is maintained.
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <libgen.h>
12 #include <limits.h>
14 static char *s_pMyName;
16 void usage(void);
18 int main(int argc, char *argv[])
20 char
21 sPath[PATH_MAX];
24 s_pMyName = strdup(basename(argv[0]));
26 if (argc < 2)
27 usage();
29 printf("%s\n", realpath(argv[1], sPath));
30 return 0;
33 void usage(void)
35 fprintf(stderr, "usage: %s PATH\n", s_pMyName);
36 exit(1);