Go to the documentation of this file.
13 #if defined(__clang__)
14 # pragma clang diagnostic ignored "-Wunused-function"
15 #elif defined(_MSC_VER)
16 # pragma warning(disable:4505)
17 #elif defined(__GNUC__)
18 # pragma GCC diagnostic ignored "-Wunused-function"
25 #ifndef WIN32_LEAN_AND_MEAN
26 # define WIN32_LEAN_AND_MEAN
37 #include <sys/types.h>
40 #define _DIRENT_HAVE_D_TYPE
43 #define _DIRENT_HAVE_D_NAMLEN
46 #if !defined(FILE_ATTRIBUTE_DEVICE)
47 # define FILE_ATTRIBUTE_DEVICE 0x40
52 # define S_IFMT _S_IFMT
57 # define S_IFDIR _S_IFDIR
62 # define S_IFCHR _S_IFCHR
66 #if !defined(S_IFFIFO)
67 # define S_IFFIFO _S_IFFIFO
72 # define S_IFREG _S_IFREG
77 # define S_IREAD _S_IREAD
81 #if !defined(S_IWRITE)
82 # define S_IWRITE _S_IWRITE
87 # define S_IEXEC _S_IEXEC
92 # define S_IFIFO _S_IFIFO
101 #if !defined(S_IFLNK)
106 #if !defined(S_IFSOCK)
111 #if !defined(S_IRUSR)
112 # define S_IRUSR S_IREAD
116 #if !defined(S_IWUSR)
117 # define S_IWUSR S_IWRITE
121 #if !defined(S_IXUSR)
126 #if !defined(S_IRGRP)
131 #if !defined(S_IWGRP)
136 #if !defined(S_IXGRP)
141 #if !defined(S_IROTH)
146 #if !defined(S_IWOTH)
151 #if !defined(S_IXOTH)
156 #if !defined(PATH_MAX)
157 # define PATH_MAX MAX_PATH
159 #if !defined(FILENAME_MAX)
160 # define FILENAME_MAX MAX_PATH
162 #if !defined(NAME_MAX)
163 # define NAME_MAX FILENAME_MAX
168 #define DT_REG S_IFREG
169 #define DT_DIR S_IFDIR
170 #define DT_FIFO S_IFIFO
171 #define DT_SOCK S_IFSOCK
172 #define DT_CHR S_IFCHR
173 #define DT_BLK S_IFBLK
174 #define DT_LNK S_IFLNK
177 #define IFTODT(mode) ((mode) & S_IFMT)
178 #define DTTOIF(type) (type)
186 #if !defined(S_ISFIFO)
187 # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
189 #if !defined(S_ISDIR)
190 # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
192 #if !defined(S_ISREG)
193 # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
195 #if !defined(S_ISLNK)
196 # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
198 #if !defined(S_ISSOCK)
199 # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
201 #if !defined(S_ISCHR)
202 # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
204 #if !defined(S_ISBLK)
205 # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
209 #define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
212 #define _D_ALLOC_NAMLEN(p) ((PATH_MAX)+1)
307 static int scandir (
const char *dirname,
struct dirent ***namelist,
309 int (*compare)(
const struct dirent**,
const struct dirent**));
317 #define wdirent _wdirent
319 #define wopendir _wopendir
320 #define wreaddir _wreaddir
321 #define wclosedir _wclosedir
322 #define wrewinddir _wrewinddir
330 size_t *pReturnValue,
337 size_t *pReturnValue,
340 const wchar_t *wcstr,
353 const wchar_t *dirname)
360 if (dirname ==
NULL || dirname[0] ==
'\0') {
366 dirp = (
_WDIR*) malloc (
sizeof (
struct _WDIR));
372 dirp->
handle = INVALID_HANDLE_VALUE;
382 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
384 n = GetFullPathNameW (dirname, 0,
NULL,
NULL);
387 n = wcslen (dirname);
391 dirp->
patt = (
wchar_t*) malloc (
sizeof (
wchar_t) *
n + 16);
404 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
406 n = GetFullPathNameW (dirname,
n, dirp->
patt,
NULL);
412 wcsncpy_s (dirp->
patt,
n+1, dirname,
n);
480 WIN32_FIND_DATAW *datap;
495 entry->
d_name[
n] = datap->cFileName[
n];
504 attr = datap->dwFileAttributes;
507 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
544 if (dirp->
handle != INVALID_HANDLE_VALUE) {
575 if (dirp->
handle != INVALID_HANDLE_VALUE) {
585 static WIN32_FIND_DATAW*
589 WIN32_FIND_DATAW *datap;
593 dirp->
handle = FindFirstFileExW(
594 dirp->
patt, FindExInfoStandard, &dirp->
data,
595 FindExSearchNameMatch,
NULL, 0);
596 if (dirp->
handle != INVALID_HANDLE_VALUE) {
609 error = GetLastError ();
611 case ERROR_ACCESS_DENIED:
616 case ERROR_DIRECTORY:
621 case ERROR_PATH_NOT_FOUND:
636 static WIN32_FIND_DATAW*
649 }
else if (dirp->
handle != INVALID_HANDLE_VALUE) {
652 if (FindNextFileW (dirp->
handle, &dirp->
data) != FALSE) {
658 dirp->
handle = INVALID_HANDLE_VALUE;
682 if (dirname ==
NULL || dirname[0] ==
'\0') {
688 dirp = (
DIR*) malloc (
sizeof (
struct DIR));
759 WIN32_FIND_DATAW *datap;
781 if (
error && datap->cAlternateFileName[0] !=
'\0') {
784 datap->cAlternateFileName,
PATH_MAX + 1);
794 attr = datap->dwFileAttributes;
797 }
else if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
883 struct dirent ***namelist,
885 int (*compare)(
const struct dirent**,
const struct dirent**))
889 size_t allocated = 0;
890 const size_t init_size = 1;
905 if (
size >= allocated) {
910 if (
size < init_size) {
912 num_entries = init_size;
915 num_entries =
size * 2;
919 p = realloc (files,
sizeof (
void*) * num_entries);
923 allocated = num_entries;
973 qsort (files,
size,
sizeof (
void*),
974 (
int (*) (
const void*,
const void*)) compare);
1021 return strcoll ((*a)->d_name, (*b)->d_name);
1036 size_t *pReturnValue,
1044 #if defined(_MSC_VER) && _MSC_VER >= 1400
1047 error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr,
count);
1055 n = mbstowcs (wcstr, mbstr, sizeInWords);
1056 if (!wcstr ||
n <
count) {
1059 if (wcstr && sizeInWords) {
1060 if (
n >= sizeInWords) {
1061 n = sizeInWords - 1;
1068 *pReturnValue =
n + 1;
1088 size_t *pReturnValue,
1091 const wchar_t *wcstr,
1096 #if defined(_MSC_VER) && _MSC_VER >= 1400
1099 error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr,
count);
1107 n = wcstombs (mbstr, wcstr, sizeInBytes);
1108 if (!mbstr ||
n <
count) {
1111 if (mbstr && sizeInBytes) {
1112 if (
n >= sizeInBytes) {
1113 n = sizeInBytes - 1;
1120 *pReturnValue =
n + 1;
1142 #if defined(_MSC_VER) && _MSC_VER >= 1400
static void rewinddir(DIR *dirp)
static int dirent_mbstowcs_s(size_t *pReturnValue, wchar_t *wcstr, size_t sizeInWords, const char *mbstr, size_t count)
static int _wreaddir_r(_WDIR *dirp, struct _wdirent *entry, struct _wdirent **result)
static int alphasort(const struct dirent **a, const struct dirent **b)
static struct dirent * readdir(DIR *dirp)
static _WDIR * _wopendir(const wchar_t *dirname)
wchar_t d_name[PATH_MAX+1]
static int scandir(const char *dirname, struct dirent ***namelist, int(*filter)(const struct dirent *), int(*compare)(const struct dirent **, const struct dirent **))
static struct _wdirent * _wreaddir(_WDIR *dirp)
static int closedir(DIR *dirp)
GLboolean GLboolean GLboolean b
#define FILE_ATTRIBUTE_DEVICE
static int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
static int dirent_wcstombs_s(size_t *pReturnValue, char *mbstr, size_t sizeInBytes, const wchar_t *wcstr, size_t count)
static WIN32_FIND_DATAW * dirent_first(_WDIR *dirp)
typedef void(APIENTRY *GLDEBUGPROCARB)(GLenum source
static int versionsort(const struct dirent **a, const struct dirent **b)
static int _wclosedir(_WDIR *dirp)
static void _wrewinddir(_WDIR *dirp)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
static WIN32_FIND_DATAW * dirent_next(_WDIR *dirp)
static DIR * opendir(const char *dirname)
GLboolean GLboolean GLboolean GLboolean a
static void dirent_set_errno(int error)
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:50