12 DIR *opendir (const char * a_dir
)
16 DIR* dd_dir
= (DIR*) malloc (sizeof(DIR));
18 char *c_dir
= malloc (strlen(a_dir
) + 4);
19 strcpy (c_dir
, a_dir
);
20 strcat (c_dir
, "\\*");
22 dd_dir
->d_handle
= FindFirstFile (c_dir
, &wfd
);
23 if (dd_dir
->d_handle
== INVALID_HANDLE_VALUE
) {
26 case ERROR_NO_MORE_FILES
:
27 case ERROR_FILE_NOT_FOUND
:
28 case ERROR_PATH_NOT_FOUND
:
31 case ERROR_NOT_ENOUGH_MEMORY
:
41 dd_dir
->d_attr
= (wfd
.dwFileAttributes
== FILE_ATTRIBUTE_NORMAL
)
42 ? 0 : wfd
.dwFileAttributes
;
44 dd_dir
->d_time
= dd_dir
->d_date
= 10;
45 dd_dir
->d_size
= wfd
.nFileSizeLow
;
46 strcpy (dd_dir
->d_name
, wfd
.cFileName
);
53 DIR *readdir( DIR * dd_dir
)
58 if (dd_dir
->d_first
) {
63 if(!FindNextFile (dd_dir
->d_handle
, &wfd
)) {
66 case ERROR_NO_MORE_FILES
:
67 case ERROR_FILE_NOT_FOUND
:
68 case ERROR_PATH_NOT_FOUND
:
71 case ERROR_NOT_ENOUGH_MEMORY
:
80 dd_dir
->d_attr
= (wfd
.dwFileAttributes
== FILE_ATTRIBUTE_NORMAL
)
81 ? 0 : wfd
.dwFileAttributes
;
83 dd_dir
->d_time
= dd_dir
->d_date
= 10;
84 dd_dir
->d_size
= wfd
.nFileSizeLow
;
85 strcpy (dd_dir
->d_name
, wfd
.cFileName
);
89 int closedir (DIR *dd_dir
)
91 FindClose(dd_dir
->d_handle
);