Name

wtelldir, wseekdir
- directory operations

Library

libc.lib

Synopsis

  #include <wchar.h>
  #include <dirent.h>

  off_t wtelldir (WDIR *dirp);
  void wseekdir (WDIR *dirp, long loc);

Return values

wtelldir function returns current location associated with the named directory stream on success or -1 on failure.


Detailed description

The wtelldir function returns the current location associated with the named directory stream. Values returned by wtelldir are good only for the lifetime of the DIR pointer, dirp, from which they are derived. If the directory is closed and then reopened, prior values returned by wtelldir will no longer be valid.

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.


Examples

#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.

         

Errors

[EFAULT]
  A directory pointer dirp is not valid.



See also

wclosedir, wopendir, wreaddir


Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top