OSDN Git Service

Timeval struct bitness issue [#2059]
[mingw/mingw-org-wsl.git] / include / io.h
1 /**
2  * @file io.h
3  * Copyright 2012, 2013 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _IO_H_
25 #define _IO_H_
26 #pragma GCC system_header
27 #include <_mingw.h>
28
29 /* MSVC's io.h contains the stuff from dir.h, so I will too.
30  * NOTE: This also defines off_t, the file offset type, through
31  *       an inclusion of sys/types.h */
32
33 #include <sys/types.h>  /* To get time_t.  */
34
35 /*
36  * Attributes of files as returned by _findfirst et al.
37  */
38 #define _A_NORMAL       0x00000000
39 #define _A_RDONLY       0x00000001
40 #define _A_HIDDEN       0x00000002
41 #define _A_SYSTEM       0x00000004
42 #define _A_VOLID        0x00000008
43 #define _A_SUBDIR       0x00000010
44 #define _A_ARCH         0x00000020
45
46
47 #ifndef RC_INVOKED
48
49 #ifndef _INTPTR_T_DEFINED
50 #define _INTPTR_T_DEFINED
51 #ifdef _WIN64
52   typedef __int64 intptr_t;
53 #else
54   typedef int intptr_t;
55 #endif
56 #endif
57
58 #ifndef _FSIZE_T_DEFINED
59 typedef unsigned long   _fsize_t;
60 #define _FSIZE_T_DEFINED
61 #endif
62
63 /*
64  * The maximum length of a file name. You should use GetVolumeInformation
65  * instead of this constant. But hey, this works.
66  * Also defined in stdio.h.
67  */
68 #ifndef FILENAME_MAX
69 #define FILENAME_MAX    (260)
70 #endif
71
72 #ifndef _FINDDATA_T_DEFINED
73 /*
74  * The following structure is filled in by _findfirst or _findnext when
75  * they succeed in finding a match.
76  */
77 struct _finddata32_t {
78         unsigned        attrib;
79         __time32_t      time_create;
80         __time32_t      time_access;
81         __time32_t      time_write;
82         _fsize_t        size;
83         char            name[FILENAME_MAX];
84 };
85
86 struct __finddata64_t {
87         unsigned    attrib;
88         __time64_t  time_create;
89         __time64_t  time_access;
90         __time64_t  time_write;
91         __int64    size;
92          char       name[FILENAME_MAX];
93 };
94
95 struct _finddata32i64_t {
96         unsigned        attrib;
97         __time32_t      time_create;
98         __time32_t      time_access;
99         __time32_t      time_write;
100         __int64         size;
101         char            name[FILENAME_MAX];
102 };
103
104 struct _finddata64i32_t {
105         unsigned        attrib;
106         __time64_t      time_create;
107         __time64_t      time_access;
108         __time64_t      time_write;
109         _fsize_t        size;
110         char            name[FILENAME_MAX];
111 };
112
113 #define _FINDDATA_T_DEFINED
114 #endif /* !_FINDDATA_T_DEFINED */
115
116 #ifndef _WFINDDATA_T_DEFINED
117 struct _wfinddata32_t {
118         unsigned        attrib;
119         __time32_t      time_create;
120         __time32_t      time_access;
121         __time32_t      time_write;
122         _fsize_t        size;
123         wchar_t         name[FILENAME_MAX];
124 };
125
126 struct _wfinddata64_t {
127         unsigned    attrib;
128         __time64_t  time_create;
129         __time64_t  time_access;
130         __time64_t  time_write;
131 /* 8 bytes are returned so it can't be _fsize_t */
132         __int64    size;
133         wchar_t     name[FILENAME_MAX];
134 };
135
136 struct _wfinddata32i64_t {
137         unsigned        attrib;
138         __time32_t      time_create;
139         __time32_t      time_access;
140         __time32_t      time_write;
141         __int64         size;
142         wchar_t         name[FILENAME_MAX];
143 };
144
145 struct _wfinddata64i32_t {
146         unsigned        attrib;
147         __time64_t      time_create;
148         __time64_t      time_access;
149         __time64_t      time_write;
150         __int32         size;
151         wchar_t         name[FILENAME_MAX];
152 };
153 #define _WFINDDATA_T_DEFINED
154 #endif /* ! _WFINDDATA_T_DEFINED */
155
156 #ifdef  __cplusplus
157 extern "C" {
158 #endif
159
160 /*
161  * Functions for searching for files. _findfirst returns -1 if no match
162  * is found. Otherwise it returns a handle to be used in _findnext and
163  * _findclose calls. _findnext also returns -1 if no match could be found,
164  * and 0 if a match was found. Call _findclose when you are finished.
165  */
166 /*
167 intptr_t _findfirst      (const char *filespec,struct _finddata_t      *fileinfo);
168 intptr_t _findfirst32    (const char *filespec,struct _finddata32_t    *fileinfo);
169 intptr_t _findfirst64    (const char *filespec,struct __finddata64_t   *fileinfo);
170 intptr_t _findfirsti64   (const char *filespec,struct _finddatai64_t   *fileinfo);
171 intptr_t _findfirst32i64 (const char *filespec,struct _finddata32i64_t *fileinfo);
172 intptr_t _findfirst64i32 (const char *filespec,struct _finddata64i32_t *fileinfo);
173
174 intptr_t _wfindfirst     (const wchar_t *filespec,struct _wfinddata_t *fileinfo);
175 intptr_t _wfindfirst32   (const wchar_t *filespec,struct _wfinddata32_t *fileinfo);
176 intptr_t _wfindfirst64   (const wchar_t *filespec, struct _wfinddata64_t   *fileinfo);
177 intptr_t _wfindfirsti64  (const wchar_t *filespec, struct _wfinddatai64_t   *fileinfo);
178 intptr_t _wfindfirst32i64(const wchar_t *filespec, struct _wfinddata32i64_t *fileinfo);
179 intptr_t _wfindfirst64i32(const wchar_t *filespec, struct _wfinddata64i32_t *fileinfo);
180
181 Time Type and File Length Type Variations of _findfirst:
182 Functions               _USE_32BIT_TIME_T defined?      Time type       File length type
183 _findfirst,             Not defined                     64-bit          32-bit
184 _wfindfirst
185 _findfirst,             Defined                         32-bit          32-bit
186 _wfindfirst
187
188 _findfirst32,           Not affected by the macro       32-bit          32-bit
189 _wfindfirst32           definition
190
191 _findfirst64,           Not affected by the macro       64-bit          64-bit
192 _wfindfirst64           definition
193
194 _findfirsti64,          Not defined                     64-bit          64-bit
195 _wfindfirsti64
196 _findfirsti64,          Defined                         32-bit          64-bit
197 _wfindfirsti64
198
199 _findfirst32i64,        Not affected by the macro       32-bit          64-bit
200 _wfindfirst32i64        definition
201
202 _findfirst64i32,        Not affected by the macro       64-bit          32-bit
203 _wfindfirst64i32        definition
204 */
205
206 _CRTIMP int __cdecl __MINGW_NOTHROW _findclose (intptr_t);
207
208 /* _findfirst32 and _findnext32 do not exist in MSVCRT.DLL */
209 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst (const char*, struct _finddata32_t*);
210 _CRTALIAS intptr_t __cdecl __MINGW_NOTHROW _findfirst32 (const char* _v1, struct _finddata32_t* _v2) {
211     return _findfirst(_v1, _v2);
212 }
213 _CRTIMP int  __cdecl __MINGW_NOTHROW _findnext (intptr_t, struct _finddata32_t*);
214 _CRTALIAS int  __cdecl __MINGW_NOTHROW  _findnext32 (intptr_t _v1, struct _finddata32_t* _v2) {
215     return _findnext(_v1, _v2);
216 }
217
218 _CRTIMP int __cdecl __MINGW_NOTHROW _chdir (const char*);
219 _CRTIMP char* __cdecl __MINGW_NOTHROW _getcwd (char*, int);
220 _CRTIMP int __cdecl __MINGW_NOTHROW _mkdir (const char*);
221 _CRTIMP char* __cdecl __MINGW_NOTHROW _mktemp (char*);
222 _CRTIMP int __cdecl __MINGW_NOTHROW _rmdir (const char*);
223 _CRTIMP int __cdecl __MINGW_NOTHROW _chmod (const char*, int);
224 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _filelengthi64(int);
225 _CRTIMP int __cdecl __MINGW_NOTHROW _findnexti64(intptr_t, struct _finddatai64_t*);
226 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _lseeki64(int, __int64, int);
227 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int);
228 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst64(const char*, struct __finddata64_t*);
229 intptr_t __cdecl __MINGW_NOTHROW _findfirst32i64(const char*, struct _finddata32i64_t*);
230 intptr_t __cdecl __MINGW_NOTHROW _findfirst64i32(const char*, struct _finddata64i32_t*);
231 _CRTIMP int __cdecl __MINGW_NOTHROW _findnext64(intptr_t, struct __finddata64_t*);
232 int __cdecl __MINGW_NOTHROW _findnext32i64(intptr_t, struct _finddata32i64_t*);
233 int __cdecl __MINGW_NOTHROW _findnext64i32(intptr_t, struct _finddata64i32_t*);
234
235 #include <string.h>
236 __CRT_MAYBE_INLINE __cdecl __MINGW_NOTHROW intptr_t _findfirst32i64(const char* _filename, struct _finddata32i64_t* _fdata) {
237     struct __finddata64_t fd;
238     intptr_t ret = _findfirst64(_filename, &fd);
239     if (ret == -1) {
240         memset(_fdata, 0, sizeof(struct __finddata64_t));
241         return ret;
242     }
243     _fdata->attrib = fd.attrib;
244     _fdata->time_create = (__time32_t)fd.time_create;
245     _fdata->time_access = (__time32_t)fd.time_access;
246     _fdata->time_write  = (__time32_t)fd.time_write;
247     _fdata->size        = fd.size;
248     strncpy(_fdata->name, fd.name, FILENAME_MAX);
249     return ret;
250 }
251
252 __CRT_MAYBE_INLINE __cdecl __MINGW_NOTHROW intptr_t _findfirst64i32(const char* _filename, struct _finddata64i32_t* _fdata) {
253     struct _finddata32_t fd;
254     intptr_t ret = _findfirst32(_filename, &fd);
255     if (ret == -1) {
256         memset(_fdata, 0, sizeof(struct _finddata32_t));
257         return ret;
258     }
259     _fdata->attrib = fd.attrib;
260     _fdata->time_create = (__time64_t)fd.time_create;
261     _fdata->time_access = (__time64_t)fd.time_access;
262     _fdata->time_write  = (__time64_t)fd.time_write;
263     _fdata->size        = fd.size;
264     strncpy(_fdata->name, fd.name, FILENAME_MAX);
265     return ret;
266 }
267
268 __CRT_MAYBE_INLINE __cdecl __MINGW_NOTHROW intptr_t _findnext32i64(intptr_t _fp, struct _finddata32i64_t* _fdata) {
269     struct __finddata64_t fd;
270     int ret = _findnext64(_fp,&fd);
271     if (ret == -1) {
272       memset(_fdata, 0, sizeof(struct _finddata32i64_t));
273       return ret;
274     }
275     _fdata->attrib = fd.attrib;
276     _fdata->time_create = (__time32_t)fd.time_create;
277     _fdata->time_access = (__time32_t)fd.time_access;
278     _fdata->time_write  = (__time32_t)fd.time_write;
279     _fdata->size        = fd.size;
280     strncpy(_fdata->name, fd.name, FILENAME_MAX);
281     return ret;
282 }
283
284 __CRT_MAYBE_INLINE __cdecl __MINGW_NOTHROW intptr_t _findnext64i32(intptr_t _fp, struct _finddata64i32_t* _fdata) {
285     struct _finddata32_t fd;
286     int ret = _findnext32(_fp, &fd);
287     if (ret == -1) {
288       memset(_fdata, 0, sizeof(struct _finddata64i32_t));
289       return ret;
290     }
291     _fdata->attrib = fd.attrib;
292     _fdata->time_create = (__time64_t)fd.time_create;
293     _fdata->time_access = (__time64_t)fd.time_access;
294     _fdata->time_write  = (__time64_t)fd.time_write;
295     _fdata->size        = fd.size;
296     strncpy(_fdata->name, fd.name, FILENAME_MAX);
297     return ret;
298 }
299
300 #ifndef __NO_MINGW_LFS
301 __CRT_INLINE _off64_t lseek64 (int, _off64_t, int);
302 __CRT_INLINE _off64_t lseek64 (int fd, _off64_t offset, int whence) {
303   return _lseeki64(fd, (__int64) offset, whence);
304 }
305 #endif
306
307 #ifndef _NO_OLDNAMES
308
309 _CRTIMP int __cdecl __MINGW_NOTHROW chdir (const char*);
310 _CRTIMP char* __cdecl __MINGW_NOTHROW getcwd (char*, int);
311 _CRTIMP int __cdecl __MINGW_NOTHROW mkdir (const char*);
312 _CRTIMP char* __cdecl __MINGW_NOTHROW mktemp (char*);
313 _CRTIMP int __cdecl __MINGW_NOTHROW rmdir (const char*);
314 _CRTIMP int __cdecl __MINGW_NOTHROW chmod (const char*, int);
315
316 #endif /* Not _NO_OLDNAMES */
317
318 #ifdef  __cplusplus
319 }
320 #endif
321
322 #endif  /* Not RC_INVOKED */
323
324 /* TODO: Maximum number of open handles has not been tested, I just set
325  * it the same as FOPEN_MAX. */
326 #define HANDLE_MAX      FOPEN_MAX
327
328 /* Some defines for _access nAccessMode (MS doesn't define them, but
329  * it doesn't seem to hurt to add them). */
330 #define F_OK    0       /* Check for file existence */
331 /* Well maybe it does hurt.  On newer versions of MSVCRT, an access mode
332    of 1 causes invalid parameter error. */
333 #define X_OK    1       /* MS access() doesn't check for execute permission. */
334 #define W_OK    2       /* Check for write permission */
335 #define R_OK    4       /* Check for read permission */
336
337 #ifndef RC_INVOKED
338
339 #ifdef  __cplusplus
340 extern "C" {
341 #endif
342
343 _CRTIMP int __cdecl __MINGW_NOTHROW _access (const char*, int);
344 _CRTIMP int __cdecl __MINGW_NOTHROW _chsize (int, long);
345 _CRTIMP int __cdecl __MINGW_NOTHROW _close (int);
346 _CRTIMP int __cdecl __MINGW_NOTHROW _commit(int);
347
348 /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
349  *       the "owner write permission" bit (on FAT). */
350 _CRTIMP int __cdecl __MINGW_NOTHROW _creat (const char*, int);
351
352 _CRTIMP int __cdecl __MINGW_NOTHROW _dup (int);
353 _CRTIMP int __cdecl __MINGW_NOTHROW _dup2 (int, int);
354 _CRTIMP long __cdecl __MINGW_NOTHROW _filelength (int);
355 _CRTIMP long __cdecl __MINGW_NOTHROW _get_osfhandle (int);
356 _CRTIMP int __cdecl __MINGW_NOTHROW _isatty (int);
357
358 /* In a very odd turn of events this function is excluded from those
359  * files which define _STREAM_COMPAT. This is required in order to
360  * build GNU libio because of a conflict with _eof in streambuf.h
361  * line 107. Actually I might just be able to change the name of
362  * the enum member in streambuf.h... we'll see. TODO */
363 #ifndef _STREAM_COMPAT
364 _CRTIMP int __cdecl __MINGW_NOTHROW _eof (int);
365 #endif
366
367 /* LK_... locking commands defined in sys/locking.h. */
368 _CRTIMP int __cdecl __MINGW_NOTHROW _locking (int, int, long);
369
370 _CRTIMP long __cdecl __MINGW_NOTHROW _lseek (int, long, int);
371
372 /* Optional third argument is unsigned unPermissions. */
373 _CRTIMP int __cdecl __MINGW_NOTHROW _open (const char*, int, ...);
374
375 _CRTIMP int __cdecl __MINGW_NOTHROW _open_osfhandle (intptr_t, int);
376 _CRTIMP int __cdecl __MINGW_NOTHROW _pipe (int *, unsigned int, int);
377 _CRTIMP int __cdecl __MINGW_NOTHROW _read (int, void*, unsigned int);
378 _CRTIMP int __cdecl __MINGW_NOTHROW _setmode (int, int);
379 /* MS puts remove & rename (but not wide versions) in io.h as well
380    as in stdio.h. */
381 _CRTIMP int __cdecl __MINGW_NOTHROW     remove (const char*);
382 _CRTIMP int __cdecl __MINGW_NOTHROW     rename (const char*, const char*);
383
384 /* SH_... flags for nShFlags defined in share.h
385  * Optional fourth argument is unsigned unPermissions */
386 _CRTIMP int __cdecl __MINGW_NOTHROW _sopen (const char*, int, int, ...);
387
388 _CRTIMP long __cdecl __MINGW_NOTHROW _tell (int);
389 /* Should umask be in sys/stat.h and/or sys/types.h instead? */
390 _CRTIMP int __cdecl __MINGW_NOTHROW _umask (int);
391 _CRTIMP int __cdecl __MINGW_NOTHROW _unlink (const char*);
392 _CRTIMP int __cdecl __MINGW_NOTHROW _write (int, const void*, unsigned int);
393
394 /* Wide character versions. Also declared in wchar.h. */
395 #if !defined (_WIO_DEFINED)
396 #define _WIO_DEFINED
397 _CRTIMP int __cdecl __MINGW_NOTHROW _waccess(const wchar_t*, int);
398 _CRTIMP int __cdecl __MINGW_NOTHROW _wchmod(const wchar_t*, int);
399 _CRTIMP int __cdecl __MINGW_NOTHROW _wcreat(const wchar_t*, int);
400
401 /* _wfindfirst32 and _wfindnext32 do not exist in MSVCRT.DLL */
402 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst (const wchar_t*, struct _wfinddata32_t*);
403 intptr_t __cdecl __MINGW_NOTHROW _wfindfirst32 (const wchar_t*, struct _wfinddata32_t*);
404 _CRTALIAS intptr_t __cdecl __MINGW_NOTHROW _wfindfirst32 (const wchar_t* _v1, struct _wfinddata32_t* _v2) {
405     return _wfindfirst(_v1, _v2);
406 }
407 _CRTIMP int  __cdecl __MINGW_NOTHROW _wfindnext (intptr_t, struct _wfinddata32_t*);
408 int  __cdecl __MINGW_NOTHROW    _wfindnext32 (intptr_t, struct _wfinddata32_t*);
409 _CRTALIAS int  __cdecl __MINGW_NOTHROW  _wfindnext32 (intptr_t _v1, struct _wfinddata32_t* _v2) {
410     return _wfindnext(_v1, _v2);
411 }
412
413 _CRTIMP int __cdecl __MINGW_NOTHROW _wunlink(const wchar_t*);
414 _CRTIMP int __cdecl __MINGW_NOTHROW _wopen(const wchar_t*, int, ...);
415 _CRTIMP int __cdecl __MINGW_NOTHROW _wsopen(const wchar_t*, int, int, ...);
416 _CRTIMP wchar_t * __cdecl __MINGW_NOTHROW _wmktemp(wchar_t*);
417 _CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64(const wchar_t*, struct _wfinddata64_t*);
418 intptr_t __cdecl __MINGW_NOTHROW _wfindfirst32i64 (const wchar_t*, struct _wfinddata32i64_t*);
419 intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64i32 (const wchar_t*, struct _wfinddata64i32_t*);
420 _CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext64(intptr_t, struct _wfinddata64_t*);
421 int  __cdecl __MINGW_NOTHROW    _wfindnext32i64 (intptr_t, struct _wfinddata32i64_t*);
422 int  __cdecl __MINGW_NOTHROW    _wfindnext64i32 (intptr_t, struct _wfinddata64i32_t*);
423
424 #include <string.h>
425 __CRT_MAYBE_INLINE __cdecl __MINGW_NOTHROW intptr_t _wfindfirst32i64(const wchar_t* _filename, struct _wfinddata32i64_t* _fdata) {
426     struct _wfinddata64_t fd;
427     intptr_t ret = _wfindfirst64(_filename, &fd);
428     if (ret == -1) {
429         memset(_fdata, 0, sizeof(struct _wfinddata64_t));
430         return ret;
431     }
432     _fdata->attrib = fd.attrib;
433     _fdata->time_create = (__time32_t)fd.time_create;
434     _fdata->time_access = (__time32_t)fd.time_access;
435     _fdata->time_write  = (__time32_t)fd.time_write;
436     _fdata->size        = fd.size;
437     wcsncpy(_fdata->name, fd.name, FILENAME_MAX);
438     return ret;
439 }
440
441 __CRT_MAYBE_INLINE __cdecl __MINGW_NOTHROW intptr_t _wfindfirst64i32(const wchar_t* _filename, struct _wfinddata64i32_t* _fdata) {
442     struct _wfinddata32_t fd;
443     intptr_t ret = _wfindfirst32(_filename, &fd);
444     if (ret == -1) {
445         memset(_fdata, 0, sizeof(struct _wfinddata32_t));
446         return ret;
447     }
448     _fdata->attrib = fd.attrib;
449     _fdata->time_create = (__time64_t)fd.time_create;
450     _fdata->time_access = (__time64_t)fd.time_access;
451     _fdata->time_write  = (__time64_t)fd.time_write;
452     _fdata->size        = fd.size;
453     wcsncpy(_fdata->name, fd.name, FILENAME_MAX);
454     return ret;
455 }
456
457 __CRT_MAYBE_INLINE __cdecl __MINGW_NOTHROW intptr_t _wfindnext32i64(intptr_t _fp, struct _wfinddata32i64_t* _fdata) {
458     struct _wfinddata64_t fd;
459     int ret = _wfindnext64(_fp,&fd);
460     if (ret == -1) {
461       memset(_fdata, 0, sizeof(struct _wfinddata32i64_t));
462       return ret;
463     }
464     _fdata->attrib = fd.attrib;
465     _fdata->time_create = (__time32_t)fd.time_create;
466     _fdata->time_access = (__time32_t)fd.time_access;
467     _fdata->time_write  = (__time32_t)fd.time_write;
468     _fdata->size        = fd.size;
469     wcsncpy(_fdata->name, fd.name, FILENAME_MAX);
470     return ret;
471 }
472
473 __CRT_MAYBE_INLINE __cdecl __MINGW_NOTHROW intptr_t _wfindnext64i32(intptr_t _fp, struct _wfinddata64i32_t* _fdata) {
474     struct _wfinddata32_t fd;
475     int ret = _wfindnext32(_fp, &fd);
476     if (ret == -1) {
477       memset(_fdata, 0, sizeof(struct _wfinddata64i32_t));
478       return ret;
479     }
480     _fdata->attrib = fd.attrib;
481     _fdata->time_create = (__time64_t)fd.time_create;
482     _fdata->time_access = (__time64_t)fd.time_access;
483     _fdata->time_write  = (__time64_t)fd.time_write;
484     _fdata->size        = fd.size;
485     wcsncpy(_fdata->name, fd.name, FILENAME_MAX);
486     return ret;
487 }
488
489 #endif /* _WIO_DEFINED */
490
491 #ifndef _NO_OLDNAMES
492 /*
493  * Non-underscored versions of non-ANSI functions to improve portability.
494  * These functions live in libmoldname.a.
495  */
496
497 _CRTIMP int __cdecl __MINGW_NOTHROW access (const char*, int);
498 _CRTIMP int __cdecl __MINGW_NOTHROW chsize (int, long );
499 _CRTIMP int __cdecl __MINGW_NOTHROW close (int);
500 _CRTIMP int __cdecl __MINGW_NOTHROW creat (const char*, int);
501 _CRTIMP int __cdecl __MINGW_NOTHROW dup (int);
502 _CRTIMP int __cdecl __MINGW_NOTHROW dup2 (int, int);
503 _CRTIMP int __cdecl __MINGW_NOTHROW eof (int);
504 _CRTIMP long __cdecl __MINGW_NOTHROW filelength (int);
505 _CRTIMP int __cdecl __MINGW_NOTHROW isatty (int);
506 _CRTIMP long __cdecl __MINGW_NOTHROW lseek (int, long, int);
507 _CRTIMP int __cdecl __MINGW_NOTHROW open (const char*, int, ...);
508 _CRTIMP int __cdecl __MINGW_NOTHROW read (int, void*, unsigned int);
509 _CRTIMP int __cdecl __MINGW_NOTHROW setmode (int, int);
510 _CRTIMP int __cdecl __MINGW_NOTHROW sopen (const char*, int, int, ...);
511 _CRTIMP long __cdecl __MINGW_NOTHROW tell (int);
512 _CRTIMP int __cdecl __MINGW_NOTHROW umask (int);
513 _CRTIMP int __cdecl __MINGW_NOTHROW unlink (const char*);
514 _CRTIMP int __cdecl __MINGW_NOTHROW write (int, const void*, unsigned int);
515
516 #ifdef __USE_MINGW_ACCESS
517 /*  Old versions of MSVCRT access() just ignored X_OK, while the version
518     shipped with Vista, returns an error code.  This will restore the
519     old behaviour  */
520 static inline int __mingw_access (const char* __fname, int __mode)
521   { return  _access (__fname, __mode & ~X_OK); }
522 #define access(__f,__m)  __mingw_access (__f, __m)
523 #endif
524
525 /* Wide character versions. Also declared in wchar.h. */
526 /* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
527 #if 0
528 int             waccess(const wchar_t *, int);
529 int             wchmod(const wchar_t *, int);
530 int             wcreat(const wchar_t *, int);
531 intptr_t        wfindfirst(wchar_t *, struct _wfinddata_t *);
532 int             wfindnext(intptr_t, struct _wfinddata_t *);
533 int             wunlink(const wchar_t *);
534 int             wrename(const wchar_t *, const wchar_t *);
535 int             wopen(const wchar_t *, int, ...);
536 int             wsopen(const wchar_t *, int, int, ...);
537 wchar_t *       wmktemp(wchar_t *);
538 #endif
539
540 #endif  /* Not _NO_OLDNAMES */
541
542 #ifdef  __cplusplus
543 }
544 #endif
545
546 #if defined(_USE_32BIT_TIME_T)
547 #define _finddata_t _finddata32_t
548 #define _finddatai64_t _finddata32i64_t
549 #define _findfirst _findfirst32
550 #define _findnext _findnext32
551 #define _findfirsti64 _findfirst32i64
552 #define _findnexti64 _findnext32i64
553 #define _wfinddata_t _wfinddata32_t
554 #define _wfinddatai64_t _wfinddata32i64_t
555 #define _wfindfirst _wfindfirst32
556 #define _wfindnext _wfindnext32
557 #define _wfindfirsti64 _wfindfirst32i64
558 #define _wfindnexti64 _wfindnext32i64
559
560 #else /* !_USE_32BIT_TIME_T */
561 #define _finddata_t _finddata64i32_t
562 #define _finddatai64_t __finddata64_t
563 #define _findfirst _findfirst64i32
564 #define _findnext _findnext64i32
565 #define _findfirsti64 _findfirst64
566 #define _findnexti64 _findnext64
567 #define _wfinddata_t _wfinddata64i32_t
568 #define _wfinddatai64_t _wfinddata64_t
569 #define _wfindfirst _wfindfirst64i32
570 #define _wfindnext _wfindnext64i32
571 #define _wfindfirsti64 _wfindfirst64
572 #define _wfindnexti64 _wfindnext64
573
574 #endif /* _USE_32BIT_TIME_T */
575
576
577 #endif  /* Not RC_INVOKED */
578
579 #endif  /* _IO_H_ not defined */