20 #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86)
23 #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64)
35 #include <sys/types.h>
40 #define _DIRENT_HAVE_D_TYPE
43 #define _DIRENT_HAVE_D_NAMLEN
46 #if !defined(FILE_ATTRIBUTE_DEVICE)
47 # define FILE_ATTRIBUTE_DEVICE 0x40
52 # define S_IFMT _S_IFMT
57 # define S_IFDIR _S_IFDIR
62 # define S_IFCHR _S_IFCHR
66 #if !defined(S_IFFIFO)
67 # define S_IFFIFO _S_IFFIFO
72 # define S_IFREG _S_IFREG
77 # define S_IREAD _S_IREAD
81 #if !defined(S_IWRITE)
82 # define S_IWRITE _S_IWRITE
87 # define S_IEXEC _S_IEXEC
92 # define S_IFIFO _S_IFIFO
101 #if !defined(S_IFLNK)
106 #if !defined(S_IFSOCK)
111 #if !defined(S_IRUSR)
112 # define S_IRUSR S_IREAD
116 #if !defined(S_IWUSR)
117 # define S_IWUSR S_IWRITE
121 #if !defined(S_IXUSR)
126 #if !defined(S_IRGRP)
131 #if !defined(S_IWGRP)
136 #if !defined(S_IXGRP)
141 #if !defined(S_IROTH)
146 #if !defined(S_IWOTH)
151 #if !defined(S_IXOTH)
156 #if !defined(PATH_MAX)
157 # define PATH_MAX MAX_PATH
159 #if !defined(FILENAME_MAX)
160 # define FILENAME_MAX MAX_PATH
162 #if !defined(NAME_MAX)
163 # define NAME_MAX FILENAME_MAX
168 #define DT_REG S_IFREG
169 #define DT_DIR S_IFDIR
170 #define DT_FIFO S_IFIFO
171 #define DT_SOCK S_IFSOCK
172 #define DT_CHR S_IFCHR
173 #define DT_BLK S_IFBLK
174 #define DT_LNK S_IFLNK
177 #define IFTODT(mode) ((mode) & S_IFMT)
178 #define DTTOIF(type) (type)
186 #if !defined(S_ISFIFO)
187 # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
189 #if !defined(S_ISDIR)
190 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
192 #if !defined(S_ISREG)
193 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
195 #if !defined(S_ISLNK)
196 # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
198 #if !defined(S_ISSOCK)
199 # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
201 #if !defined(S_ISCHR)
202 # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
204 #if !defined(S_ISBLK)
205 # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
209 #define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
212 #define _D_ALLOC_NAMLEN(p) (PATH_MAX)
264 #define wdirent _wdirent
266 #define wopendir _wopendir
267 #define wreaddir _wreaddir
268 #define wclosedir _wclosedir
269 #define wrewinddir _wrewinddir
308 size_t *pReturnValue,
315 size_t *pReturnValue,
318 const wchar_t *wcstr,
330 const wchar_t *dirname)
336 if (dirname == NULL || dirname[0] ==
'\0') {
342 dirp = (
_WDIR*) malloc (
sizeof (
struct _WDIR));
347 dirp->
handle = INVALID_HANDLE_VALUE;
352 n = GetFullPathNameW (dirname, 0, NULL, NULL);
355 dirp->
patt = (
wchar_t*) malloc (
sizeof (
wchar_t) * n + 16);
363 n = GetFullPathNameW (dirname, n, dirp->
patt, NULL);
369 if (dirp->
patt < p) {
431 WIN32_FIND_DATAW *datap;
449 while (n + 1 <
PATH_MAX && datap->cFileName[n] != 0) {
450 entp->
d_name[n] = datap->cFileName[n];
459 attr = datap->dwFileAttributes;
462 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
495 if (dirp->
handle != INVALID_HANDLE_VALUE) {
497 dirp->
handle = INVALID_HANDLE_VALUE;
528 if (dirp->
handle != INVALID_HANDLE_VALUE) {
538 static WIN32_FIND_DATAW*
542 WIN32_FIND_DATAW *datap;
546 if (dirp->
handle != INVALID_HANDLE_VALUE) {
563 static WIN32_FIND_DATAW*
576 }
else if (dirp->
handle != INVALID_HANDLE_VALUE) {
579 if (FindNextFileW (dirp->
handle, &dirp->
data) != FALSE) {
585 dirp->
handle = INVALID_HANDLE_VALUE;
610 if (dirname == NULL || dirname[0] ==
'\0') {
616 dirp = (
DIR*) malloc (
sizeof (
struct DIR));
676 WIN32_FIND_DATAW *datap;
699 if (error && datap->cAlternateFileName[0] !=
'\0') {
702 datap->cAlternateFileName,
PATH_MAX);
715 attr = datap->dwFileAttributes;
718 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
793 size_t *pReturnValue,
801 #if defined(_MSC_VER) && _MSC_VER >= 1400
804 error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
812 n = mbstowcs (wcstr, mbstr, sizeInWords);
813 if (!wcstr || n < count) {
816 if (wcstr && sizeInWords) {
817 if (n >= sizeInWords) {
825 *pReturnValue = n + 1;
846 size_t *pReturnValue,
849 const wchar_t *wcstr,
854 #if defined(_MSC_VER) && _MSC_VER >= 1400
857 error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
865 n = wcstombs (mbstr, wcstr, sizeInBytes);
866 if (!mbstr || n < count) {
869 if (mbstr && sizeInBytes) {
870 if (n >= sizeInBytes) {
878 *pReturnValue = n + 1;
901 #if defined(_MSC_VER) && _MSC_VER >= 1400
static void dirent_set_errno(int error)
static int dirent_mbstowcs_s(size_t *pReturnValue, wchar_t *wcstr, size_t sizeInWords, const char *mbstr, size_t count)
static WIN32_FIND_DATAW * dirent_first(_WDIR *dirp)
static struct _wdirent * _wreaddir(_WDIR *dirp)
static int closedir(DIR *dirp)
static void rewinddir(DIR *dirp)
static void _wrewinddir(_WDIR *dirp)
static DIR * opendir(const char *dirname)
static int dirent_wcstombs_s(size_t *pReturnValue, char *mbstr, size_t sizeInBytes, const wchar_t *wcstr, size_t count)
static _WDIR * _wopendir(const wchar_t *dirname)
static struct dirent * readdir(DIR *dirp)
static int _wclosedir(_WDIR *dirp)
static WIN32_FIND_DATAW * dirent_next(_WDIR *dirp)
#define FILE_ATTRIBUTE_DEVICE