Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <sys\types.h>
    #include <direct.h>
    void rewinddir( struct dirent *dirp );
    void _wrewinddir( _wdirent *dirp );

Description:
    The rewinddir function resets the position of the directory stream to
    which dirp refers to the beginning of the directory.  It also causes the
    directory stream to refer to the current state of the corresponding
    directory, as a call to  opendir would have done.

    The _wrewinddir function is identical to rewinddir except that it
    rewinds a directory of wide-character filenames opened by  _wopendir.

Returns:
    The rewinddir function does not return a value.

Example:
    The following example lists all the files in a directory, creates a new
    file, and then relists the directory.

    #include <stdio.h>
    #include <sys\types.h>
    #include <sys\stat.h>
    #include <direct.h>

    void main()
      {
        DIR *dirp;
        struct dirent *direntp;
        int handle;

        dirp = opendir( "\\watcom\\h\\*.*" );
        if( dirp != NULL ) {
          printf( "Old directory listing\n" );
          for(;;) {
              direntp = readdir( dirp );
              if( direntp == NULL ) break;
              printf( "%s\n", direntp->d_name );
          }

          handle = creat( "\\watcom\\h\\file.new",
                      S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
          close( handle );

          rewinddir( dirp );
          printf( "New directory listing\n" );
          for(;;) {
            direntp = readdir( dirp );
            if( direntp == NULL ) break;
            printf( "%s\n", direntp->d_name );
          }
          closedir( dirp );
        }
      }

    Note the use of two adjacent backslash characters (\) within
    character-string constants to signify a single backslash.

Classification:
    rewinddir is POSIX 1003.1, _wrewinddir is not POSIX

Systems:
     rewinddir - All

    _wrewinddir - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    closedir, _dos_find Functions, opendir, readdir

See Also:

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson