25 struct _finddata_t info;
30 DIR *opendir(
const char *name)
36 size_t base_length = strlen(name);
38 strchr(
"/\\", name[base_length - 1]) ?
"*" :
"/*";
40 if((dir = (DIR *) malloc(
sizeof *dir)) != 0 &&
41 (dir->name = (
char *) malloc(base_length + strlen(all) + 1)) != 0)
43 strcat(strcpy(dir->name, name), all);
45 if((dir->handle = (
long) _findfirst(dir->name, &dir->info)) != -1)
47 dir->result.d_name = 0;
71 int closedir(DIR *dir)
79 result = _findclose(dir->handle);
94 struct dirent *readdir(DIR *dir)
96 struct dirent *result = 0;
98 if(dir && dir->handle != -1)
100 if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
102 result = &dir->result;
103 result->d_name = dir->info.name;
114 void rewinddir(DIR *dir)
116 if(dir && dir->handle != -1)
118 _findclose(dir->handle);
119 dir->handle = (long) _findfirst(dir->name, &dir->info);
120 dir->result.d_name = 0;