42 #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86) 45 #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64) 57 #include <sys/types.h> 62 #define _DIRENT_HAVE_D_TYPE 65 #define _DIRENT_HAVE_D_NAMLEN 68 #if !defined(FILE_ATTRIBUTE_DEVICE) 69 # define FILE_ATTRIBUTE_DEVICE 0x40 74 # define S_IFMT _S_IFMT 79 # define S_IFDIR _S_IFDIR 84 # define S_IFCHR _S_IFCHR 88 #if !defined(S_IFFIFO) 89 # define S_IFFIFO _S_IFFIFO 94 # define S_IFREG _S_IFREG 99 # define S_IREAD _S_IREAD 103 #if !defined(S_IWRITE) 104 # define S_IWRITE _S_IWRITE 108 #if !defined(S_IEXEC) 109 # define S_IEXEC _S_IEXEC 113 #if !defined(S_IFIFO) 114 # define S_IFIFO _S_IFIFO 118 #if !defined(S_IFBLK) 123 #if !defined(S_IFLNK) 128 #if !defined(S_IFSOCK) 133 #if !defined(S_IRUSR) 134 # define S_IRUSR S_IREAD 138 #if !defined(S_IWUSR) 139 # define S_IWUSR S_IWRITE 143 #if !defined(S_IXUSR) 148 #if !defined(S_IRGRP) 153 #if !defined(S_IWGRP) 158 #if !defined(S_IXGRP) 163 #if !defined(S_IROTH) 168 #if !defined(S_IWOTH) 173 #if !defined(S_IXOTH) 178 #if !defined(PATH_MAX) 179 # define PATH_MAX MAX_PATH 181 #if !defined(FILENAME_MAX) 182 # define FILENAME_MAX MAX_PATH 184 #if !defined(NAME_MAX) 185 # define NAME_MAX FILENAME_MAX 190 #define DT_REG S_IFREG 191 #define DT_DIR S_IFDIR 192 #define DT_FIFO S_IFIFO 193 #define DT_SOCK S_IFSOCK 194 #define DT_CHR S_IFCHR 195 #define DT_BLK S_IFBLK 196 #define DT_LNK S_IFLNK 199 #define IFTODT(mode) ((mode) & S_IFMT) 200 #define DTTOIF(type) (type) 208 #if !defined(S_ISFIFO) 209 # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) 211 #if !defined(S_ISDIR) 212 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 214 #if !defined(S_ISREG) 215 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) 217 #if !defined(S_ISLNK) 218 # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) 220 #if !defined(S_ISSOCK) 221 # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) 223 #if !defined(S_ISCHR) 224 # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) 226 #if !defined(S_ISBLK) 227 # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) 231 #define _D_EXACT_NAMLEN(p) ((p)->d_namlen) 234 #define _D_ALLOC_NAMLEN(p) (PATH_MAX) 286 #define wdirent _wdirent 288 #define wopendir _wopendir 289 #define wreaddir _wreaddir 290 #define wclosedir _wclosedir 291 #define wrewinddir _wrewinddir 330 size_t *pReturnValue,
337 size_t *pReturnValue,
340 const wchar_t *wcstr,
352 const wchar_t *dirname)
358 if (dirname == NULL || dirname[0] ==
'\0') {
364 dirp = (
_WDIR*) malloc (
sizeof (
struct _WDIR));
369 dirp->
handle = INVALID_HANDLE_VALUE;
374 n = GetFullPathNameW (dirname, 0, NULL, NULL);
377 dirp->
patt = (
wchar_t*) malloc (
sizeof (
wchar_t) * n + 16);
385 n = GetFullPathNameW (dirname, n, dirp->
patt, NULL);
391 if (dirp->
patt < p) {
453 WIN32_FIND_DATAW *datap;
471 while (n + 1 <
PATH_MAX && datap->cFileName[n] != 0) {
472 entp->
d_name[n] = datap->cFileName[n];
481 attr = datap->dwFileAttributes;
484 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
517 if (dirp->
handle != INVALID_HANDLE_VALUE) {
519 dirp->
handle = INVALID_HANDLE_VALUE;
550 if (dirp->
handle != INVALID_HANDLE_VALUE) {
560 static WIN32_FIND_DATAW*
564 WIN32_FIND_DATAW *datap;
568 if (dirp->
handle != INVALID_HANDLE_VALUE) {
585 static WIN32_FIND_DATAW*
598 }
else if (dirp->
handle != INVALID_HANDLE_VALUE) {
601 if (FindNextFileW (dirp->
handle, &dirp->
data) != FALSE) {
607 dirp->
handle = INVALID_HANDLE_VALUE;
632 if (dirname == NULL || dirname[0] ==
'\0') {
638 dirp = (
DIR*) malloc (
sizeof (
struct DIR));
698 WIN32_FIND_DATAW *datap;
721 if (error && datap->cAlternateFileName[0] !=
'\0') {
724 datap->cAlternateFileName,
PATH_MAX);
737 attr = datap->dwFileAttributes;
740 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
815 size_t *pReturnValue,
823 #if defined(_MSC_VER) && _MSC_VER >= 1400 826 error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
834 n = mbstowcs (wcstr, mbstr, sizeInWords);
835 if (!wcstr || n < count) {
838 if (wcstr && sizeInWords) {
839 if (n >= sizeInWords) {
847 *pReturnValue = n + 1;
868 size_t *pReturnValue,
871 const wchar_t *wcstr,
876 #if defined(_MSC_VER) && _MSC_VER >= 1400 879 error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
887 n = wcstombs (mbstr, wcstr, sizeInBytes);
888 if (!mbstr || n < count) {
891 if (mbstr && sizeInBytes) {
892 if (n >= sizeInBytes) {
900 *pReturnValue = n + 1;
923 #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