43 #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86)
46 #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64)
58 #include <sys/types.h>
63 #define _DIRENT_HAVE_D_TYPE
66 #define _DIRENT_HAVE_D_NAMLEN
69 #if !defined(FILE_ATTRIBUTE_DEVICE)
70 # define FILE_ATTRIBUTE_DEVICE 0x40
75 # define S_IFMT _S_IFMT
80 # define S_IFDIR _S_IFDIR
85 # define S_IFCHR _S_IFCHR
89 #if !defined(S_IFFIFO)
90 # define S_IFFIFO _S_IFFIFO
95 # define S_IFREG _S_IFREG
100 # define S_IREAD _S_IREAD
104 #if !defined(S_IWRITE)
105 # define S_IWRITE _S_IWRITE
109 #if !defined(S_IEXEC)
110 # define S_IEXEC _S_IEXEC
114 #if !defined(S_IFIFO)
115 # define S_IFIFO _S_IFIFO
119 #if !defined(S_IFBLK)
124 #if !defined(S_IFLNK)
129 #if !defined(S_IFSOCK)
134 #if !defined(S_IRUSR)
135 # define S_IRUSR S_IREAD
139 #if !defined(S_IWUSR)
140 # define S_IWUSR S_IWRITE
144 #if !defined(S_IXUSR)
149 #if !defined(S_IRGRP)
154 #if !defined(S_IWGRP)
159 #if !defined(S_IXGRP)
164 #if !defined(S_IROTH)
169 #if !defined(S_IWOTH)
174 #if !defined(S_IXOTH)
179 #if !defined(PATH_MAX)
180 # define PATH_MAX MAX_PATH
182 #if !defined(FILENAME_MAX)
183 # define FILENAME_MAX MAX_PATH
185 #if !defined(NAME_MAX)
186 # define NAME_MAX FILENAME_MAX
191 #define DT_REG S_IFREG
192 #define DT_DIR S_IFDIR
193 #define DT_FIFO S_IFIFO
194 #define DT_SOCK S_IFSOCK
195 #define DT_CHR S_IFCHR
196 #define DT_BLK S_IFBLK
197 #define DT_LNK S_IFLNK
200 #define IFTODT(mode) ((mode) & S_IFMT)
201 #define DTTOIF(type) (type)
209 #if !defined(S_ISFIFO)
210 # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
212 #if !defined(S_ISDIR)
213 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
215 #if !defined(S_ISREG)
216 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
218 #if !defined(S_ISLNK)
219 # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
221 #if !defined(S_ISSOCK)
222 # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
224 #if !defined(S_ISCHR)
225 # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
227 #if !defined(S_ISBLK)
228 # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
232 #define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
235 #define _D_ALLOC_NAMLEN(p) (PATH_MAX)
287 #define wdirent _wdirent
289 #define wopendir _wopendir
290 #define wreaddir _wreaddir
291 #define wclosedir _wclosedir
292 #define wrewinddir _wrewinddir
331 size_t *pReturnValue,
338 size_t *pReturnValue,
341 const wchar_t *wcstr,
353 const wchar_t *dirname)
359 if (dirname == NULL || dirname[0] ==
'\0') {
365 dirp = (
_WDIR*) malloc (
sizeof (
struct _WDIR));
370 dirp->
handle = INVALID_HANDLE_VALUE;
375 n = GetFullPathNameW (dirname, 0, NULL, NULL);
378 dirp->
patt = (
wchar_t*) malloc (
sizeof (
wchar_t) * n + 16);
386 n = GetFullPathNameW (dirname, n, dirp->
patt, NULL);
392 if (dirp->
patt < p) {
454 WIN32_FIND_DATAW *datap;
472 while (n + 1 <
PATH_MAX && datap->cFileName[n] != 0) {
473 entp->
d_name[n] = datap->cFileName[n];
482 attr = datap->dwFileAttributes;
485 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
518 if (dirp->
handle != INVALID_HANDLE_VALUE) {
520 dirp->
handle = INVALID_HANDLE_VALUE;
551 if (dirp->
handle != INVALID_HANDLE_VALUE) {
561 static WIN32_FIND_DATAW*
565 WIN32_FIND_DATAW *datap;
569 if (dirp->
handle != INVALID_HANDLE_VALUE) {
586 static WIN32_FIND_DATAW*
599 }
else if (dirp->
handle != INVALID_HANDLE_VALUE) {
602 if (FindNextFileW (dirp->
handle, &dirp->
data) != FALSE) {
608 dirp->
handle = INVALID_HANDLE_VALUE;
633 if (dirname == NULL || dirname[0] ==
'\0') {
639 dirp = (
DIR*) malloc (
sizeof (
struct DIR));
699 WIN32_FIND_DATAW *datap;
722 if (error && datap->cAlternateFileName[0] !=
'\0') {
725 datap->cAlternateFileName,
PATH_MAX);
738 attr = datap->dwFileAttributes;
741 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
816 size_t *pReturnValue,
824 #if defined(_MSC_VER) && _MSC_VER >= 1400
827 error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
835 n = mbstowcs (wcstr, mbstr, sizeInWords);
836 if (!wcstr || n < count) {
839 if (wcstr && sizeInWords) {
840 if (n >= sizeInWords) {
848 *pReturnValue = n + 1;
869 size_t *pReturnValue,
872 const wchar_t *wcstr,
877 #if defined(_MSC_VER) && _MSC_VER >= 1400
880 error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
888 n = wcstombs (mbstr, wcstr, sizeInBytes);
889 if (!mbstr || n < count) {
892 if (mbstr && sizeInBytes) {
893 if (n >= sizeInBytes) {
901 *pReturnValue = n + 1;
924 #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