ReactOS 0.4.16-dev-1028-g8602629
corecrt_io.h
Go to the documentation of this file.
1//
2// corecrt_io.h
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// This file declares the low-level I/O and file handling functionality. These
7// declarations are split out to support the Windows build.
8//
9#pragma once
10
11#include <corecrt_share.h>
12#include <corecrt_wio.h>
13
14#pragma warning(push)
15#pragma warning(disable: _UCRT_DISABLED_WARNINGS)
17
19
20
21
22//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23//
24// Types
25//
26//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27#ifdef _USE_32BIT_TIME_T
28 #define _finddata_t _finddata32_t
29 #define _finddatai64_t _finddata32i64_t
30#else
31 #define _finddata_t _finddata64i32_t
32 #define _finddatai64_t __finddata64_t
33#endif
34
35struct _finddata32_t
36{
37 unsigned attrib;
38 __time32_t time_create; // -1 for FAT file systems
39 __time32_t time_access; // -1 for FAT file systems
42 char name[260];
43};
44
46{
47 unsigned attrib;
48 __time32_t time_create; // -1 for FAT file systems
49 __time32_t time_access; // -1 for FAT file systems
52 char name[260];
53};
54
56{
57 unsigned attrib;
58 __time64_t time_create; // -1 for FAT file systems
59 __time64_t time_access; // -1 for FAT file systems
62 char name[260];
63};
64
66{
67 unsigned attrib;
68 __time64_t time_create; // -1 for FAT file systems
69 __time64_t time_access; // -1 for FAT file systems
72 char name[260];
73};
74
75//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76//
77// Macros
78//
79//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80// File attribute constants for the _findfirst() family of functions
81#define _A_NORMAL 0x00 // Normal file - No read/write restrictions
82#define _A_RDONLY 0x01 // Read only file
83#define _A_HIDDEN 0x02 // Hidden file
84#define _A_SYSTEM 0x04 // System file
85#define _A_SUBDIR 0x10 // Subdirectory
86#define _A_ARCH 0x20 // Archive file
87
88
89
90//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91//
92// Functions
93//
94//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95#ifdef _USE_32BIT_TIME_T
96 #define _findfirst _findfirst32
97 #define _findnext _findnext32
98 #define _findfirsti64 _findfirst32i64
99 #define _findnexti64 _findnext32i64
100#else
101 #define _findfirst _findfirst64i32
102 #define _findnext _findnext64i32
103 #define _findfirsti64 _findfirst64
104 #define _findnexti64 _findnext64
105#endif
106
107#if _CRT_FUNCTIONS_REQUIRED
108
111 _In_z_ char const* _FileName,
112 _In_ int _AccessMode
113 );
114
117 _In_z_ char const* _FileName,
118 _In_ int _AccessMode
119 );
120
123 _In_z_ char const* _FileName,
124 _In_ int _Mode
125 );
126
129 _In_ int _FileHandle,
130 _In_ long _Size
131 );
132
135 _In_ int _FileHandle,
137 );
138
141 _In_ int _FileHandle
142 );
143
146 _In_ int _FileHandle
147 );
148
151 _In_z_ char const* _FileName,
153 );
154
157 _In_ int _FileHandle
158 );
159
162 _In_ int _FileHandleSrc,
163 _In_ int _FileHandleDst
164 );
165
168 _In_ int _FileHandle
169 );
170
173 _In_ int _FileHandle
174 );
175
176 _Success_(return != -1)
179 _In_z_ char const* _FileName,
181 );
182
183 _Success_(return != -1)
186 _In_ intptr_t _FindHandle,
188 );
189
192 _In_ intptr_t _FindHandle
193 );
194
196 _In_ int _FileHandle
197 );
198
201 _In_ int _FileHandle
202 );
203
205 _In_ int _FileHandle,
206 _In_ int _LockMode,
207 _In_ long _NumOfBytes
208 );
209
212 _In_ int _FileHandle,
213 _In_ long _Offset,
214 _In_ int _Origin
215 );
216
217 _Success_(return == 0)
220 _Inout_updates_z_(_Size) char* _TemplateName,
221 _In_ size_t _Size
222 );
223
226 _Prepost_z_ char, _TemplateName
227 )
228
229 _Success_(return != 0)
232 _Inout_z_, char, _TemplateName
233 )
234
236 _In_ intptr_t _OSFileHandle,
237 _In_ int _Flags
238 );
239
240 #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
241 _Success_(return != -1)
244 _Out_writes_(2) int* _PtHandles,
245 _In_ unsigned int _PipeSize,
246 _In_ int _TextMode
247 );
248 #endif
249
250 _Success_(return != -1)
253 _In_ int _FileHandle,
254 _Out_writes_bytes_(_MaxCharCount) void* _DstBuf,
255 _In_ unsigned int _MaxCharCount
256 );
257
260 );
261
264 _In_z_ char const* _OldFilename,
265 _In_z_ char const* _NewFilename
266 );
267
270 );
271
274 _In_ int _FileHandle,
275 _In_ int _Mode
276 );
277
280 _In_ int _FileHandle
281 );
282
285 _In_ int _Mode
286 );
287
290 _In_ int _NewMode,
291 _Out_ int* _OldMode
292 );
293
295 _In_ int _FileHandle,
297 _In_ unsigned int _MaxCharCount
298 );
299
302 _In_ int _FileHandle
303 );
304
305 _Success_(return != -1)
308 _In_z_ char const* _FileName,
310 );
311
312 _Success_(return != -1)
315 _In_z_ char const* _FileName,
317 );
318
319 _Success_(return != -1)
322 _In_z_ char const* _FileName,
324 );
325
326 _Success_(return != -1)
329 _In_ intptr_t _FindHandle,
331 );
332
333 _Success_(return != -1)
336 _In_ intptr_t _FindHandle,
338 );
339
340 _Success_(return != -1)
343 _In_ intptr_t _FindHandle,
345 );
346
349 _In_ int _FileHandle,
351 _In_ int _Origin
352 );
353
356 _In_ int _FileHandle
357 );
358
361 _Out_ int* _FileHandle,
362 _In_z_ char const* _FileName,
363 _In_ int _OpenFlag,
364 _In_ int _ShareFlag,
366 );
367
369 _ACRTIMP errno_t __cdecl _sopen_s_nolock(
370 _Out_ int* _FileHandle,
371 _In_z_ char const* _FileName,
372 _In_ int _OpenFlag,
373 _In_ int _ShareFlag,
375 );
376
378 _In_z_ char const* _FileName,
379 _In_ int _OFlag,
380 _In_ int _ShFlag,
381 _In_ int _PMode,
382 _Out_ int* _PFileHandle,
383 _In_ int _BSecure
384 );
385
386
387
388 #ifdef __cplusplus
389
390 // These function do not validate pmode; use _sopen_s instead.
392 inline int __CRTDECL _open(
393 _In_z_ char const* const _FileName,
394 _In_ int const _OFlag,
395 _In_ int const _PMode = 0
396 )
397 {
398 int _FileHandle;
399 // Last parameter passed as 0 because we don't want to validate pmode from _open
400 errno_t const _Result = _sopen_dispatch(_FileName, _OFlag, _SH_DENYNO, _PMode, &_FileHandle, 0);
401 return _Result ? -1 : _FileHandle;
402 }
403
405 inline int __CRTDECL _sopen(
406 _In_z_ char const* const _FileName,
407 _In_ int const _OFlag,
408 _In_ int const _ShFlag,
409 _In_ int const _PMode = 0
410 )
411 {
412 int _FileHandle;
413 // Last parameter passed as 0 because we don't want to validate pmode from _sopen
414 errno_t const _Result = _sopen_dispatch(_FileName, _OFlag, _ShFlag, _PMode, &_FileHandle, 0);
415 return _Result ? -1 : _FileHandle;
416 }
417
418 #else
419
422 _In_z_ char const* _FileName,
423 _In_ int _OpenFlag,
424 ...);
425
428 _In_z_ char const* _FileName,
429 _In_ int _OpenFlag,
430 _In_ int _ShareFlag,
431 ...);
432
433 #endif
434
435
436
437 #if defined(_CRT_INTERNAL_NONSTDC_NAMES) && _CRT_INTERNAL_NONSTDC_NAMES
438 // Suppress warnings about double deprecation
439 #pragma warning(push)
440 #pragma warning(disable: 4141)
441
444 _In_z_ char const* _FileName,
445 _In_ int _AccessMode
446 );
447
450 _In_z_ char const* _FileName,
451 _In_ int _AccessMode
452 );
453
456 _In_ int _FileHandle,
457 _In_ long _Size
458 );
459
462 _In_ int _FileHandle
463 );
464
467 _In_z_ char const* _FileName,
469 );
470
472 _ACRTIMP int __cdecl dup(
473 _In_ int _FileHandle
474 );
475
478 _In_ int _FileHandleSrc,
479 _In_ int _FileHandleDst
480 );
481
483 _ACRTIMP int __cdecl eof(
484 _In_ int _FileHandle
485 );
486
489 _In_ int _FileHandle
490 );
491
494 _In_ int _FileHandle
495 );
496
499 _In_ int _FileHandle,
500 _In_ int _LockMode,
501 _In_ long _NumOfBytes
502 );
503
506 _In_ int _FileHandle,
507 _In_ long _Offset,
508 _In_ int _Origin
509 );
510
511 _Success_(return != 0)
513 _ACRTIMP char * __cdecl mktemp(
514 _Inout_z_ char* _TemplateName
515 );
516
519 _In_z_ char const* _FileName,
520 _In_ int _OpenFlag,
521 ...);
522
523 _Success_(return != -1)
526 _In_ int _FileHandle,
527 _Out_writes_bytes_(_MaxCharCount) void* _DstBuf,
528 _In_ unsigned int _MaxCharCount
529 );
530
533 _In_ int _FileHandle,
534 _In_ int _Mode
535 );
536
539 _In_ char const* _FileName,
540 _In_ int _OpenFlag,
541 _In_ int _ShareFlag,
542 ...);
543
545 _ACRTIMP long __cdecl tell(
546 _In_ int _FileHandle
547 );
548
551 _In_ int _Mode
552 );
553
557 );
558
561 _In_ int _FileHandle,
563 _In_ unsigned int _MaxCharCount
564 );
565
566 #pragma warning(pop)
567 #endif // _CRT_INTERNAL_NONSTDC_NAMES
568#endif // _CRT_FUNCTIONS_REQUIRED
569
572#pragma warning(pop) // _UCRT_DISABLED_WARNINGS
#define __cdecl
Definition: accygwin.h:79
#define read
Definition: acwin.h:96
#define open
Definition: acwin.h:95
#define close
Definition: acwin.h:98
#define write
Definition: acwin.h:97
#define isatty
Definition: acwin.h:103
#define __int64
Definition: basetyps.h:16
#define _setmode(fd, mode)
Definition: cat.c:21
return
Definition: dirsup.c:529
_Out_ int * _FileHandle
_Check_return_ _In_ unsigned int _MaxCharCount
_Out_ struct _wfinddata32_t * _FindData
Definition: corecrt_wio.h:122
_Check_return_ _In_ int _PermissionMode
Definition: corecrt_wio.h:116
_Check_return_ _In_ int _OpenFlag
Definition: corecrt_wio.h:256
_Check_return_ _In_ int _Check_return_ _In_ int _In_ int _ShareFlag
Definition: corecrt_wio.h:263
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(_ReturnType, _FuncName, _DstType, _Dst)
Definition: corecrt.h:176
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Size
Definition: malloc.h:109
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Offset
Definition: malloc.h:140
#define _SH_DENYNO
Definition: share.h:17
_Result
Definition: printf.c:27
int __cdecl _findnext64i32(intptr_t const handle, _finddata64i32_t *const result)
Definition: findfile.cpp:342
intptr_t __cdecl _findfirst64i32(char const *const pattern, _finddata64i32_t *const result)
Definition: findfile.cpp:210
int __cdecl _findnext32i64(intptr_t const handle, _finddata32i64_t *const result)
Definition: findfile.cpp:336
intptr_t __cdecl _findfirst32i64(char const *const pattern, _finddata32i64_t *const result)
Definition: findfile.cpp:204
intptr_t __cdecl _findfirst64(char const *const pattern, __finddata64_t *const result)
Definition: findfile.cpp:216
int __cdecl _findnext64(intptr_t const handle, __finddata64_t *const result)
Definition: findfile.cpp:348
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define lseek
Definition: syshdrs.h:47
#define unlink
Definition: syshdrs.h:54
#define dup
Definition: syshdrs.h:51
errno_t __cdecl _mktemp_s(char *const template_string, size_t const buffer_size_in_chars)
Definition: mktemp.cpp:119
int remove
Definition: msacm.c:1366
#define _Prepost_z_
Definition: no_sal2.h:510
#define _In_reads_bytes_(s)
Definition: no_sal2.h:170
#define _Success_(c)
Definition: no_sal2.h:84
#define _In_z_
Definition: no_sal2.h:164
#define _Check_return_
Definition: no_sal2.h:60
#define _Inout_updates_z_(s)
Definition: no_sal2.h:186
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
#define _Inout_z_
Definition: no_sal2.h:166
errno_t __cdecl _sopen_dispatch(char const *const path, int const oflag, int const shflag, int const pmode, int *const pfh, int const secure)
Definition: open.cpp:196
_CRTIMP intptr_t __cdecl _get_osfhandle(_In_ int _FileHandle)
_CRTIMP int __cdecl _umask(_In_ int _Mode)
_Check_return_ _CRTIMP int __cdecl _access(_In_z_ const char *_Filename, _In_ int _AccessMode)
_Check_return_opt_ _CRTIMP int __cdecl _close(_In_ int _FileHandle)
_Check_return_opt_ _CRTIMP long __cdecl _lseek(_In_ int _FileHandle, _In_ long _Offset, _In_ int _Origin)
_Check_return_ _CRTIMP long __cdecl _filelength(_In_ int _FileHandle)
_CRTIMP int __cdecl _locking(_In_ int _FileHandle, _In_ int _LockMode, _In_ long _NumOfBytes)
unsigned long _fsize_t
Definition: io.h:31
_Check_return_ _CRTIMP int __cdecl _chmod(_In_z_ const char *_Filename, _In_ int _Mode)
_CRTIMP int __cdecl _sopen(const char *_Filename, int _OpenFlag, int _ShareFlag,...)
Definition: file.c:1978
_CRTIMP int __cdecl _write(_In_ int _FileHandle, _In_reads_bytes_(_MaxCharCount) const void *_Buf, _In_ unsigned int _MaxCharCount)
_Check_return_ _CRTIMP int __cdecl _pipe(_Inout_updates_(2) int *_PtHandles, _In_ unsigned int _PipeSize, _In_ int _TextMode)
_Check_return_ _CRTIMP long __cdecl _tell(_In_ int _FileHandle)
_Check_return_ _CRTIMP char *__cdecl _mktemp(_Inout_z_ char *_TemplateName)
_Check_return_ _CRTIMP long __cdecl filelength(_In_ int _FileHandle)
_Check_return_ _CRTIMP int __cdecl _findnext32(_In_ intptr_t _FindHandle, _Out_ struct _finddata32_t *_FindData)
_Check_return_ _CRTIMP int __cdecl _isatty(_In_ int _FileHandle)
_Check_return_ _CRTIMP int __cdecl _creat(_In_z_ const char *_Filename, _In_ int _PermissionMode)
_Check_return_ _CRTIMP intptr_t __cdecl _findfirst32(_In_z_ const char *_Filename, _Out_ struct _finddata32_t *_FindData)
_Check_return_ _CRTIMP int __cdecl _read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
_Check_return_ _CRTIMP int __cdecl _dup2(_In_ int _FileHandleSrc, _In_ int _FileHandleDst)
_Check_return_ _CRTIMP int __cdecl _unlink(_In_z_ const char *_Filename)
_CRTIMP char *__cdecl mktemp(_Inout_z_ char *_TemplateName)
_CRTIMP int __cdecl sopen(const char *_Filename, int _OpenFlag, int _ShareFlag,...)
_CRTIMP int __cdecl _open(const char *_Filename, int _OpenFlag,...)
Definition: file.c:2001
_CRTIMP int __cdecl umask(_In_ int _Mode)
_Check_return_ _CRTIMP int __cdecl chsize(_In_ int _FileHandle, _In_ long _Size)
_Check_return_ _CRTIMP int __cdecl _chsize(_In_ int _FileHandle, _In_ long _Size)
_Check_return_ int __cdecl rename(_In_z_ const char *_OldFilename, _In_z_ const char *_NewFilename)
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
_Check_return_ _CRTIMP int __cdecl _dup(_In_ int _FileHandle)
_Check_return_ _CRTIMP int __cdecl creat(_In_z_ const char *_Filename, _In_ int _PermissionMode)
_Check_return_ _CRTIMP int __cdecl chmod(_In_z_ const char *_Filename, _In_ int _AccessMode)
_Check_return_opt_ _CRTIMP int __cdecl _commit(_In_ int _FileHandle)
_Check_return_opt_ _CRTIMP int __cdecl _findclose(_In_ intptr_t _FindHandle)
_Check_return_wat_ _CRTIMP errno_t __cdecl _sopen_s(_Out_ int *_FileHandle, _In_z_ const char *_Filename, _In_ int _OpenFlag, _In_ int _ShareFlag, _In_ int _PermissionMode)
_Check_return_ _CRTIMP int __cdecl _eof(_In_ int _FileHandle)
_Check_return_ _CRTIMP int __cdecl locking(_In_ int _FileHandle, _In_ int _LockMode, _In_ long _NumOfBytes)
_Check_return_ _CRTIMP int __cdecl dup2(_In_ int _FileHandleSrc, _In_ int _FileHandleDst)
_CRTIMP int __cdecl _open_osfhandle(_In_ intptr_t _OSFileHandle, _In_ int _Flags)
long __time32_t
Definition: time.h:24
#define tell(s)
Definition: getopt.c:28
int CDECL _access_s(const char *filename, int mode)
Definition: file.c:712
__int64 CDECL _lseeki64(int fd, __int64 offset, int whence)
Definition: file.c:1138
int CDECL _chsize_s(int fd, __int64 size)
Definition: file.c:1318
__int64 CDECL _telli64(int fd)
Definition: file.c:2527
__int64 CDECL _filelengthi64(int fd)
Definition: file.c:1563
#define setmode(f, m)
Definition: io.h:42
__int64 size
Definition: corecrt_io.h:71
__time64_t time_write
Definition: corecrt_io.h:70
__time64_t time_access
Definition: corecrt_io.h:69
__time64_t time_create
Definition: corecrt_io.h:68
unsigned attrib
Definition: corecrt_io.h:67
unsigned attrib
Definition: io.h:47
__time32_t time_access
Definition: io.h:49
__time32_t time_write
Definition: io.h:50
__time32_t time_create
Definition: io.h:48
_fsize_t size
Definition: io.h:51
__time32_t time_create
Definition: corecrt_io.h:48
__time32_t time_access
Definition: corecrt_io.h:49
unsigned attrib
Definition: corecrt_io.h:47
__time32_t time_write
Definition: corecrt_io.h:50
__time64_t time_create
Definition: corecrt_io.h:58
__time64_t time_write
Definition: corecrt_io.h:60
unsigned attrib
Definition: corecrt_io.h:57
_fsize_t size
Definition: corecrt_io.h:61
__time64_t time_access
Definition: corecrt_io.h:59
Definition: name.c:39
int errno_t
Definition: corecrt.h:615
#define _Check_return_opt_
Definition: corecrt.h:224
#define _DCRTIMP
Definition: corecrt.h:154
#define _CRT_NONSTDC_DEPRECATE(_NewName)
Definition: corecrt.h:439
__int64 __time64_t
Definition: corecrt.h:619
#define __RETURN_POLICY_DST(_FunctionCall)
Definition: corecrt.h:1892
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SalAttributeDst, _DstType, _Dst)
Definition: corecrt.h:842
#define _ACRTIMP
Definition: corecrt.h:138
#define _UCRT_DISABLE_CLANG_WARNINGS
Definition: corecrt.h:109
#define _UCRT_RESTORE_CLANG_WARNINGS
Definition: corecrt.h:117
#define _Check_return_wat_
Definition: corecrt.h:230
errno_t __cdecl _umask_s(int const mode, int *const old_mode)
Definition: umask.cpp:26
int intptr_t
Definition: vcruntime.h:134
#define _CRT_END_C_HEADER
Definition: vcruntime.h:42
#define _CRT_BEGIN_C_HEADER
Definition: vcruntime.h:40
#define _CRT_INSECURE_DEPRECATE(_Replacement)
Definition: vcruntime.h:99
#define __CRTDECL
Definition: yvals.h:17
#define const
Definition: zconf.h:233