108 #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86) 119 #include <sys/types.h> 120 #include <sys/stat.h> 124 #define _DIRENT_HAVE_D_TYPE 127 #define _DIRENT_HAVE_D_NAMLEN 130 #if !defined(FILE_ATTRIBUTE_DEVICE) 131 # define FILE_ATTRIBUTE_DEVICE 0x40 136 # define S_IFMT _S_IFMT 138 #if !defined(S_IFDIR) 139 # define S_IFDIR _S_IFDIR 141 #if !defined(S_IFCHR) 142 # define S_IFCHR _S_IFCHR 144 #if !defined(S_IFFIFO) 145 # define S_IFFIFO _S_IFFIFO 147 #if !defined(S_IFREG) 148 # define S_IFREG _S_IFREG 150 #if !defined(S_IREAD) 151 # define S_IREAD _S_IREAD 153 #if !defined(S_IWRITE) 154 # define S_IWRITE _S_IWRITE 156 #if !defined(S_IEXEC) 157 # define S_IEXEC _S_IEXEC 159 #if !defined(S_IFIFO) 160 # define S_IFIFO _S_IFIFO 162 #if !defined(S_IFBLK) 165 #if !defined(S_IFLNK) 168 #if !defined(S_IFSOCK) 172 #if defined(_MSC_VER) 173 # define S_IRUSR S_IREAD 174 # define S_IWUSR S_IWRITE 185 #if !defined(PATH_MAX) 186 # define PATH_MAX MAX_PATH 188 #if !defined(FILENAME_MAX) 189 # define FILENAME_MAX MAX_PATH 191 #if !defined(NAME_MAX) 192 # define NAME_MAX FILENAME_MAX 197 #define DT_REG S_IFREG 198 #define DT_DIR S_IFDIR 199 #define DT_FIFO S_IFIFO 200 #define DT_SOCK S_IFSOCK 201 #define DT_CHR S_IFCHR 202 #define DT_BLK S_IFBLK 203 #define DT_LNK S_IFLNK 206 #define IFTODT(mode) ((mode) & S_IFMT) 207 #define DTTOIF(type) (type) 215 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) 216 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) 217 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) 218 #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) 219 #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) 220 #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) 221 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) 224 #define _D_EXACT_NAMLEN(p) ((p)->d_namlen) 227 #define _D_ALLOC_NAMLEN(p) (PATH_MAX) 261 #define wdirent _wdirent 263 #define wopendir _wopendir 264 #define wreaddir _wreaddir 265 #define wclosedir _wclosedir 266 #define wrewinddir _wrewinddir 296 size_t *pReturnValue,
303 size_t *pReturnValue,
306 const wchar_t *wcstr,
318 const wchar_t *dirname)
324 if (dirname == NULL || dirname[0] ==
'\0') {
330 dirp = (
_WDIR*) malloc (
sizeof (
struct _WDIR));
335 dirp->
handle = INVALID_HANDLE_VALUE;
340 n = GetFullPathNameW (dirname, 0, NULL, NULL);
343 dirp->
patt = (
wchar_t*) malloc (
sizeof (
wchar_t) * n + 16);
351 n = GetFullPathNameW (dirname, n, dirp->
patt, NULL);
357 if (dirp->
patt < p) {
419 WIN32_FIND_DATAW *datap;
437 while (n + 1 <
PATH_MAX && datap->cFileName[n] != 0) {
438 entp->
d_name[n] = datap->cFileName[n];
447 attr = datap->dwFileAttributes;
450 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
483 if (dirp->
handle != INVALID_HANDLE_VALUE) {
485 dirp->
handle = INVALID_HANDLE_VALUE;
516 if (dirp->
handle != INVALID_HANDLE_VALUE) {
526 static WIN32_FIND_DATAW*
530 WIN32_FIND_DATAW *datap;
534 if (dirp->
handle != INVALID_HANDLE_VALUE) {
551 static WIN32_FIND_DATAW*
564 }
else if (dirp->
handle != INVALID_HANDLE_VALUE) {
567 if (FindNextFileW (dirp->
handle, &dirp->
data) != FALSE) {
573 dirp->
handle = INVALID_HANDLE_VALUE;
598 if (dirname == NULL || dirname[0] ==
'\0') {
604 dirp = (
DIR*) malloc (
sizeof (
struct DIR));
664 WIN32_FIND_DATAW *datap;
687 if (error && datap->cAlternateFileName[0] !=
'\0') {
690 datap->cAlternateFileName,
PATH_MAX);
703 attr = datap->dwFileAttributes;
706 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
781 size_t *pReturnValue,
789 #if defined(_MSC_VER) && _MSC_VER >= 1400 792 error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
800 n = mbstowcs (wcstr, mbstr, sizeInWords);
801 if (!wcstr || n < count) {
804 if (wcstr && sizeInWords) {
805 if (n >= sizeInWords) {
813 *pReturnValue = n + 1;
834 size_t *pReturnValue,
837 const wchar_t *wcstr,
842 #if defined(_MSC_VER) && _MSC_VER >= 1400 845 error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
853 n = wcstombs (mbstr, wcstr, sizeInBytes);
854 if (!mbstr || n < count) {
857 if (mbstr && sizeInBytes) {
858 if (n >= sizeInBytes) {
866 *pReturnValue = n + 1;
889 #if defined(_MSC_VER) && _MSC_VER >= 1400 static int dirent_mbstowcs_s(size_t *pReturnValue, wchar_t *wcstr, size_t sizeInWords, const char *mbstr, size_t count)
static void _wrewinddir(_WDIR *dirp)
static int dirent_wcstombs_s(size_t *pReturnValue, char *mbstr, size_t sizeInBytes, const wchar_t *wcstr, size_t count)
static DIR * opendir(const char *dirname)
static _WDIR * _wopendir(const wchar_t *dirname)
static struct _wdirent * _wreaddir(_WDIR *dirp)
static void dirent_set_errno(int error)
static struct dirent * readdir(DIR *dirp)
#define FILE_ATTRIBUTE_DEVICE
static void rewinddir(DIR *dirp)
static int _wclosedir(_WDIR *dirp)
static WIN32_FIND_DATAW * dirent_first(_WDIR *dirp)
static WIN32_FIND_DATAW * dirent_next(_WDIR *dirp)
static int closedir(DIR *dirp)