Mail Archives: djgpp-workers/1999/05/16/18:21:47
> > : Otherwise it returns a NULL pointer and places in
> > : resolved_path the absolute pathname of the path component
> > : which could not be resolved.
>
> This is not very specific, and in fact I could interpret this in several
> ways. Could you please throw together a short test program and see what
> it does with non-existent file names?
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/param.h>
int main ()
{
char resolved_path [MAXPATHLEN];
char *rp;
printf ("Trying /bin/../usr/bin/foo/bar/baz\n");
rp = realpath ("/bin/../usr/bin/foo/bar/baz", resolved_path);
printf ("realpath returns: %s\n", rp ? rp : "NULL");
printf ("resolved_path contains: %s\n\n", resolved_path);
printf ("Trying /usr/../bin\n");
rp = realpath ("/usr/../bin", resolved_path);
printf ("realpath returns: %s\n", rp ? rp : "NULL");
printf ("resolved_path contains: %s\n\n", resolved_path);
return 0;
}
Under Linux (2.2.7, libc 5.4.46) it says:
Trying /bin/../usr/bin/foo/bar/baz
realpath returns: NULL
resolved_path contains: /usr/bin/foo
Trying /usr/../bin
realpath returns: /bin
resolved_path contains: /bin
(/usr/bin/foo, of course, does not exist on my system.)
Frank
--
Frank Heckenbach, frank AT fjf DOT gnu DOT de
http://fjf.gnu.de/
PGP and GPG keys: http://fjf.gnu.de/plan
- Raw text -