Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040622
Hello,
I've had a few occasions now where I would have liked to be able to get
the absolute name of a file in a script, or for some other reasons (such
as knowing on which partition my file is actually located - don't ask).
Anyway, the attached program will allow for this, simply compile, give
it a relative path and it'll give you the complete path.
Yes I'm aware that it is a very simple program but useful none the less.
Jaco
===========================================
This message and attachments are subject to a disclaimer. Please refer to
www.it.up.ac.za/documentation/governance/disclaimer/ for full details.
Hierdie boodskap en aanhangsels is aan 'n vrywaringsklousule onderhewig.
Volledige besonderhede is by
www.it.up.ac.za/documentation/governance/disclaimer/ beskikbaar.
===========================================
/*
* realpath program by address@hidden
* This program is hereby placed under GPL.
*/
#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)
{
fprintf(stderr, "%s: too few arguments\nUSAGE: %s
relative_path\n", argv[0], argv[0]);
exit(-1);
}
if(realpath(argv[1], resolved_path))
{
printf("%s\n", resolved_path);
exit(0);
}
else
{
perror(argv[1]);
exit(errno);
}
}