Fossil SCM
Update <dirent.h> for Visual Studio to latest version 1.21 (September 2015)
Commit
dd498bbac7f8cf96a4fd4fad234673a582c0850c
Parent
5b5cbfc92628787…
1 file changed
+154
-75
+154
-75
| --- win/include/dirent.h | ||
| +++ win/include/dirent.h | ||
| @@ -1,30 +1,13 @@ | ||
| 1 | 1 | /* |
| 2 | - * dirent.h - dirent API for Microsoft Visual Studio | |
| 2 | + * Dirent interface for Microsoft Visual Studio | |
| 3 | + * Version 1.21 | |
| 3 | 4 | * |
| 4 | 5 | * 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 $ | |
| 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 | |
| 26 | 9 | */ |
| 27 | 10 | #ifndef DIRENT_H |
| 28 | 11 | #define DIRENT_H |
| 29 | 12 | |
| 30 | 13 | /* |
| @@ -60,58 +43,113 @@ | ||
| 60 | 43 | /* Entries missing from MSVC 6.0 */ |
| 61 | 44 | #if !defined(FILE_ATTRIBUTE_DEVICE) |
| 62 | 45 | # define FILE_ATTRIBUTE_DEVICE 0x40 |
| 63 | 46 | #endif |
| 64 | 47 | |
| 65 | -/* File type and permission flags for stat() */ | |
| 48 | +/* File type and permission flags for stat(), general mask */ | |
| 66 | 49 | #if !defined(S_IFMT) |
| 67 | -# define S_IFMT _S_IFMT /* File type mask */ | |
| 50 | +# define S_IFMT _S_IFMT | |
| 68 | 51 | #endif |
| 52 | + | |
| 53 | +/* Directory bit */ | |
| 69 | 54 | #if !defined(S_IFDIR) |
| 70 | -# define S_IFDIR _S_IFDIR /* Directory */ | |
| 55 | +# define S_IFDIR _S_IFDIR | |
| 71 | 56 | #endif |
| 57 | + | |
| 58 | +/* Character device bit */ | |
| 72 | 59 | #if !defined(S_IFCHR) |
| 73 | -# define S_IFCHR _S_IFCHR /* Character device */ | |
| 60 | +# define S_IFCHR _S_IFCHR | |
| 74 | 61 | #endif |
| 62 | + | |
| 63 | +/* Pipe bit */ | |
| 75 | 64 | #if !defined(S_IFFIFO) |
| 76 | -# define S_IFFIFO _S_IFFIFO /* Pipe */ | |
| 65 | +# define S_IFFIFO _S_IFFIFO | |
| 77 | 66 | #endif |
| 67 | + | |
| 68 | +/* Regular file bit */ | |
| 78 | 69 | #if !defined(S_IFREG) |
| 79 | -# define S_IFREG _S_IFREG /* Regular file */ | |
| 70 | +# define S_IFREG _S_IFREG | |
| 80 | 71 | #endif |
| 72 | + | |
| 73 | +/* Read permission */ | |
| 81 | 74 | #if !defined(S_IREAD) |
| 82 | -# define S_IREAD _S_IREAD /* Read permission */ | |
| 75 | +# define S_IREAD _S_IREAD | |
| 83 | 76 | #endif |
| 77 | + | |
| 78 | +/* Write permission */ | |
| 84 | 79 | #if !defined(S_IWRITE) |
| 85 | -# define S_IWRITE _S_IWRITE /* Write permission */ | |
| 80 | +# define S_IWRITE _S_IWRITE | |
| 86 | 81 | #endif |
| 82 | + | |
| 83 | +/* Execute permission */ | |
| 87 | 84 | #if !defined(S_IEXEC) |
| 88 | -# define S_IEXEC _S_IEXEC /* Execute permission */ | |
| 85 | +# define S_IEXEC _S_IEXEC | |
| 89 | 86 | #endif |
| 87 | + | |
| 88 | +/* Pipe */ | |
| 90 | 89 | #if !defined(S_IFIFO) |
| 91 | -# define S_IFIFO _S_IFIFO /* Pipe */ | |
| 90 | +# define S_IFIFO _S_IFIFO | |
| 92 | 91 | #endif |
| 92 | + | |
| 93 | +/* Block device */ | |
| 93 | 94 | #if !defined(S_IFBLK) |
| 94 | -# define S_IFBLK 0 /* Block device */ | |
| 95 | +# define S_IFBLK 0 | |
| 95 | 96 | #endif |
| 97 | + | |
| 98 | +/* Link */ | |
| 96 | 99 | #if !defined(S_IFLNK) |
| 97 | -# define S_IFLNK 0 /* Link */ | |
| 100 | +# define S_IFLNK 0 | |
| 98 | 101 | #endif |
| 102 | + | |
| 103 | +/* Socket */ | |
| 99 | 104 | #if !defined(S_IFSOCK) |
| 100 | -# define S_IFSOCK 0 /* Socket */ | |
| 105 | +# define S_IFSOCK 0 | |
| 106 | +#endif | |
| 107 | + | |
| 108 | +/* Read user permission */ | |
| 109 | +#if !defined(S_IRUSR) | |
| 110 | +# define S_IRUSR S_IREAD | |
| 111 | +#endif | |
| 112 | + | |
| 113 | +/* Write user permission */ | |
| 114 | +#if !defined(S_IWUSR) | |
| 115 | +# define S_IWUSR S_IWRITE | |
| 116 | +#endif | |
| 117 | + | |
| 118 | +/* Execute user permission */ | |
| 119 | +#if !defined(S_IXUSR) | |
| 120 | +# define S_IXUSR 0 | |
| 121 | +#endif | |
| 122 | + | |
| 123 | +/* Read group permission */ | |
| 124 | +#if !defined(S_IRGRP) | |
| 125 | +# define S_IRGRP 0 | |
| 126 | +#endif | |
| 127 | + | |
| 128 | +/* Write group permission */ | |
| 129 | +#if !defined(S_IWGRP) | |
| 130 | +# define S_IWGRP 0 | |
| 131 | +#endif | |
| 132 | + | |
| 133 | +/* Execute group permission */ | |
| 134 | +#if !defined(S_IXGRP) | |
| 135 | +# define S_IXGRP 0 | |
| 136 | +#endif | |
| 137 | + | |
| 138 | +/* Read others permission */ | |
| 139 | +#if !defined(S_IROTH) | |
| 140 | +# define S_IROTH 0 | |
| 141 | +#endif | |
| 142 | + | |
| 143 | +/* Write others permission */ | |
| 144 | +#if !defined(S_IWOTH) | |
| 145 | +# define S_IWOTH 0 | |
| 101 | 146 | #endif |
| 102 | 147 | |
| 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 */ | |
| 148 | +/* Execute others permission */ | |
| 149 | +#if !defined(S_IXOTH) | |
| 150 | +# define S_IXOTH 0 | |
| 113 | 151 | #endif |
| 114 | 152 | |
| 115 | 153 | /* Maximum length of file name */ |
| 116 | 154 | #if !defined(PATH_MAX) |
| 117 | 155 | # define PATH_MAX MAX_PATH |
| @@ -122,18 +160,18 @@ | ||
| 122 | 160 | #if !defined(NAME_MAX) |
| 123 | 161 | # define NAME_MAX FILENAME_MAX |
| 124 | 162 | #endif |
| 125 | 163 | |
| 126 | 164 | /* 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 | |
| 165 | +#define DT_UNKNOWN 0 | |
| 166 | +#define DT_REG S_IFREG | |
| 167 | +#define DT_DIR S_IFDIR | |
| 168 | +#define DT_FIFO S_IFIFO | |
| 169 | +#define DT_SOCK S_IFSOCK | |
| 170 | +#define DT_CHR S_IFCHR | |
| 171 | +#define DT_BLK S_IFBLK | |
| 172 | +#define DT_LNK S_IFLNK | |
| 135 | 173 | |
| 136 | 174 | /* Macros for converting between st_mode and d_type */ |
| 137 | 175 | #define IFTODT(mode) ((mode) & S_IFMT) |
| 138 | 176 | #define DTTOIF(type) (type) |
| 139 | 177 | |
| @@ -141,17 +179,31 @@ | ||
| 141 | 179 | * File type macros. Note that block devices, sockets and links cannot be |
| 142 | 180 | * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are |
| 143 | 181 | * only defined for compatibility. These macros should always return false |
| 144 | 182 | * on Windows. |
| 145 | 183 | */ |
| 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) | |
| 184 | +#if !defined(S_ISFIFO) | |
| 185 | +# define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) | |
| 186 | +#endif | |
| 187 | +#if !defined(S_ISDIR) | |
| 188 | +# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) | |
| 189 | +#endif | |
| 190 | +#if !defined(S_ISREG) | |
| 191 | +# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) | |
| 192 | +#endif | |
| 193 | +#if !defined(S_ISLNK) | |
| 194 | +# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) | |
| 195 | +#endif | |
| 196 | +#if !defined(S_ISSOCK) | |
| 197 | +# define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) | |
| 198 | +#endif | |
| 199 | +#if !defined(S_ISCHR) | |
| 200 | +# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) | |
| 201 | +#endif | |
| 202 | +#if !defined(S_ISBLK) | |
| 203 | +# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) | |
| 204 | +#endif | |
| 153 | 205 | |
| 154 | 206 | /* Return the exact length of d_namlen without zero terminator */ |
| 155 | 207 | #define _D_EXACT_NAMLEN(p) ((p)->d_namlen) |
| 156 | 208 | |
| 157 | 209 | /* Return number of bytes needed to store d_namlen */ |
| @@ -163,24 +215,42 @@ | ||
| 163 | 215 | #endif |
| 164 | 216 | |
| 165 | 217 | |
| 166 | 218 | /* Wide-character version */ |
| 167 | 219 | struct _wdirent { |
| 168 | - long d_ino; /* Always zero */ | |
| 169 | - unsigned short d_reclen; /* Structure size */ | |
| 170 | - size_t d_namlen; /* Length of name without \0 */ | |
| 171 | - int d_type; /* File type */ | |
| 172 | - wchar_t d_name[PATH_MAX]; /* File name */ | |
| 220 | + /* Always zero */ | |
| 221 | + long d_ino; | |
| 222 | + | |
| 223 | + /* Structure size */ | |
| 224 | + unsigned short d_reclen; | |
| 225 | + | |
| 226 | + /* Length of name without \0 */ | |
| 227 | + size_t d_namlen; | |
| 228 | + | |
| 229 | + /* File type */ | |
| 230 | + int d_type; | |
| 231 | + | |
| 232 | + /* File name */ | |
| 233 | + wchar_t d_name[PATH_MAX]; | |
| 173 | 234 | }; |
| 174 | 235 | typedef struct _wdirent _wdirent; |
| 175 | 236 | |
| 176 | 237 | struct _WDIR { |
| 177 | - struct _wdirent ent; /* Current directory entry */ | |
| 178 | - WIN32_FIND_DATAW data; /* Private file data */ | |
| 179 | - int cached; /* True if data is valid */ | |
| 180 | - HANDLE handle; /* Win32 search handle */ | |
| 181 | - wchar_t *patt; /* Initial directory name */ | |
| 238 | + /* Current directory entry */ | |
| 239 | + struct _wdirent ent; | |
| 240 | + | |
| 241 | + /* Private file data */ | |
| 242 | + WIN32_FIND_DATAW data; | |
| 243 | + | |
| 244 | + /* True if data is valid */ | |
| 245 | + int cached; | |
| 246 | + | |
| 247 | + /* Win32 search handle */ | |
| 248 | + HANDLE handle; | |
| 249 | + | |
| 250 | + /* Initial directory name */ | |
| 251 | + wchar_t *patt; | |
| 182 | 252 | }; |
| 183 | 253 | typedef struct _WDIR _WDIR; |
| 184 | 254 | |
| 185 | 255 | static _WDIR *_wopendir (const wchar_t *dirname); |
| 186 | 256 | static struct _wdirent *_wreaddir (_WDIR *dirp); |
| @@ -197,15 +267,24 @@ | ||
| 197 | 267 | #define wrewinddir _wrewinddir |
| 198 | 268 | |
| 199 | 269 | |
| 200 | 270 | /* Multi-byte character versions */ |
| 201 | 271 | struct dirent { |
| 202 | - long d_ino; /* Always zero */ | |
| 203 | - unsigned short d_reclen; /* Structure size */ | |
| 204 | - size_t d_namlen; /* Length of name without \0 */ | |
| 205 | - int d_type; /* File type */ | |
| 206 | - char d_name[PATH_MAX]; /* File name */ | |
| 272 | + /* Always zero */ | |
| 273 | + long d_ino; | |
| 274 | + | |
| 275 | + /* Structure size */ | |
| 276 | + unsigned short d_reclen; | |
| 277 | + | |
| 278 | + /* Length of name without \0 */ | |
| 279 | + size_t d_namlen; | |
| 280 | + | |
| 281 | + /* File type */ | |
| 282 | + int d_type; | |
| 283 | + | |
| 284 | + /* File name */ | |
| 285 | + char d_name[PATH_MAX]; | |
| 207 | 286 | }; |
| 208 | 287 | typedef struct dirent dirent; |
| 209 | 288 | |
| 210 | 289 | struct DIR { |
| 211 | 290 | struct dirent ent; |
| 212 | 291 |
| --- win/include/dirent.h | |
| +++ win/include/dirent.h | |
| @@ -1,30 +1,13 @@ | |
| 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 DIRENT_H |
| 28 | #define DIRENT_H |
| 29 | |
| 30 | /* |
| @@ -60,58 +43,113 @@ | |
| 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 |
| @@ -122,18 +160,18 @@ | |
| 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 | |
| @@ -141,17 +179,31 @@ | |
| 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 */ |
| @@ -163,24 +215,42 @@ | |
| 163 | #endif |
| 164 | |
| 165 | |
| 166 | /* Wide-character version */ |
| 167 | struct _wdirent { |
| 168 | long d_ino; /* Always zero */ |
| 169 | unsigned short d_reclen; /* Structure size */ |
| 170 | size_t d_namlen; /* Length of name without \0 */ |
| 171 | int d_type; /* File type */ |
| 172 | wchar_t d_name[PATH_MAX]; /* File name */ |
| 173 | }; |
| 174 | typedef struct _wdirent _wdirent; |
| 175 | |
| 176 | struct _WDIR { |
| 177 | struct _wdirent ent; /* Current directory entry */ |
| 178 | WIN32_FIND_DATAW data; /* Private file data */ |
| 179 | int cached; /* True if data is valid */ |
| 180 | HANDLE handle; /* Win32 search handle */ |
| 181 | wchar_t *patt; /* Initial directory name */ |
| 182 | }; |
| 183 | typedef struct _WDIR _WDIR; |
| 184 | |
| 185 | static _WDIR *_wopendir (const wchar_t *dirname); |
| 186 | static struct _wdirent *_wreaddir (_WDIR *dirp); |
| @@ -197,15 +267,24 @@ | |
| 197 | #define wrewinddir _wrewinddir |
| 198 | |
| 199 | |
| 200 | /* Multi-byte character versions */ |
| 201 | struct dirent { |
| 202 | long d_ino; /* Always zero */ |
| 203 | unsigned short d_reclen; /* Structure size */ |
| 204 | size_t d_namlen; /* Length of name without \0 */ |
| 205 | int d_type; /* File type */ |
| 206 | char d_name[PATH_MAX]; /* File name */ |
| 207 | }; |
| 208 | typedef struct dirent dirent; |
| 209 | |
| 210 | struct DIR { |
| 211 | struct dirent ent; |
| 212 |
| --- win/include/dirent.h | |
| +++ win/include/dirent.h | |
| @@ -1,30 +1,13 @@ | |
| 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 | /* |
| @@ -60,58 +43,113 @@ | |
| 43 | /* Entries missing from MSVC 6.0 */ |
| 44 | #if !defined(FILE_ATTRIBUTE_DEVICE) |
| 45 | # define FILE_ATTRIBUTE_DEVICE 0x40 |
| 46 | #endif |
| 47 | |
| 48 | /* File type and permission flags for stat(), general mask */ |
| 49 | #if !defined(S_IFMT) |
| 50 | # define S_IFMT _S_IFMT |
| 51 | #endif |
| 52 | |
| 53 | /* Directory bit */ |
| 54 | #if !defined(S_IFDIR) |
| 55 | # define S_IFDIR _S_IFDIR |
| 56 | #endif |
| 57 | |
| 58 | /* Character device bit */ |
| 59 | #if !defined(S_IFCHR) |
| 60 | # define S_IFCHR _S_IFCHR |
| 61 | #endif |
| 62 | |
| 63 | /* Pipe bit */ |
| 64 | #if !defined(S_IFFIFO) |
| 65 | # define S_IFFIFO _S_IFFIFO |
| 66 | #endif |
| 67 | |
| 68 | /* Regular file bit */ |
| 69 | #if !defined(S_IFREG) |
| 70 | # define S_IFREG _S_IFREG |
| 71 | #endif |
| 72 | |
| 73 | /* Read permission */ |
| 74 | #if !defined(S_IREAD) |
| 75 | # define S_IREAD _S_IREAD |
| 76 | #endif |
| 77 | |
| 78 | /* Write permission */ |
| 79 | #if !defined(S_IWRITE) |
| 80 | # define S_IWRITE _S_IWRITE |
| 81 | #endif |
| 82 | |
| 83 | /* Execute permission */ |
| 84 | #if !defined(S_IEXEC) |
| 85 | # define S_IEXEC _S_IEXEC |
| 86 | #endif |
| 87 | |
| 88 | /* Pipe */ |
| 89 | #if !defined(S_IFIFO) |
| 90 | # define S_IFIFO _S_IFIFO |
| 91 | #endif |
| 92 | |
| 93 | /* Block device */ |
| 94 | #if !defined(S_IFBLK) |
| 95 | # define S_IFBLK 0 |
| 96 | #endif |
| 97 | |
| 98 | /* Link */ |
| 99 | #if !defined(S_IFLNK) |
| 100 | # define S_IFLNK 0 |
| 101 | #endif |
| 102 | |
| 103 | /* Socket */ |
| 104 | #if !defined(S_IFSOCK) |
| 105 | # define S_IFSOCK 0 |
| 106 | #endif |
| 107 | |
| 108 | /* Read user permission */ |
| 109 | #if !defined(S_IRUSR) |
| 110 | # define S_IRUSR S_IREAD |
| 111 | #endif |
| 112 | |
| 113 | /* Write user permission */ |
| 114 | #if !defined(S_IWUSR) |
| 115 | # define S_IWUSR S_IWRITE |
| 116 | #endif |
| 117 | |
| 118 | /* Execute user permission */ |
| 119 | #if !defined(S_IXUSR) |
| 120 | # define S_IXUSR 0 |
| 121 | #endif |
| 122 | |
| 123 | /* Read group permission */ |
| 124 | #if !defined(S_IRGRP) |
| 125 | # define S_IRGRP 0 |
| 126 | #endif |
| 127 | |
| 128 | /* Write group permission */ |
| 129 | #if !defined(S_IWGRP) |
| 130 | # define S_IWGRP 0 |
| 131 | #endif |
| 132 | |
| 133 | /* Execute group permission */ |
| 134 | #if !defined(S_IXGRP) |
| 135 | # define S_IXGRP 0 |
| 136 | #endif |
| 137 | |
| 138 | /* Read others permission */ |
| 139 | #if !defined(S_IROTH) |
| 140 | # define S_IROTH 0 |
| 141 | #endif |
| 142 | |
| 143 | /* Write others permission */ |
| 144 | #if !defined(S_IWOTH) |
| 145 | # define S_IWOTH 0 |
| 146 | #endif |
| 147 | |
| 148 | /* Execute others permission */ |
| 149 | #if !defined(S_IXOTH) |
| 150 | # define S_IXOTH 0 |
| 151 | #endif |
| 152 | |
| 153 | /* Maximum length of file name */ |
| 154 | #if !defined(PATH_MAX) |
| 155 | # define PATH_MAX MAX_PATH |
| @@ -122,18 +160,18 @@ | |
| 160 | #if !defined(NAME_MAX) |
| 161 | # define NAME_MAX FILENAME_MAX |
| 162 | #endif |
| 163 | |
| 164 | /* File type flags for d_type */ |
| 165 | #define DT_UNKNOWN 0 |
| 166 | #define DT_REG S_IFREG |
| 167 | #define DT_DIR S_IFDIR |
| 168 | #define DT_FIFO S_IFIFO |
| 169 | #define DT_SOCK S_IFSOCK |
| 170 | #define DT_CHR S_IFCHR |
| 171 | #define DT_BLK S_IFBLK |
| 172 | #define DT_LNK S_IFLNK |
| 173 | |
| 174 | /* Macros for converting between st_mode and d_type */ |
| 175 | #define IFTODT(mode) ((mode) & S_IFMT) |
| 176 | #define DTTOIF(type) (type) |
| 177 | |
| @@ -141,17 +179,31 @@ | |
| 179 | * File type macros. Note that block devices, sockets and links cannot be |
| 180 | * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are |
| 181 | * only defined for compatibility. These macros should always return false |
| 182 | * on Windows. |
| 183 | */ |
| 184 | #if !defined(S_ISFIFO) |
| 185 | # define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) |
| 186 | #endif |
| 187 | #if !defined(S_ISDIR) |
| 188 | # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) |
| 189 | #endif |
| 190 | #if !defined(S_ISREG) |
| 191 | # define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) |
| 192 | #endif |
| 193 | #if !defined(S_ISLNK) |
| 194 | # define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) |
| 195 | #endif |
| 196 | #if !defined(S_ISSOCK) |
| 197 | # define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) |
| 198 | #endif |
| 199 | #if !defined(S_ISCHR) |
| 200 | # define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) |
| 201 | #endif |
| 202 | #if !defined(S_ISBLK) |
| 203 | # define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) |
| 204 | #endif |
| 205 | |
| 206 | /* Return the exact length of d_namlen without zero terminator */ |
| 207 | #define _D_EXACT_NAMLEN(p) ((p)->d_namlen) |
| 208 | |
| 209 | /* Return number of bytes needed to store d_namlen */ |
| @@ -163,24 +215,42 @@ | |
| 215 | #endif |
| 216 | |
| 217 | |
| 218 | /* Wide-character version */ |
| 219 | struct _wdirent { |
| 220 | /* Always zero */ |
| 221 | long d_ino; |
| 222 | |
| 223 | /* Structure size */ |
| 224 | unsigned short d_reclen; |
| 225 | |
| 226 | /* Length of name without \0 */ |
| 227 | size_t d_namlen; |
| 228 | |
| 229 | /* File type */ |
| 230 | int d_type; |
| 231 | |
| 232 | /* File name */ |
| 233 | wchar_t d_name[PATH_MAX]; |
| 234 | }; |
| 235 | typedef struct _wdirent _wdirent; |
| 236 | |
| 237 | struct _WDIR { |
| 238 | /* Current directory entry */ |
| 239 | struct _wdirent ent; |
| 240 | |
| 241 | /* Private file data */ |
| 242 | WIN32_FIND_DATAW data; |
| 243 | |
| 244 | /* True if data is valid */ |
| 245 | int cached; |
| 246 | |
| 247 | /* Win32 search handle */ |
| 248 | HANDLE handle; |
| 249 | |
| 250 | /* Initial directory name */ |
| 251 | wchar_t *patt; |
| 252 | }; |
| 253 | typedef struct _WDIR _WDIR; |
| 254 | |
| 255 | static _WDIR *_wopendir (const wchar_t *dirname); |
| 256 | static struct _wdirent *_wreaddir (_WDIR *dirp); |
| @@ -197,15 +267,24 @@ | |
| 267 | #define wrewinddir _wrewinddir |
| 268 | |
| 269 | |
| 270 | /* Multi-byte character versions */ |
| 271 | struct dirent { |
| 272 | /* Always zero */ |
| 273 | long d_ino; |
| 274 | |
| 275 | /* Structure size */ |
| 276 | unsigned short d_reclen; |
| 277 | |
| 278 | /* Length of name without \0 */ |
| 279 | size_t d_namlen; |
| 280 | |
| 281 | /* File type */ |
| 282 | int d_type; |
| 283 | |
| 284 | /* File name */ |
| 285 | char d_name[PATH_MAX]; |
| 286 | }; |
| 287 | typedef struct dirent dirent; |
| 288 | |
| 289 | struct DIR { |
| 290 | struct dirent ent; |
| 291 |