1 #include "../git-compat-util.h"
6 DIR *opendir(const char *name
)
8 DWORD attrs
= GetFileAttributes(name
);
12 /* check for valid path */
13 if (attrs
== INVALID_FILE_ATTRIBUTES
) {
18 /* check if it's a directory */
19 if (!(attrs
& FILE_ATTRIBUTE_DIRECTORY
)) {
24 /* check that the pattern won't be too long for FindFirstFileA */
26 if (is_dir_sep(name
[len
- 1]))
28 if (len
+ 2 >= MAX_PATH
) {
33 p
= malloc(sizeof(DIR) + len
+ 2);
37 memset(p
, 0, sizeof(DIR) + len
+ 2);
38 strcpy(p
->dd_name
, name
);
39 p
->dd_name
[len
] = '/';
40 p
->dd_name
[len
+1] = '*';
42 p
->dd_handle
= (long)INVALID_HANDLE_VALUE
;
45 int closedir(DIR *dir
)
52 if (dir
->dd_handle
!= (long)INVALID_HANDLE_VALUE
)
53 FindClose((HANDLE
)dir
->dd_handle
);