4 * System level I/O functions and types.
6 * This file is part of the Mingw32 package.
9 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
11 * THIS SOFTWARE IS NOT COPYRIGHTED
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 * $Date: 2005/04/17 13:14:29 $
27 #ifndef __STRICT_ANSI__
32 /* All the headers include this file. */
35 /* We need the definition of FILE anyway... */
38 /* MSVC's io.h contains the stuff from dir.h, so I will too.
39 * NOTE: This also defines off_t, the file offset type, through
40 * an inclusion of sys/types.h */
41 #ifndef __STRICT_ANSI__
43 #include <sys/types.h> /* To get time_t. */
46 * Attributes of files as returned by _findfirst et al.
48 #define _A_NORMAL 0x00000000
49 #define _A_RDONLY 0x00000001
50 #define _A_HIDDEN 0x00000002
51 #define _A_SYSTEM 0x00000004
52 #define _A_VOLID 0x00000008
53 #define _A_SUBDIR 0x00000010
54 #define _A_ARCH 0x00000020
59 #ifndef _FSIZE_T_DEFINED
60 typedef unsigned long _fsize_t
;
61 #define _FSIZE_T_DEFINED
65 * The following structure is filled in by _findfirst or _findnext when
66 * they succeed in finding a match.
70 unsigned attrib
; /* Attributes, see constants above. */
72 time_t time_access
; /* always midnight local time */
75 char name
[FILENAME_MAX
]; /* may include spaces. */
78 struct _finddatai64_t
{
84 char name
[FILENAME_MAX
];
88 #ifndef _WFINDDATA_T_DEFINED
91 time_t time_create
; /* -1 for FAT file systems */
92 time_t time_access
; /* -1 for FAT file systems */
95 wchar_t name
[FILENAME_MAX
]; /* may include spaces. */
97 struct _wfinddatai64_t
{
103 wchar_t name
[FILENAME_MAX
];
106 #define _WFINDDATA_T_DEFINED
114 * Functions for searching for files. _findfirst returns -1 if no match
115 * is found. Otherwise it returns a handle to be used in _findnext and
116 * _findclose calls. _findnext also returns -1 if no match could be found,
117 * and 0 if a match was found. Call _findclose when you are finished.
119 int _findfirst (const char*, struct _finddata_t
*);
120 int _findnext (int, struct _finddata_t
*);
121 int _findclose (int);
123 int _chdir (const char*);
124 char* _getcwd (char*, int);
125 int _mkdir (const char*);
126 char* _mktemp (char*);
127 int _rmdir (const char*);
131 __int64
_filelengthi64(int);
132 long _findfirsti64(const char*, struct _finddatai64_t
*);
133 int _findnexti64(long, struct _finddatai64_t
*);
134 __int64
_lseeki64(int, __int64
, int);
135 __int64
_telli64(int);
136 #endif /* __MSVCRT__ */
142 int chdir (const char*);
143 char* getcwd (char*, int);
144 int mkdir (const char*);
145 char* mktemp (char*);
146 int rmdir (const char*);
149 #endif /* Not _NO_OLDNAMES */
155 #endif /* Not RC_INVOKED */
157 #endif /* Not __STRICT_ANSI__ */
159 /* TODO: Maximum number of open handles has not been tested, I just set
160 * it the same as FOPEN_MAX. */
161 #define HANDLE_MAX FOPEN_MAX
164 /* Some defines for _access nAccessMode (MS doesn't define them, but
165 * it doesn't seem to hurt to add them). */
166 #define F_OK 0 /* Check for file existence */
167 #define X_OK 1 /* Check for execute permission. */
168 #define W_OK 2 /* Check for write permission */
169 #define R_OK 4 /* Check for read permission */
177 int _access (const char*, int);
178 int _chsize (int, long);
182 /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
183 * the "owner write permission" bit (on FAT). */
184 int _creat (const char*, unsigned);
187 int _dup2 (int, int);
188 long _filelength (int);
190 long _get_osfhandle (int);
193 /* In a very odd turn of events this function is excluded from those
194 * files which define _STREAM_COMPAT. This is required in order to
195 * build GNU libio because of a conflict with _eof in streambuf.h
196 * line 107. Actually I might just be able to change the name of
197 * the enum member in streambuf.h... we'll see. TODO */
198 #ifndef _STREAM_COMPAT
202 /* LK_... locking commands defined in sys/locking.h. */
203 int _locking (int, int, long);
205 long _lseek (int, long, int);
207 /* Optional third argument is unsigned unPermissions. */
208 int _open (const char*, int, ...);
210 int _open_osfhandle (long, int);
211 int _pipe (int *, unsigned int, int);
212 int _read (int, void*, unsigned int);
214 /* SH_... flags for nShFlags defined in share.h
215 * Optional fourth argument is unsigned unPermissions */
216 int _sopen (const char*, int, int, ...);
219 /* Should umask be in sys/stat.h and/or sys/types.h instead? */
221 int _unlink (const char*);
222 int _write (int, const void*, unsigned int);
224 /* Wide character versions. Also declared in wchar.h. */
225 /* Not in crtdll.dll */
226 #if !defined (_WIO_DEFINED)
227 #if defined (__MSVCRT__)
228 int _waccess(const wchar_t*, int);
229 int _wchmod(const wchar_t*, int);
230 int _wcreat(const wchar_t*, int);
231 long _wfindfirst(wchar_t*, struct _wfinddata_t
*);
232 int _wfindnext(long, struct _wfinddata_t
*);
233 int _wunlink(const wchar_t*);
234 int _wopen(const wchar_t*, int, ...);
235 int _wsopen(const wchar_t*, int, int, ...);
236 wchar_t * _wmktemp(wchar_t*);
237 long _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t
*);
238 int _wfindnexti64(long, struct _wfinddatai64_t
*);
239 #endif /* defined (__MSVCRT__) */
241 #endif /* _WIO_DEFINED */
245 * Non-underscored versions of non-ANSI functions to improve portability.
246 * These functions live in libmoldname.a.
250 int access (const char*, int);
251 int chsize (int, long );
253 int creat (const char*, int);
257 long filelength (int);
260 long lseek (int, long, int);
261 int open (const char*, int, ...);
262 int read (int, void*, unsigned int);
263 int sopen (const char*, int, int, ...);
266 int unlink (const char*);
267 int write (int, const void*, unsigned int);
270 /* Wide character versions. Also declared in wchar.h. */
271 /* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
273 int waccess(const wchar_t *, int);
274 int wchmod(const wchar_t *, int);
275 int wcreat(const wchar_t *, int);
276 long wfindfirst(wchar_t *, struct _wfinddata_t
*);
277 int wfindnext(long, struct _wfinddata_t
*);
278 int wunlink(const wchar_t *);
279 int wrename(const wchar_t *, const wchar_t *);
280 int wopen(const wchar_t *, int, ...);
281 int wsopen(const wchar_t *, int, int, ...);
282 wchar_t * wmktemp(wchar_t *);
285 #endif /* Not _NO_OLDNAMES */
291 #endif /* Not RC_INVOKED */
293 #endif /* _IO_H_ not defined */
295 #endif /* Not strict ANSI */