#include <sys/param.h>
|
#include <wchar.h>
|
wchar_t *
wrealpath (const wchar_t *pathname, wchar_t resolved_path[PATH_MAX]); |
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.
#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
© 2008 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user. |