#include <wchar.h>
|
#include <dirent.h>
|
off_t
wtelldir (WDIR *dirp); |
void
wseekdir (WDIR *dirp, long loc); |
wtelldir function returns current location associated with the named directory stream on success or -1 on failure.
The wseekdir function sets the position of the next wreaddir operation on the directory stream. The new position reverts to the one associated with the directory stream when the wtelldir operation was performed.
#include <dirent.h> #include<wchar.h> #include<stdio.h> #include<unistd.h> #include<sys/types.h> void wTest() { //declare the variables for dir pointer and dir position. wchar_t *dirName =L"c:\test_wseekdir"; off_t dirpos; // Open the directory WDIR *dirp = wopendir (dirName); if(dirp != NULL) { //read the directory. wreaddir(dirp); wreaddir(dirp); //get the dirp pointer position by calling telldir API. dirpos = wtelldir(dirp); //print the position of the dirp pointer. printf(“dirp is pointing at position %ld. \n”,dirpos); wseekdir(dirp , 0) ; wreaddir(dirp); dirpos = wtelldir(dirp); //print the position of the dirp pointer. printf(“dirp is pointing at position %ld. \n”,dirpos); } }
Output
Dirp is pointing at position 2. Dirp is pointing at position 1.
[EFAULT] | |
A directory pointer dirp is not valid.
|
|
© 2005-2007 Nokia |