Lines Matching refs:dir

36 do_seek_dir(DIR* dir)
38 if (dir->seek_position == dir->current_position)
43 if (dir->seek_position < dir->current_position) {
44 status_t status = _kern_rewind_dir(dir->fd);
50 dir->current_position = 0;
51 dir->entries_left = 0;
55 while (dir->seek_position > dir->current_position) {
57 long toSkip = dir->seek_position - dir->current_position;
58 if (toSkip == dir->entries_left) {
60 dir->current_position = dir->seek_position;
61 dir->entries_left = 0;
65 if (toSkip < dir->entries_left) {
69 ((uint8*)&dir->first_entry + dir->next_entry);
70 dir->entries_left--;
71 dir->next_entry += entry->d_reclen;
74 dir->current_position = dir->seek_position;
79 dir->current_position += dir->entries_left;
80 dir->entries_left = 0;
82 count = _kern_read_dir(dir->fd, &dir->first_entry,
83 (char*)dir + DIR_BUFFER_SIZE - (char*)&dir->first_entry, USHRT_MAX);
92 dir->next_entry = 0;
93 dir->entries_left = count;
108 DIR* dir = (DIR*)malloc(DIR_BUFFER_SIZE);
109 if (dir == NULL) {
114 dir->fd = fd;
115 dir->entries_left = 0;
116 dir->seek_position = 0;
117 dir->current_position = 0;
119 return dir;
129 DIR* dir;
152 dir = __create_dir_struct(dirFD);
153 if (dir == NULL) {
158 return dir;
165 DIR* dir;
174 if ((dir = __create_dir_struct(fd)) == NULL) {
179 return dir;
184 closedir(DIR* dir)
188 if (dir == NULL) {
193 status = _kern_close(dir->fd);
195 free(dir);
202 readdir(DIR* dir)
206 if (dir->seek_position != dir->current_position) {
207 if (do_seek_dir(dir) != 0)
211 if (dir->entries_left > 0) {
213 = (struct dirent *)((uint8 *)&dir->first_entry + dir->next_entry);
215 dir->entries_left--;
216 dir->next_entry += dirent->d_reclen;
217 dir->seek_position++;
218 dir->current_position++;
225 count = _kern_read_dir(dir->fd, &dir->first_entry,
226 (char*)dir + DIR_BUFFER_SIZE - (char*)&dir->first_entry, USHRT_MAX);
235 dir->entries_left = count - 1;
236 dir->next_entry = dir->first_entry.d_reclen;
237 dir->seek_position++;
238 dir->current_position++;
240 return &dir->first_entry;
245 readdir_r(DIR* dir, struct dirent* entry, struct dirent** _result)
250 struct dirent* dirent = readdir(dir);
263 rewinddir(DIR* dir)
265 dir->seek_position = 0;
270 seekdir(DIR* dir, long int position)
272 dir->seek_position = position;
277 telldir(DIR* dir)
279 return dir->seek_position;
284 dirfd(DIR* dir)
286 return dir->fd;