79 #ifndef WIN32_LEAN_AND_MEAN
80 #define WIN32_LEAN_AND_MEAN
85 #include <sys/types.h>
90 #if !defined(FILE_ATTRIBUTE_DEVICE)
91 # define FILE_ATTRIBUTE_DEVICE 0x40
95 #if defined(_MSC_VER) && !defined(S_IREAD)
96 # define S_IFMT _S_IFMT
97 # define S_IFDIR _S_IFDIR
98 # define S_IFCHR _S_IFCHR
99 # define S_IFFIFO _S_IFFIFO
100 # define S_IFREG _S_IFREG
101 # define S_IREAD _S_IREAD
102 # define S_IWRITE _S_IWRITE
103 # define S_IEXEC _S_IEXEC
109 #if defined(_MSC_VER)
110 # define S_IRUSR S_IREAD
111 # define S_IWUSR S_IWRITE
122 #define _DIRENT_HAVE_D_TYPE
126 #define DT_REG S_IFREG
127 #define DT_DIR S_IFDIR
128 #define DT_FIFO S_IFFIFO
129 #define DT_SOCK S_IFSOCK
130 #define DT_CHR S_IFCHR
131 #define DT_BLK S_IFBLK
134 #define IFTODT(mode) ((mode) & S_IFMT)
135 #define DTTOIF(type) (type)
143 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
144 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
145 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
146 #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
147 #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
148 #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
149 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
182 #if defined(_MSC_VER) && _MSC_VER >= 1400
183 # define DIRENT_STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
185 # define DIRENT_STRNCPY(dest,src,size) strncpy((dest),(src),(size))
189 #if defined(_MSC_VER)
190 #define DIRENT_SET_ERRNO(x) _set_errno (x)
192 #define DIRENT_SET_ERRNO(x) (errno = (x))
206 if (dirname == NULL) {
210 if (strlen (dirname) + 3 >= MAX_PATH) {
216 dirp = (
DIR*) malloc (
sizeof (
struct DIR));
225 if (GetFullPathNameA (dirname, MAX_PATH, dirp->
patt, NULL)) {
229 p = strchr (dirp->
patt,
'\0');
230 if (dirp->
patt < p && *(p-1) !=
'\\' && *(p-1) !=
':') {
309 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
#define DIRENT_SET_ERRNO(x)
static int closedir(DIR *dirp)
#define FILE_ATTRIBUTE_DEVICE
static void rewinddir(DIR *dirp)
static DIR * opendir(const char *dirname)
static struct dirent * readdir(DIR *dirp)
WIN32_FIND_DATAA find_data
#define DIRENT_STRNCPY(dest, src, size)
#define INVALID_HANDLE_VALUE