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.
26 /* Appropriated for Reactos Crtdll by Ariadne */
28 /* changed get_osfhandle and open_osfhandle */
29 /* added fileno as macro */
31 #ifndef __STRICT_ANSI__
36 #include <msvcrt/sys/types.h>
38 #include <msvcrt/sys/stat.h>
41 /* We need the definition of FILE anyway... */
42 #include <msvcrt/stdio.h>
44 /* MSVC's io.h contains the stuff from dir.h, so I will too.
45 * NOTE: This also defines off_t, the file offset type, through
46 * and inclusion of sys/types.h */
47 #include <msvcrt/dir.h>
49 /* TODO: Maximum number of open handles has not been tested, I just set
50 * it the same as FOPEN_MAX. */
51 #define HANDLE_MAX FOPEN_MAX
54 /* Some defines for _access nAccessMode (MS doesn't define them, but
55 * it doesn't seem to hurt to add them). */
56 #define F_OK 0 /* Check for file existence */
57 #define W_OK 2 /* Check for write permission */
58 #define R_OK 4 /* Check for read permission */
59 /* TODO: Is this safe? X_OK not supported directly... */
60 #define X_OK R_OK /* Check for execute permission */
69 int _access (const char*, int);
70 int _chsize (int, long);
74 /* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
75 * the "owner write permission" bit (on FAT). */
76 int _creat (const char*, int);
79 long _filelength (int);
81 void* _get_osfhandle (int);
84 int _chmod (const char* szPath, int nMode);
85 __int64 _filelengthi64(int nHandle);
87 /* In a very odd turn of events this function is excluded from those
88 * files which define _STREAM_COMPAT. This is required in order to
89 * build GNU libio because of a conflict with _eof in streambuf.h
90 * line 107. Actually I might just be able to change the name of
91 * the enum member in streambuf.h... we'll see. TODO */
92 #ifndef _STREAM_COMPAT
96 /* LK_... locking commands defined in sys/locking.h. */
97 int _locking (int, int, long);
99 off_t _lseek(int, off_t, int);
101 /* Optional third argument is unsigned unPermissions. */
102 int _open (const char*, int, ...);
104 int _open_osfhandle (void*, int);
105 int _pipe (int*, unsigned int, int);
106 size_t _read(int, void*, size_t);
108 /* SH_... flags for nShFlags defined in share.h
109 * Optional fourth argument is unsigned unPermissions */
110 int _sopen (char*, int, int, int);
113 /* Should umask be in sys/stat.h and/or sys/types.h instead? */
114 unsigned _umask(unsigned);
115 int _unlink(const char*);
116 size_t _write(int, const void*, size_t);
118 __int64 _lseeki64(int _fildes, __int64 _offset, int _whence);
119 __int64 _telli64(int nHandle);
121 /* Wide character versions. Also declared in wchar.h. */
122 /* Not in crtdll.dll */
123 int _waccess(const wchar_t*, int);
124 int _wchmod(const wchar_t*, int);
125 int _wcreat(const wchar_t*, int);
127 int _wunlink(const wchar_t*);
128 int _wopen(const wchar_t*, int, ...);
129 int _wsopen(wchar_t*, int, int, int);
134 * Non-underscored versions of non-ANSI functions to improve portability.
135 * These functions live in libmoldname.a.
138 #define access _access
140 #define chsize _chsize
146 #define filelength _filelength
147 #define fileno(f) ((f)->_file)
148 #define isatty _isatty
152 #define sopen(path,access,shflag,mode) _open((path), (access)|(shflag), (mode))
153 #define tell(file) _lseek(_file, 0, SEEK_CUR)
155 #define unlink _unlink
159 #endif /* Not _NO_OLDNAMES */
165 #endif /* _IO_H_ not defined */
167 #endif /* Not strict ANSI */