46 struct _finddata_t info;
57 size_t base_length = strlen(name);
61 size_t alloc_size =
sizeof(
DIR) + base_length + 2;
63 if((dir = (
DIR *) malloc(alloc_size)) != 0)
65 memcpy(dir->name, name, base_length);
67 if(name[base_length - 1] !=
'/' && name[base_length - 1] !=
'\\')
68 dir->name[base_length++] =
'/';
69 memcpy(dir->name + base_length,
"*", 2);
71 if((dir->handle = _findfirst(dir->name, &dir->info)) != -1)
73 dir->result.d_name = 0;
103 if(dir->handle != -1)
105 result = _findclose(dir->handle);
121 struct dirent *result = 0;
123 if(dir && dir->handle != -1)
125 if(!dir->result.d_name) {
126 result = &dir->result;
127 result->
d_name = dir->info.name;
129 int orig_errno = errno;
130 if (_findnext(dir->handle, &dir->info) != -1) {
131 result = &dir->result;
132 result->
d_name = dir->info.name;
133 }
else if (errno == ENOENT) {
152 if(dir && dir->handle != -1)
154 _findclose(dir->handle);
155 dir->handle = _findfirst(dir->name, &dir->info);
156 dir->result.d_name = 0;
struct dirent * readdir(DIR *)
DIR * opendir(const char *)
Implementation of dirent functions using WIN32 API.