1 #define GIT__WIN32_NO_WRAP_DIR
4 static int init_filter(char *filter
, size_t n
, const char *dir
)
6 size_t len
= strlen(dir
);
12 if (len
&& dir
[len
-1] != '/')
19 git__DIR
*git__opendir(const char *dir
)
24 if (!dir
|| !init_filter(filter
, sizeof(filter
), dir
))
27 new = git__malloc(sizeof(*new));
31 new->dir
= git__malloc(strlen(dir
)+1);
36 strcpy(new->dir
, dir
);
38 new->h
= FindFirstFile(filter
, &new->f
);
39 if (new->h
== INVALID_HANDLE_VALUE
) {
49 struct git__dirent
*git__readdir(git__DIR
*d
)
51 if (!d
|| d
->h
== INVALID_HANDLE_VALUE
)
57 if (!FindNextFile(d
->h
, &d
->f
))
61 if (strlen(d
->f
.cFileName
) >= sizeof(d
->entry
.d_name
))
65 strcpy(d
->entry
.d_name
, d
->f
.cFileName
);
70 void git__rewinddir(git__DIR
*d
)
75 if (d
->h
!= INVALID_HANDLE_VALUE
)
77 d
->h
= INVALID_HANDLE_VALUE
;
79 if (init_filter(filter
, sizeof(filter
), d
->dir
)) {
80 d
->h
= FindFirstFile(filter
, &d
->f
);
81 if (d
->h
!= INVALID_HANDLE_VALUE
)
87 int git__closedir(git__DIR
*d
)
90 if (d
->h
!= INVALID_HANDLE_VALUE
)