VAPOR3 3.9.4
direntWin32.h
Go to the documentation of this file.
1/*
2 * dirent.h - dirent API for Microsoft Visual Studio
3 *
4 * Copyright (C) 2006-2012 Toni Ronkko
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * ``Software''), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 *
25 * $Id: dirent.h,v 1.20 2014/03/19 17:52:23 tronkko Exp $
26 */
27#ifndef DIRENTWin32_H
28#define DIRENTWin32_H
29
30/*
31 * Define architecture flags so we don't need to include windows.h.
32 * Avoiding windows.h makes it simpler to use windows sockets in conjunction
33 * with dirent.h.
34 */
35#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86)
36 #define _X86_
37#endif
38#if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64)
39 #define _AMD64_
40#endif
41
42#include <stdio.h>
43#include <stdarg.h>
44#include <windef.h>
45#include <winbase.h>
46#include <wchar.h>
47#include <string.h>
48#include <stdlib.h>
49#include <malloc.h>
50#include <sys/types.h>
51#include <sys/stat.h>
52#include <errno.h>
53
54/* Indicates that d_type field is available in dirent structure */
55#define _DIRENT_HAVE_D_TYPE
56
57/* Indicates that d_namlen field is available in dirent structure */
58#define _DIRENT_HAVE_D_NAMLEN
59
60/* Entries missing from MSVC 6.0 */
61#if !defined(FILE_ATTRIBUTE_DEVICE)
62 #define FILE_ATTRIBUTE_DEVICE 0x40
63#endif
64
65/* File type and permission flags for stat() */
66#if !defined(S_IFMT)
67 #define S_IFMT _S_IFMT /* File type mask */
68#endif
69#if !defined(S_IFDIR)
70 #define S_IFDIR _S_IFDIR /* Directory */
71#endif
72#if !defined(S_IFCHR)
73 #define S_IFCHR _S_IFCHR /* Character device */
74#endif
75#if !defined(S_IFFIFO)
76 #define S_IFFIFO _S_IFFIFO /* Pipe */
77#endif
78#if !defined(S_IFREG)
79 #define S_IFREG _S_IFREG /* Regular file */
80#endif
81#if !defined(S_IREAD)
82 #define S_IREAD _S_IREAD /* Read permission */
83#endif
84#if !defined(S_IWRITE)
85 #define S_IWRITE _S_IWRITE /* Write permission */
86#endif
87#if !defined(S_IEXEC)
88 #define S_IEXEC _S_IEXEC /* Execute permission */
89#endif
90#if !defined(S_IFIFO)
91 #define S_IFIFO _S_IFIFO /* Pipe */
92#endif
93#if !defined(S_IFBLK)
94 #define S_IFBLK 0 /* Block device */
95#endif
96#if !defined(S_IFLNK)
97 #define S_IFLNK 0 /* Link */
98#endif
99#if !defined(S_IFSOCK)
100 #define S_IFSOCK 0 /* Socket */
101#endif
102
103#if defined(_MSC_VER)
104 #define S_IRUSR S_IREAD /* Read user */
105 #define S_IWUSR S_IWRITE /* Write user */
106 #define S_IXUSR 0 /* Execute user */
107 #define S_IRGRP 0 /* Read group */
108 #define S_IWGRP 0 /* Write group */
109 #define S_IXGRP 0 /* Execute group */
110 #define S_IROTH 0 /* Read others */
111 #define S_IWOTH 0 /* Write others */
112 #define S_IXOTH 0 /* Execute others */
113#endif
114
115/* Maximum length of file name */
116#if !defined(PATH_MAX)
117 #define PATH_MAX MAX_PATH
118#endif
119#if !defined(FILENAME_MAX)
120 #define FILENAME_MAX MAX_PATH
121#endif
122#if !defined(NAME_MAX)
123 #define NAME_MAX FILENAME_MAX
124#endif
125
126/* File type flags for d_type */
127#define DT_UNKNOWN 0
128#define DT_REG S_IFREG
129#define DT_DIR S_IFDIR
130#define DT_FIFO S_IFIFO
131#define DT_SOCK S_IFSOCK
132#define DT_CHR S_IFCHR
133#define DT_BLK S_IFBLK
134#define DT_LNK S_IFLNK
135
136/* Macros for converting between st_mode and d_type */
137#define IFTODT(mode) ((mode)&S_IFMT)
138#define DTTOIF(type) (type)
139
140/*
141 * File type macros. Note that block devices, sockets and links cannot be
142 * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are
143 * only defined for compatibility. These macros should always return false
144 * on Windows.
145 */
146#define S_ISFIFO(mode) (((mode)&S_IFMT) == S_IFIFO)
147#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
148#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
149#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
150#define S_ISSOCK(mode) (((mode)&S_IFMT) == S_IFSOCK)
151#define S_ISCHR(mode) (((mode)&S_IFMT) == S_IFCHR)
152#define S_ISBLK(mode) (((mode)&S_IFMT) == S_IFBLK)
153
154/* Return the exact length of d_namlen without zero terminator */
155#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
156
157/* Return number of bytes needed to store d_namlen */
158#define _D_ALLOC_NAMLEN(p) (PATH_MAX)
159
160#ifdef __cplusplus
161extern "C" {
162#endif
163
164/* Wide-character version */
165struct _wdirent {
166 long d_ino; /* Always zero */
167 unsigned short d_reclen; /* Structure size */
168 size_t d_namlen; /* Length of name without \0 */
169 int d_type; /* File type */
170 wchar_t d_name[PATH_MAX]; /* File name */
171};
172typedef struct _wdirent _wdirent;
173
174struct _WDIR {
175 struct _wdirent ent; /* Current directory entry */
176 WIN32_FIND_DATAW data; /* Private file data */
177 int cached; /* True if data is valid */
178 HANDLE handle; /* Win32 search handle */
179 wchar_t * patt; /* Initial directory name */
180};
181typedef struct _WDIR _WDIR;
182
183static _WDIR * _wopendir(const wchar_t *dirname);
184static struct _wdirent *_wreaddir(_WDIR *dirp);
185static int _wclosedir(_WDIR *dirp);
186static void _wrewinddir(_WDIR *dirp);
187
188/* For compatibility with Symbian */
189#define wdirent _wdirent
190#define WDIR _WDIR
191#define wopendir _wopendir
192#define wreaddir _wreaddir
193#define wclosedir _wclosedir
194#define wrewinddir _wrewinddir
195
196/* Multi-byte character versions */
197struct dirent {
198 long d_ino; /* Always zero */
199 unsigned short d_reclen; /* Structure size */
200 size_t d_namlen; /* Length of name without \0 */
201 int d_type; /* File type */
202 char d_name[PATH_MAX]; /* File name */
203};
204typedef struct dirent dirent;
205
206struct DIR {
207 struct dirent ent;
208 struct _WDIR *wdirp;
209};
210typedef struct DIR DIR;
211
212static DIR * opendir(const char *dirname);
213static struct dirent *readdir(DIR *dirp);
214static int closedir(DIR *dirp);
215static void rewinddir(DIR *dirp);
216
217/* Internal utility functions */
218static WIN32_FIND_DATAW *dirent_first(_WDIR *dirp);
219static WIN32_FIND_DATAW *dirent_next(_WDIR *dirp);
220
221static int dirent_mbstowcs_s(size_t *pReturnValue, wchar_t *wcstr, size_t sizeInWords, const char *mbstr, size_t count);
222
223static int dirent_wcstombs_s(size_t *pReturnValue, char *mbstr, size_t sizeInBytes, const wchar_t *wcstr, size_t count);
224
225static void dirent_set_errno(int error);
226
227/*
228 * Open directory stream DIRNAME for read and return a pointer to the
229 * internal working area that is used to retrieve individual directory
230 * entries.
231 */
232static _WDIR *_wopendir(const wchar_t *dirname)
233{
234 _WDIR *dirp = NULL;
235 int error;
236
237 /* Must have directory name */
238 if (dirname == NULL || dirname[0] == '\0') {
239 dirent_set_errno(ENOENT);
240 return NULL;
241 }
242
243 /* Allocate new _WDIR structure */
244 dirp = (_WDIR *)malloc(sizeof(struct _WDIR));
245 if (dirp != NULL) {
246 DWORD n;
247
248 /* Reset _WDIR structure */
249 dirp->handle = INVALID_HANDLE_VALUE;
250 dirp->patt = NULL;
251 dirp->cached = 0;
252
253 /* Compute the length of full path plus zero terminator */
254 n = GetFullPathNameW(dirname, 0, NULL, NULL);
255
256 /* Allocate room for absolute directory name and search pattern */
257 dirp->patt = (wchar_t *)malloc(sizeof(wchar_t) * n + 16);
258 if (dirp->patt) {
259 /*
260 * Convert relative directory name to an absolute one. This
261 * allows rewinddir() to function correctly even when current
262 * working directory is changed between opendir() and rewinddir().
263 */
264 n = GetFullPathNameW(dirname, n, dirp->patt, NULL);
265 if (n > 0) {
266 wchar_t *p;
267
268 /* Append search pattern \* to the directory name */
269 p = dirp->patt + n;
270 if (dirp->patt < p) {
271 switch (p[-1]) {
272 case '\\':
273 case '/':
274 case ':':
275 /* Directory ends in path separator, e.g. c:\temp\ */
276 /*NOP*/;
277 break;
278
279 default:
280 /* Directory name doesn't end in path separator */
281 *p++ = '\\';
282 }
283 }
284 *p++ = '*';
285 *p = '\0';
286
287 /* Open directory stream and retrieve the first entry */
288 if (dirent_first(dirp)) {
289 /* Directory stream opened successfully */
290 error = 0;
291 } else {
292 /* Cannot retrieve first entry */
293 error = 1;
294 dirent_set_errno(ENOENT);
295 }
296
297 } else {
298 /* Cannot retrieve full path name */
299 dirent_set_errno(ENOENT);
300 error = 1;
301 }
302
303 } else {
304 /* Cannot allocate memory for search pattern */
305 error = 1;
306 }
307
308 } else {
309 /* Cannot allocate _WDIR structure */
310 error = 1;
311 }
312
313 /* Clean up in case of error */
314 if (error && dirp) {
315 _wclosedir(dirp);
316 dirp = NULL;
317 }
318
319 return dirp;
320}
321
322/*
323 * Read next directory entry. The directory entry is returned in dirent
324 * structure in the d_name field. Individual directory entries returned by
325 * this function include regular files, sub-directories, pseudo-directories
326 * "." and ".." as well as volume labels, hidden files and system files.
327 */
328static struct _wdirent *_wreaddir(_WDIR *dirp)
329{
330 WIN32_FIND_DATAW *datap;
331 struct _wdirent * entp;
332
333 /* Read next directory entry */
334 datap = dirent_next(dirp);
335 if (datap) {
336 size_t n;
337 DWORD attr;
338
339 /* Pointer to directory entry to return */
340 entp = &dirp->ent;
341
342 /*
343 * Copy file name as wide-character string. If the file name is too
344 * long to fit in to the destination buffer, then truncate file name
345 * to PATH_MAX characters and zero-terminate the buffer.
346 */
347 n = 0;
348 while (n + 1 < PATH_MAX && datap->cFileName[n] != 0) {
349 entp->d_name[n] = datap->cFileName[n];
350 n++;
351 }
352 dirp->ent.d_name[n] = 0;
353
354 /* Length of file name excluding zero terminator */
355 entp->d_namlen = n;
356
357 /* File type */
358 attr = datap->dwFileAttributes;
359 if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
360 entp->d_type = DT_CHR;
361 } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
362 entp->d_type = DT_DIR;
363 } else {
364 entp->d_type = DT_REG;
365 }
366
367 /* Reset dummy fields */
368 entp->d_ino = 0;
369 entp->d_reclen = sizeof(struct _wdirent);
370
371 } else {
372 /* Last directory entry read */
373 entp = NULL;
374 }
375
376 return entp;
377}
378
379/*
380 * Close directory stream opened by opendir() function. This invalidates the
381 * DIR structure as well as any directory entry read previously by
382 * _wreaddir().
383 */
384static int _wclosedir(_WDIR *dirp)
385{
386 int ok;
387 if (dirp) {
388 /* Release search handle */
389 if (dirp->handle != INVALID_HANDLE_VALUE) {
390 FindClose(dirp->handle);
391 dirp->handle = INVALID_HANDLE_VALUE;
392 }
393
394 /* Release search pattern */
395 if (dirp->patt) {
396 free(dirp->patt);
397 dirp->patt = NULL;
398 }
399
400 /* Release directory structure */
401 free(dirp);
402 ok = /*success*/ 0;
403
404 } else {
405 /* Invalid directory stream */
406 dirent_set_errno(EBADF);
407 ok = /*failure*/ -1;
408 }
409 return ok;
410}
411
412/*
413 * Rewind directory stream such that _wreaddir() returns the very first
414 * file name again.
415 */
416static void _wrewinddir(_WDIR *dirp)
417{
418 if (dirp) {
419 /* Release existing search handle */
420 if (dirp->handle != INVALID_HANDLE_VALUE) { FindClose(dirp->handle); }
421
422 /* Open new search handle */
423 dirent_first(dirp);
424 }
425}
426
427/* Get first directory entry (internal) */
428static WIN32_FIND_DATAW *dirent_first(_WDIR *dirp)
429{
430 WIN32_FIND_DATAW *datap;
431
432 /* Open directory and retrieve the first entry */
433 dirp->handle = FindFirstFileW(dirp->patt, &dirp->data);
434 if (dirp->handle != INVALID_HANDLE_VALUE) {
435 /* a directory entry is now waiting in memory */
436 datap = &dirp->data;
437 dirp->cached = 1;
438
439 } else {
440 /* Failed to re-open directory: no directory entry in memory */
441 dirp->cached = 0;
442 datap = NULL;
443 }
444 return datap;
445}
446
447/* Get next directory entry (internal) */
448static WIN32_FIND_DATAW *dirent_next(_WDIR *dirp)
449{
450 WIN32_FIND_DATAW *p;
451
452 /* Get next directory entry */
453 if (dirp->cached != 0) {
454 /* A valid directory entry already in memory */
455 p = &dirp->data;
456 dirp->cached = 0;
457
458 } else if (dirp->handle != INVALID_HANDLE_VALUE) {
459 /* Get the next directory entry from stream */
460 if (FindNextFileW(dirp->handle, &dirp->data) != FALSE) {
461 /* Got a file */
462 p = &dirp->data;
463 } else {
464 /* The very last entry has been processed or an error occured */
465 FindClose(dirp->handle);
466 dirp->handle = INVALID_HANDLE_VALUE;
467 p = NULL;
468 }
469
470 } else {
471 /* End of directory stream reached */
472 p = NULL;
473 }
474
475 return p;
476}
477
478/*
479 * Open directory stream using plain old C-string.
480 */
481static DIR *opendir(const char *dirname)
482{
483 struct DIR *dirp;
484 int error;
485
486 /* Must have directory name */
487 if (dirname == NULL || dirname[0] == '\0') {
488 dirent_set_errno(ENOENT);
489 return NULL;
490 }
491
492 /* Allocate memory for DIR structure */
493 dirp = (DIR *)malloc(sizeof(struct DIR));
494 if (dirp) {
495 wchar_t wname[PATH_MAX];
496 size_t n;
497
498 /* Convert directory name to wide-character string */
499 error = dirent_mbstowcs_s(&n, wname, PATH_MAX, dirname, PATH_MAX);
500 if (!error) {
501 /* Open directory stream using wide-character name */
502 dirp->wdirp = _wopendir(wname);
503 if (dirp->wdirp) {
504 /* Directory stream opened */
505 error = 0;
506 } else {
507 /* Failed to open directory stream */
508 error = 1;
509 }
510
511 } else {
512 /*
513 * Cannot convert file name to wide-character string. This
514 * occurs if the string contains invalid multi-byte sequences or
515 * the output buffer is too small to contain the resulting
516 * string.
517 */
518 error = 1;
519 }
520
521 } else {
522 /* Cannot allocate DIR structure */
523 error = 1;
524 }
525
526 /* Clean up in case of error */
527 if (error && dirp) {
528 free(dirp);
529 dirp = NULL;
530 }
531
532 return dirp;
533}
534
535/*
536 * Read next directory entry.
537 *
538 * When working with text consoles, please note that file names returned by
539 * readdir() are represented in the default ANSI code page while any output to
540 * console is typically formatted on another code page. Thus, non-ASCII
541 * characters in file names will not usually display correctly on console. The
542 * problem can be fixed in two ways: (1) change the character set of console
543 * to 1252 using chcp utility and use Lucida Console font, or (2) use
544 * _cprintf function when writing to console. The _cprinf() will re-encode
545 * ANSI strings to the console code page so many non-ASCII characters will
546 * display correcly.
547 */
548static struct dirent *readdir(DIR *dirp)
549{
550 WIN32_FIND_DATAW *datap;
551 struct dirent * entp;
552
553 /* Read next directory entry */
554 datap = dirent_next(dirp->wdirp);
555 if (datap) {
556 size_t n;
557 int error;
558
559 /* Attempt to convert file name to multi-byte string */
560 error = dirent_wcstombs_s(&n, dirp->ent.d_name, PATH_MAX, datap->cFileName, PATH_MAX);
561
562 /*
563 * If the file name cannot be represented by a multi-byte string,
564 * then attempt to use old 8+3 file name. This allows traditional
565 * Unix-code to access some file names despite of unicode
566 * characters, although file names may seem unfamiliar to the user.
567 *
568 * Be ware that the code below cannot come up with a short file
569 * name unless the file system provides one. At least
570 * VirtualBox shared folders fail to do this.
571 */
572 if (error && datap->cAlternateFileName[0] != '\0') { error = dirent_wcstombs_s(&n, dirp->ent.d_name, PATH_MAX, datap->cAlternateFileName, PATH_MAX); }
573
574 if (!error) {
575 DWORD attr;
576
577 /* Initialize directory entry for return */
578 entp = &dirp->ent;
579
580 /* Length of file name excluding zero terminator */
581 entp->d_namlen = n - 1;
582
583 /* File attributes */
584 attr = datap->dwFileAttributes;
585 if ((attr & FILE_ATTRIBUTE_DEVICE) != 0) {
586 entp->d_type = DT_CHR;
587 } else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
588 entp->d_type = DT_DIR;
589 } else {
590 entp->d_type = DT_REG;
591 }
592
593 /* Reset dummy fields */
594 entp->d_ino = 0;
595 entp->d_reclen = sizeof(struct dirent);
596
597 } else {
598 /*
599 * Cannot convert file name to multi-byte string so construct
600 * an errornous directory entry and return that. Note that
601 * we cannot return NULL as that would stop the processing
602 * of directory entries completely.
603 */
604 entp = &dirp->ent;
605 entp->d_name[0] = '?';
606 entp->d_name[1] = '\0';
607 entp->d_namlen = 1;
608 entp->d_type = DT_UNKNOWN;
609 entp->d_ino = 0;
610 entp->d_reclen = 0;
611 }
612
613 } else {
614 /* No more directory entries */
615 entp = NULL;
616 }
617
618 return entp;
619}
620
621/*
622 * Close directory stream.
623 */
624static int closedir(DIR *dirp)
625{
626 int ok;
627 if (dirp) {
628 /* Close wide-character directory stream */
629 ok = _wclosedir(dirp->wdirp);
630 dirp->wdirp = NULL;
631
632 /* Release multi-byte character version */
633 free(dirp);
634
635 } else {
636 /* Invalid directory stream */
637 dirent_set_errno(EBADF);
638 ok = /*failure*/ -1;
639 }
640 return ok;
641}
642
643/*
644 * Rewind directory stream to beginning.
645 */
646static void rewinddir(DIR *dirp)
647{
648 /* Rewind wide-character string directory stream */
649 _wrewinddir(dirp->wdirp);
650}
651
652/* Convert multi-byte string to wide character string */
653static int dirent_mbstowcs_s(size_t *pReturnValue, wchar_t *wcstr, size_t sizeInWords, const char *mbstr, size_t count)
654{
655 int error;
656
657#if defined(_MSC_VER) && _MSC_VER >= 1400
658
659 /* Microsoft Visual Studio 2005 or later */
660 error = mbstowcs_s(pReturnValue, wcstr, sizeInWords, mbstr, count);
661
662#else
663
664 /* Older Visual Studio or non-Microsoft compiler */
665 size_t n;
666
667 /* Convert to wide-character string (or count characters) */
668 n = mbstowcs(wcstr, mbstr, sizeInWords);
669 if (!wcstr || n < count) {
670 /* Zero-terminate output buffer */
671 if (wcstr && sizeInWords) {
672 if (n >= sizeInWords) { n = sizeInWords - 1; }
673 wcstr[n] = 0;
674 }
675
676 /* Length of resuting multi-byte string WITH zero terminator */
677 if (pReturnValue) { *pReturnValue = n + 1; }
678
679 /* Success */
680 error = 0;
681
682 } else {
683 /* Could not convert string */
684 error = 1;
685 }
686
687#endif
688
689 return error;
690}
691
692/* Convert wide-character string to multi-byte string */
693static int dirent_wcstombs_s(size_t *pReturnValue, char *mbstr, size_t sizeInBytes, /* max size of mbstr */
694 const wchar_t *wcstr, size_t count)
695{
696 int error;
697
698#if defined(_MSC_VER) && _MSC_VER >= 1400
699
700 /* Microsoft Visual Studio 2005 or later */
701 error = wcstombs_s(pReturnValue, mbstr, sizeInBytes, wcstr, count);
702
703#else
704
705 /* Older Visual Studio or non-Microsoft compiler */
706 size_t n;
707
708 /* Convert to multi-byte string (or count the number of bytes needed) */
709 n = wcstombs(mbstr, wcstr, sizeInBytes);
710 if (!mbstr || n < count) {
711 /* Zero-terminate output buffer */
712 if (mbstr && sizeInBytes) {
713 if (n >= sizeInBytes) { n = sizeInBytes - 1; }
714 mbstr[n] = '\0';
715 }
716
717 /* Lenght of resulting multi-bytes string WITH zero-terminator */
718 if (pReturnValue) { *pReturnValue = n + 1; }
719
720 /* Success */
721 error = 0;
722
723 } else {
724 /* Cannot convert string */
725 error = 1;
726 }
727
728#endif
729
730 return error;
731}
732
733/* Set errno variable */
734static void dirent_set_errno(int error)
735{
736#if defined(_MSC_VER) && _MSC_VER >= 1400
737
738 /* Microsoft Visual Studio 2005 and later */
739 _set_errno(error);
740
741#else
742
743 /* Non-Microsoft compiler or older Microsoft compiler */
744 errno = error;
745
746#endif
747}
748
749#ifdef __cplusplus
750}
751#endif
752#endif /*DIRENT_H*/
static WIN32_FIND_DATAW * dirent_first(_WDIR *dirp)
Definition: direntWin32.h:428
static void dirent_set_errno(int error)
Definition: direntWin32.h:734
#define DT_DIR
Definition: direntWin32.h:129
#define DT_UNKNOWN
Definition: direntWin32.h:127
static DIR * opendir(const char *dirname)
Definition: direntWin32.h:481
static int closedir(DIR *dirp)
Definition: direntWin32.h:624
#define DT_CHR
Definition: direntWin32.h:132
static void rewinddir(DIR *dirp)
Definition: direntWin32.h:646
static WIN32_FIND_DATAW * dirent_next(_WDIR *dirp)
Definition: direntWin32.h:448
static _WDIR * _wopendir(const wchar_t *dirname)
Definition: direntWin32.h:232
#define DT_REG
Definition: direntWin32.h:128
#define FILE_ATTRIBUTE_DEVICE
Definition: direntWin32.h:62
static void _wrewinddir(_WDIR *dirp)
Definition: direntWin32.h:416
static int _wclosedir(_WDIR *dirp)
Definition: direntWin32.h:384
#define PATH_MAX
Definition: direntWin32.h:117
static struct _wdirent * _wreaddir(_WDIR *dirp)
Definition: direntWin32.h:328
static int dirent_mbstowcs_s(size_t *pReturnValue, wchar_t *wcstr, size_t sizeInWords, const char *mbstr, size_t count)
Definition: direntWin32.h:653
static int dirent_wcstombs_s(size_t *pReturnValue, char *mbstr, size_t sizeInBytes, const wchar_t *wcstr, size_t count)
Definition: direntWin32.h:693
static struct dirent * readdir(DIR *dirp)
Definition: direntWin32.h:548
struct _WDIR * wdirp
Definition: direntWin32.h:208
struct dirent ent
Definition: direntWin32.h:207
WIN32_FIND_DATAW data
Definition: direntWin32.h:176
HANDLE handle
Definition: direntWin32.h:178
wchar_t * patt
Definition: direntWin32.h:179
struct _wdirent ent
Definition: direntWin32.h:175
int cached
Definition: direntWin32.h:177
size_t d_namlen
Definition: direntWin32.h:168
wchar_t d_name[PATH_MAX]
Definition: direntWin32.h:170
int d_type
Definition: direntWin32.h:169
long d_ino
Definition: direntWin32.h:166
unsigned short d_reclen
Definition: direntWin32.h:167
size_t d_namlen
Definition: direntWin32.h:200
char d_name[PATH_MAX]
Definition: direntWin32.h:202
unsigned short d_reclen
Definition: direntWin32.h:199
long d_ino
Definition: direntWin32.h:198
int d_type
Definition: direntWin32.h:201