1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
/*
* io.h
*
* System level I/O functions and types.
*
* This file is part of the Mingw32 package.
*
* Contributors:
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
*
* THIS SOFTWARE IS NOT COPYRIGHTED
*
* This source code is offered for use in the public domain. You may
* use, modify or distribute it freely.
*
* This code is distributed in the hope that it will be useful but
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
* DISCLAIMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* $Revision: 1.2 $
* $Author: bellard $
* $Date: 2005/04/17 13:14:29 $
*
*/
#ifndef __STRICT_ANSI__
#ifndef _IO_H_
#define _IO_H_
/* All the headers include this file. */
#include <_mingw.h>
/* We need the definition of FILE anyway... */
#include <stdio.h>
/* MSVC's io.h contains the stuff from dir.h, so I will too.
* NOTE: This also defines off_t, the file offset type, through
* an inclusion of sys/types.h */
#ifndef __STRICT_ANSI__
#include <sys/types.h> /* To get time_t. */
/*
* Attributes of files as returned by _findfirst et al.
*/
#define _A_NORMAL 0x00000000
#define _A_RDONLY 0x00000001
#define _A_HIDDEN 0x00000002
#define _A_SYSTEM 0x00000004
#define _A_VOLID 0x00000008
#define _A_SUBDIR 0x00000010
#define _A_ARCH 0x00000020
#ifndef RC_INVOKED
#ifndef _FSIZE_T_DEFINED
typedef unsigned long _fsize_t;
#define _FSIZE_T_DEFINED
#endif
/*
* The following structure is filled in by _findfirst or _findnext when
* they succeed in finding a match.
*/
struct _finddata_t
{
unsigned attrib; /* Attributes, see constants above. */
time_t time_create;
time_t time_access; /* always midnight local time */
time_t time_write;
_fsize_t size;
char name[FILENAME_MAX]; /* may include spaces. */
};
struct _finddatai64_t {
unsigned attrib;
time_t time_create;
time_t time_access;
time_t time_write;
__int64 size;
char name[FILENAME_MAX];
};
#ifndef _WFINDDATA_T_DEFINED
struct _wfinddata_t {
unsigned attrib;
time_t time_create; /* -1 for FAT file systems */
time_t time_access; /* -1 for FAT file systems */
time_t time_write;
_fsize_t size;
wchar_t name[FILENAME_MAX]; /* may include spaces. */
};
struct _wfinddatai64_t {
unsigned attrib;
time_t time_create;
time_t time_access;
time_t time_write;
__int64 size;
wchar_t name[FILENAME_MAX];
};
#define _WFINDDATA_T_DEFINED
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Functions for searching for files. _findfirst returns -1 if no match
* is found. Otherwise it returns a handle to be used in _findnext and
* _findclose calls. _findnext also returns -1 if no match could be found,
* and 0 if a match was found. Call _findclose when you are finished.
*/
int _findfirst (const char*, struct _finddata_t*);
int _findnext (int, struct _finddata_t*);
int _findclose (int);
int _chdir (const char*);
char* _getcwd (char*, int);
int _mkdir (const char*);
char* _mktemp (char*);
int _rmdir (const char*);
#ifdef __MSVCRT__
__int64 _filelengthi64(int);
long _findfirsti64(const char*, struct _finddatai64_t*);
int _findnexti64(long, struct _finddatai64_t*);
__int64 _lseeki64(int, __int64, int);
__int64 _telli64(int);
#endif /* __MSVCRT__ */
#ifndef _NO_OLDNAMES
#ifndef _UWIN
int chdir (const char*);
char* getcwd (char*, int);
int mkdir (const char*);
char* mktemp (char*);
int rmdir (const char*);
#endif /* _UWIN */
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* Not __STRICT_ANSI__ */
/* TODO: Maximum number of open handles has not been tested, I just set
* it the same as FOPEN_MAX. */
#define HANDLE_MAX FOPEN_MAX
/* Some defines for _access nAccessMode (MS doesn't define them, but
* it doesn't seem to hurt to add them). */
#define F_OK 0 /* Check for file existence */
#define X_OK 1 /* Check for execute permission. */
#define W_OK 2 /* Check for write permission */
#define R_OK 4 /* Check for read permission */
#ifndef RC_INVOKED
#ifdef __cplusplus
extern "C" {
#endif
int _access (const char*, int);
int _chsize (int, long);
int _close (int);
int _commit(int);
/* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
* the "owner write permission" bit (on FAT). */
int _creat (const char*, unsigned);
int _dup (int);
int _dup2 (int, int);
long _filelength (int);
int _fileno (FILE*);
long _get_osfhandle (int);
int _isatty (int);
/* In a very odd turn of events this function is excluded from those
* files which define _STREAM_COMPAT. This is required in order to
* build GNU libio because of a conflict with _eof in streambuf.h
* line 107. Actually I might just be able to change the name of
* the enum member in streambuf.h... we'll see. TODO */
#ifndef _STREAM_COMPAT
int _eof (int);
#endif
/* LK_... locking commands defined in sys/locking.h. */
int _locking (int, int, long);
long _lseek (int, long, int);
/* Optional third argument is unsigned unPermissions. */
int _open (const char*, int, ...);
int _open_osfhandle (long, int);
int _pipe (int *, unsigned int, int);
int _read (int, void*, unsigned int);
/* SH_... flags for nShFlags defined in share.h
* Optional fourth argument is unsigned unPermissions */
int _sopen (const char*, int, int, ...);
long _tell (int);
/* Should umask be in sys/stat.h and/or sys/types.h instead? */
int _umask (int);
int _unlink (const char*);
int _write (int, const void*, unsigned int);
/* Wide character versions. Also declared in wchar.h. */
/* Not in crtdll.dll */
#if !defined (_WIO_DEFINED)
#if defined (__MSVCRT__)
int _waccess(const wchar_t*, int);
int _wchmod(const wchar_t*, int);
int _wcreat(const wchar_t*, int);
long _wfindfirst(wchar_t*, struct _wfinddata_t*);
int _wfindnext(long, struct _wfinddata_t *);
int _wunlink(const wchar_t*);
int _wopen(const wchar_t*, int, ...);
int _wsopen(const wchar_t*, int, int, ...);
wchar_t * _wmktemp(wchar_t*);
long _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
int _wfindnexti64(long, struct _wfinddatai64_t*);
#endif /* defined (__MSVCRT__) */
#define _WIO_DEFINED
#endif /* _WIO_DEFINED */
#ifndef _NO_OLDNAMES
/*
* Non-underscored versions of non-ANSI functions to improve portability.
* These functions live in libmoldname.a.
*/
#ifndef _UWIN
int access (const char*, int);
int chsize (int, long );
int close (int);
int creat (const char*, int);
int dup (int);
int dup2 (int, int);
int eof (int);
long filelength (int);
int fileno (FILE*);
int isatty (int);
long lseek (int, long, int);
int open (const char*, int, ...);
int read (int, void*, unsigned int);
int sopen (const char*, int, int, ...);
long tell (int);
int umask (int);
int unlink (const char*);
int write (int, const void*, unsigned int);
#endif /* _UWIN */
/* Wide character versions. Also declared in wchar.h. */
/* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
#if 0
int waccess(const wchar_t *, int);
int wchmod(const wchar_t *, int);
int wcreat(const wchar_t *, int);
long wfindfirst(wchar_t *, struct _wfinddata_t *);
int wfindnext(long, struct _wfinddata_t *);
int wunlink(const wchar_t *);
int wrename(const wchar_t *, const wchar_t *);
int wopen(const wchar_t *, int, ...);
int wsopen(const wchar_t *, int, int, ...);
wchar_t * wmktemp(wchar_t *);
#endif
#endif /* Not _NO_OLDNAMES */
#ifdef __cplusplus
}
#endif
#endif /* Not RC_INVOKED */
#endif /* _IO_H_ not defined */
#endif /* Not strict ANSI */
|