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