blob: 8b825cb4d34b437784520d1faf9ec65aa1805cec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#include <dirent.h>
#include <unistd.h>
struct dirent *readdir(DIR *dir) {
size_t offset = dir->dir_num * sizeof(struct dirent);
int rc;
if (-1 == (rc = pread(dir->fd, &dir->internal_direntry, sizeof(struct dirent),
offset)))
return NULL;
if (rc < (int)sizeof(struct dirent))
return NULL;
dir->dir_num++;
return &(dir->internal_direntry);
}
|