6 main (int argc
, char *argv
[])
20 printf ("opendir failed: %m\n");
24 save0
= telldir (dirp
);
27 printf ("telldir failed: %m\n");
31 for (dp
= readdir (dirp
); dp
!= NULL
; dp
= readdir (dirp
))
33 /* save position 3 (after fourth entry) */
35 save3
= telldir (dirp
);
37 printf ("%s\n", dp
->d_name
);
39 /* stop at 400 (just to make sure dirp->__offset and dirp->__size are
45 printf ("going back past 4-th entry...\n");
47 /* go back to saved entry */
48 seekdir (dirp
, save3
);
50 /* Check whether telldir equals to save3 now. */
54 printf ("seekdir (d, %ld); telldir (d) == %ld\n", save3
, cur
);
58 /* print remaining files (3-last) */
59 for (dp
= readdir (dirp
); dp
!= NULL
; dp
= readdir (dirp
))
60 printf ("%s\n", dp
->d_name
);
64 rewind
= telldir (dirp
);
67 printf ("telldir failed: %m\n");
70 else if (save0
!= rewind
)
72 printf ("rewinddir didn't reset directory stream\n");