This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/rewinddi.c

38 lines
880 B
C

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.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 );
}
}