Name

wrealpath - returns the canonicalized absolute pathname

Library

libc.lib

Synopsis

  #include <sys/param.h>
  #include <wchar.h>
  wchar_t * wrealpath (const wchar_t *pathname, wchar_t resolved_path[PATH_MAX]);

Return values

The wrealpath function returns resolved_path on success. If an error occurs, wrealpath returns NULL, and resolved_path contains the pathname which caused the problem.

Detailed description

The wrealpath function resolves all extra "/" characters and references to /./ and /../ in pathname, and copies the resulting absolute pathname into the memory referenced by resolved_path. The resolved_path argument must refer to a buffer capable of storing at least PATH_MAX characters.

The wrealpath function will resolve both absolute and relative paths and return the absolute pathname corresponding to pathname. All but the last component of pathname must exist when wrealpath is called.


Examples

#include<stdlib.h>
#include<stdio.h> //printf
#include<sys/stat.h> //S_IWUSR
#include<sys/syslimits.h> //PATH_MAX
#include<unistd.h> //chdir
#inlclude<wchar.h>
 
int main()
{
 wchar_t resolvepath[PATH_MAX];
 FILE *fp = NULL;
 wchar_t *rpath = NULL;
  
 fp = wfopen(L"c:\\xyz.txt", L"w");
 if(!fp)
 {
     printf("wfopen failed!!");
     return -1;
 }
    
 wmkdir(L"c:\\tmdir", S_IWUSR);
  
 int c = wchdir(L"c:\\");
 if(c == -1)
 {
     printf("wchdir failed!!");
     return -1;
 }
  
 rpath = wrealpath(L".\\tmdir\\..\\xyz.txt", resolvepath);
 printf("resolvepath: L%s\n", resolvepath);
 if(rpath != NULL)
    printf("rpath: L%s\n\n", rpath);
  
 fclose(fp);
 wrmdir(L"c:\\tmdir");
 wunlink(L"c:\\xyz.txt");
 return 0;
}

         

Output

resolvepath: C:\xyz.txt
rpath: C:\xyz.txt

         

Errors

The function wrealpath may fail and set the external variable errno for any of the errors specified for the library functions readlink and getcwd.

See also

getcwd

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top