STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 
15 
16 
17 
18 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
19 //
20 // Types
21 //
22 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23 #ifdef _USE_32BIT_TIME_T
24  #define _finddata_t _finddata32_t
25  #define _finddatai64_t _finddata32i64_t
26 #else
27  #define _finddata_t _finddata64i32_t
28  #define _finddatai64_t __finddata64_t
29 #endif
30 
32 {
33  unsigned attrib;
34  __time32_t time_create; // -1 for FAT file systems
35  __time32_t time_access; // -1 for FAT file systems
38  char name[260];
39 };
40 
42 {
43  unsigned attrib;
44  __time32_t time_create; // -1 for FAT file systems
45  __time32_t time_access; // -1 for FAT file systems
47  __int64 size;
48  char name[260];
49 };
50 
52 {
53  unsigned attrib;
54  __time64_t time_create; // -1 for FAT file systems
55  __time64_t time_access; // -1 for FAT file systems
58  char name[260];
59 };
60 
62 {
63  unsigned attrib;
64  __time64_t time_create; // -1 for FAT file systems
65  __time64_t time_access; // -1 for FAT file systems
67  __int64 size;
68  char name[260];
69 };
70 
71 
72 
73 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 //
75 // Macros
76 //
77 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 // File attribute constants for the _findfirst() family of functions
79 #define _A_NORMAL 0x00 // Normal file - No read/write restrictions
80 #define _A_RDONLY 0x01 // Read only file
81 #define _A_HIDDEN 0x02 // Hidden file
82 #define _A_SYSTEM 0x04 // System file
83 #define _A_SUBDIR 0x10 // Subdirectory
84 #define _A_ARCH 0x20 // Archive file
85 
86 
87 
88 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
89 //
90 // Functions
91 //
92 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
93 #ifdef _USE_32BIT_TIME_T
94  #define _findfirst _findfirst32
95  #define _findnext _findnext32
96  #define _findfirsti64 _findfirst32i64
97  #define _findnexti64 _findnext32i64
98 #else
99  #define _findfirst _findfirst64i32
100  #define _findnext _findnext64i32
101  #define _findfirsti64 _findfirst64
102  #define _findnexti64 _findnext64
103 #endif
104 
105 #if _CRT_FUNCTIONS_REQUIRED
106 
108  _ACRTIMP int __cdecl _access(
109  _In_z_ char const* _FileName,
110  _In_ int _AccessMode
111  );
112 
114  _ACRTIMP errno_t __cdecl _access_s(
115  _In_z_ char const* _FileName,
116  _In_ int _AccessMode
117  );
118 
120  _ACRTIMP int __cdecl _chmod(
121  _In_z_ char const* _FileName,
122  _In_ int _Mode
123  );
124 
126  _ACRTIMP int __cdecl _chsize(
127  _In_ int _FileHandle,
128  _In_ long _Size
129  );
130 
132  _ACRTIMP errno_t __cdecl _chsize_s(
133  _In_ int _FileHandle,
134  _In_ __int64 _Size
135  );
136 
138  _ACRTIMP int __cdecl _close(
139  _In_ int _FileHandle
140  );
141 
143  _ACRTIMP int __cdecl _commit(
144  _In_ int _FileHandle
145  );
146 
148  _ACRTIMP int __cdecl _creat(
149  _In_z_ char const* _FileName,
151  );
152 
154  _ACRTIMP int __cdecl _dup(
155  _In_ int _FileHandle
156  );
157 
159  _ACRTIMP int __cdecl _dup2(
160  _In_ int _FileHandleSrc,
161  _In_ int _FileHandleDst
162  );
163 
165  _ACRTIMP int __cdecl _eof(
166  _In_ int _FileHandle
167  );
168 
170  _ACRTIMP long __cdecl _filelength(
171  _In_ int _FileHandle
172  );
173 
174  _Success_(return != -1)
176  _ACRTIMP intptr_t __cdecl _findfirst32(
177  _In_z_ char const* _FileName,
179  );
180 
181  _Success_(return != -1)
183  _ACRTIMP int __cdecl _findnext32(
184  _In_ intptr_t _FindHandle,
185  _Out_ struct _finddata32_t* _FindData
186  );
187 
189  _ACRTIMP int __cdecl _findclose(
190  _In_ intptr_t _FindHandle
191  );
192 
193  _ACRTIMP intptr_t __cdecl _get_osfhandle(
194  _In_ int _FileHandle
195  );
196 
198  _ACRTIMP int __cdecl _isatty(
199  _In_ int _FileHandle
200  );
201 
202  _ACRTIMP int __cdecl _locking(
203  _In_ int _FileHandle,
204  _In_ int _LockMode,
205  _In_ long _NumOfBytes
206  );
207 
209  _ACRTIMP long __cdecl _lseek(
210  _In_ int _FileHandle,
211  _In_ long _Offset,
212  _In_ int _Origin
213  );
214 
215  _Success_(return == 0)
217  _ACRTIMP errno_t __cdecl _mktemp_s(
218  _Inout_updates_z_(_Size) char* _TemplateName,
219  _In_ size_t _Size
220  );
221 
223  errno_t, _mktemp_s,
224  _Prepost_z_ char, _TemplateName
225  )
226 
227  _Success_(return != 0)
229  char *, __RETURN_POLICY_DST, _ACRTIMP, _mktemp,
230  _Inout_z_, char, _TemplateName
231  )
232 
233  _ACRTIMP int __cdecl _open_osfhandle(
234  _In_ intptr_t _OSFileHandle,
235  _In_ int _Flags
236  );
237 
238  #ifdef _CRT_USE_WINAPI_FAMILY_DESKTOP_APP
239  _Success_(return != -1)
241  _DCRTIMP int __cdecl _pipe(
242  _Out_writes_(2) int* _PtHandles,
243  _In_ unsigned int _PipeSize,
244  _In_ int _TextMode
245  );
246  #endif
247 
248  _Success_(return != -1)
250  _ACRTIMP int __cdecl _read(
251  _In_ int _FileHandle,
252  _Out_writes_bytes_(_MaxCharCount) void* _DstBuf,
253  _In_ unsigned int _MaxCharCount
254  );
255 
256  _ACRTIMP int __cdecl remove(
257  _In_z_ char const* _FileName
258  );
259 
261  _ACRTIMP int __cdecl rename(
262  _In_z_ char const* _OldFilename,
263  _In_z_ char const* _NewFilename
264  );
265 
266  _ACRTIMP int __cdecl _unlink(
267  _In_z_ char const* _FileName
268  );
269 
271  _ACRTIMP int __cdecl _setmode(
272  _In_ int _FileHandle,
273  _In_ int _Mode
274  );
275 
277  _ACRTIMP long __cdecl _tell(
278  _In_ int _FileHandle
279  );
280 
281  _CRT_INSECURE_DEPRECATE(_umask_s)
282  _ACRTIMP int __cdecl _umask(
283  _In_ int _Mode
284  );
285 
287  _ACRTIMP errno_t __cdecl _umask_s(
288  _In_ int _NewMode,
289  _Out_ int* _OldMode
290  );
291 
292  _ACRTIMP int __cdecl _write(
293  _In_ int _FileHandle,
294  _In_reads_bytes_(_MaxCharCount) void const* _Buf,
295  _In_ unsigned int _MaxCharCount
296  );
297 
299  _ACRTIMP __int64 __cdecl _filelengthi64(
300  _In_ int _FileHandle
301  );
302 
303  _Success_(return != -1)
305  _ACRTIMP intptr_t __cdecl _findfirst32i64(
306  _In_z_ char const* _FileName,
307  _Out_ struct _finddata32i64_t* _FindData
308  );
309 
310  _Success_(return != -1)
312  _ACRTIMP intptr_t __cdecl _findfirst64i32(
313  _In_z_ char const* _FileName,
314  _Out_ struct _finddata64i32_t* _FindData
315  );
316 
317  _Success_(return != -1)
319  _ACRTIMP intptr_t __cdecl _findfirst64(
320  _In_z_ char const* _FileName,
321  _Out_ struct __finddata64_t* _FindData
322  );
323 
324  _Success_(return != -1)
326  _ACRTIMP int __cdecl _findnext32i64(
327  _In_ intptr_t _FindHandle,
328  _Out_ struct _finddata32i64_t* _FindData
329  );
330 
331  _Success_(return != -1)
333  _ACRTIMP int __cdecl _findnext64i32(
334  _In_ intptr_t _FindHandle,
335  _Out_ struct _finddata64i32_t* _FindData
336  );
337 
338  _Success_(return != -1)
340  _ACRTIMP int __cdecl _findnext64(
341  _In_ intptr_t _FindHandle,
342  _Out_ struct __finddata64_t* _FindData
343  );
344 
346  _ACRTIMP __int64 __cdecl _lseeki64(
347  _In_ int _FileHandle,
348  _In_ __int64 _Offset,
349  _In_ int _Origin
350  );
351 
353  _ACRTIMP __int64 __cdecl _telli64(
354  _In_ int _FileHandle
355  );
356 
358  _ACRTIMP errno_t __cdecl _sopen_s(
359  _Out_ int* _FileHandle,
360  _In_z_ char const* _FileName,
361  _In_ int _OpenFlag,
362  _In_ int _ShareFlag,
363  _In_ int _PermissionMode
364  );
365 
367  _ACRTIMP errno_t __cdecl _sopen_s_nolock(
368  _Out_ int* _FileHandle,
369  _In_z_ char const* _FileName,
370  _In_ int _OpenFlag,
371  _In_ int _ShareFlag,
372  _In_ int _PermissionMode
373  );
374 
375  _ACRTIMP errno_t __cdecl _sopen_dispatch(
376  _In_z_ char const* _FileName,
377  _In_ int _OFlag,
378  _In_ int _ShFlag,
379  _In_ int _PMode,
380  _Out_ int* _PFileHandle,
381  _In_ int _BSecure
382  );
383 
384 
385 
386  #ifdef __cplusplus
387 
388  // These function do not validate pmode; use _sopen_s instead.
389  extern "C++" _Check_return_ _CRT_INSECURE_DEPRECATE(_sopen_s)
390  inline int __CRTDECL _open(
391  _In_z_ char const* const _FileName,
392  _In_ int const _OFlag,
393  _In_ int const _PMode = 0
394  )
395  {
396  int _FileHandle;
397  // Last parameter passed as 0 because we don't want to validate pmode from _open
398  errno_t const _Result = _sopen_dispatch(_FileName, _OFlag, _SH_DENYNO, _PMode, &_FileHandle, 0);
399  return _Result ? -1 : _FileHandle;
400  }
401 
402  extern "C++" _Check_return_ _CRT_INSECURE_DEPRECATE(_sopen_s)
403  inline int __CRTDECL _sopen(
404  _In_z_ char const* const _FileName,
405  _In_ int const _OFlag,
406  _In_ int const _ShFlag,
407  _In_ int const _PMode = 0
408  )
409  {
410  int _FileHandle;
411  // Last parameter passed as 0 because we don't want to validate pmode from _sopen
412  errno_t const _Result = _sopen_dispatch(_FileName, _OFlag, _ShFlag, _PMode, &_FileHandle, 0);
413  return _Result ? -1 : _FileHandle;
414  }
415 
416  #else
417 
419  _ACRTIMP int __cdecl _open(
420  _In_z_ char const* _FileName,
421  _In_ int _OpenFlag,
422  ...);
423 
425  _ACRTIMP int __cdecl _sopen(
426  _In_z_ char const* _FileName,
427  _In_ int _OpenFlag,
428  _In_ int _ShareFlag,
429  ...);
430 
431  #endif
432 
433 
434 
435  #if _CRT_INTERNAL_NONSTDC_NAMES
436  // Suppress warnings about double deprecation
437  #pragma warning(push)
438  #pragma warning(disable: 4141)
439 
441  _ACRTIMP int __cdecl access(
442  _In_z_ char const* _FileName,
443  _In_ int _AccessMode
444  );
445 
447  _ACRTIMP int __cdecl chmod(
448  _In_z_ char const* _FileName,
449  _In_ int _AccessMode
450  );
451 
453  _ACRTIMP int __cdecl chsize(
454  _In_ int _FileHandle,
455  _In_ long _Size
456  );
457 
459  _ACRTIMP int __cdecl close(
460  _In_ int _FileHandle
461  );
462 
464  _ACRTIMP int __cdecl creat(
465  _In_z_ char const* _FileName,
466  _In_ int _PermissionMode
467  );
468 
470  _ACRTIMP int __cdecl dup(
471  _In_ int _FileHandle
472  );
473 
475  _ACRTIMP int __cdecl dup2(
476  _In_ int _FileHandleSrc,
477  _In_ int _FileHandleDst
478  );
479 
481  _ACRTIMP int __cdecl eof(
482  _In_ int _FileHandle
483  );
484 
486  _ACRTIMP long __cdecl filelength(
487  _In_ int _FileHandle
488  );
489 
491  _ACRTIMP int __cdecl isatty(
492  _In_ int _FileHandle
493  );
494 
496  _ACRTIMP int __cdecl locking(
497  _In_ int _FileHandle,
498  _In_ int _LockMode,
499  _In_ long _NumOfBytes
500  );
501 
503  _ACRTIMP long __cdecl lseek(
504  _In_ int _FileHandle,
505  _In_ long _Offset,
506  _In_ int _Origin
507  );
508 
509  _Success_(return != 0)
511  _ACRTIMP char * __cdecl mktemp(
512  _Inout_z_ char* _TemplateName
513  );
514 
516  _ACRTIMP int __cdecl open(
517  _In_z_ char const* _FileName,
518  _In_ int _OpenFlag,
519  ...);
520 
521  _Success_(return != -1)
523  _ACRTIMP int __cdecl read(
524  _In_ int _FileHandle,
525  _Out_writes_bytes_(_MaxCharCount) void* _DstBuf,
526  _In_ unsigned int _MaxCharCount
527  );
528 
530  _ACRTIMP int __cdecl setmode(
531  _In_ int _FileHandle,
532  _In_ int _Mode
533  );
534 
536  _ACRTIMP int __cdecl sopen(
537  _In_ char const* _FileName,
538  _In_ int _OpenFlag,
539  _In_ int _ShareFlag,
540  ...);
541 
543  _ACRTIMP long __cdecl tell(
544  _In_ int _FileHandle
545  );
546 
548  _ACRTIMP int __cdecl umask(
549  _In_ int _Mode
550  );
551 
553  _ACRTIMP int __cdecl unlink(
554  _In_z_ char const* _FileName
555  );
556 
558  _ACRTIMP int __cdecl write(
559  _In_ int _FileHandle,
560  _In_reads_bytes_(_MaxCharCount) void const* _Buf,
561  _In_ unsigned int _MaxCharCount
562  );
563 
564  #pragma warning(pop)
565  #endif // _CRT_INTERNAL_NONSTDC_NAMES
566 #endif // _CRT_FUNCTIONS_REQUIRED
567 
_ACRTIMP int __cdecl _unlink(_In_z_ char const *_FileName)
#define _Out_
Definition: sal.h:342
return
Definition: corecrt_memcpy_s.h:60
char name[260]
Definition: corecrt_io.h:58
_ACRTIMP int __cdecl unlink(_In_z_ char const *_FileName)
_Out_ struct _wfinddata32_t * _FindData
Definition: corecrt_wio.h:123
#define __RETURN_POLICY_DST(_FunctionCall)
Definition: corecrt.h:1783
#define _ACRTIMP
Definition: corecrt.h:27
__time64_t time_write
Definition: corecrt_io.h:66
__time32_t time_create
Definition: corecrt_io.h:44
__time64_t time_create
Definition: corecrt_io.h:64
#define _Out_writes_bytes_(size)
Definition: sal.h:347
#define _CRT_INSECURE_DEPRECATE(_Replacement)
Definition: vcruntime.h:269
#define _Check_return_opt_
Definition: corecrt.h:96
_fsize_t size
Definition: corecrt_io.h:57
_FwdIt remove(_FwdIt _First, _FwdIt _Last, const _Ty &_Val)
Definition: algorithm:1395
Definition: regex:1559
unsigned attrib
Definition: corecrt_io.h:63
Definition: corecrt_io.h:61
char name[260]
Definition: corecrt_io.h:68
int errno_t
Definition: corecrt.h:476
_In_ int _Pre_notnull_ _Post_z_ char * _DstBuf
Definition: stdlib.h:1329
char name[260]
Definition: corecrt_io.h:48
#define _Check_return_wat_
Definition: corecrt.h:102
unsigned attrib
Definition: corecrt_io.h:53
#define _In_reads_bytes_(size)
Definition: sal.h:318
_CRT_BEGIN_C_HEADER _Check_return_ _Ret_maybenull_ _In_ size_t _Size
Definition: corecrt_malloc.h:58
unsigned long _fsize_t
Definition: corecrt_wio.h:34
#define _CRT_BEGIN_C_HEADER
Definition: vcruntime.h:73
_fsize_t size
Definition: corecrt_io.h:37
__time32_t time_write
Definition: corecrt_io.h:36
#define _Inout_updates_z_(size)
Definition: sal.h:386
__time64_t time_access
Definition: corecrt_io.h:55
#define __CRTDECL
Definition: vcruntime.h:156
#define _Check_return_
Definition: sal.h:554
char name[260]
Definition: corecrt_io.h:38
#define _In_z_
Definition: sal.h:310
#define _In_
Definition: sal.h:305
long __time32_t
Definition: corecrt.h:479
unsigned attrib
Definition: corecrt_io.h:33
__time64_t time_create
Definition: corecrt_io.h:54
#define _DCRTIMP
Definition: corecrt.h:43
#define _Inout_z_
Definition: sal.h:380
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
_Check_return_ _In_ int _PermissionMode
Definition: corecrt_wio.h:117
Definition: corecrt_io.h:41
_Check_return_ _ACRTIMP int __cdecl rename(_In_z_ char const *_OldFileName, _In_z_ char const *_NewFileName)
unsigned attrib
Definition: corecrt_io.h:43
#define _CRT_NONSTDC_DEPRECATE(_NewName)
Definition: corecrt.h:300
int intptr_t
Definition: vcruntime.h:200
#define __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(_ReturnType, _FuncName, _DstType, _Dst)
Definition: corecrt.h:691
#define _Prepost_z_
Definition: sal.h:705
_In_opt_z_ wchar_t const _In_opt_z_ wchar_t const * _FileName
Definition: corecrt.h:253
#define _CRT_END_C_HEADER
Definition: vcruntime.h:76
__time32_t time_write
Definition: corecrt_io.h:46
_In_ long _In_ int _Origin
Definition: stdio.h:266
__time64_t time_access
Definition: corecrt_io.h:65
#define _Out_writes_(size)
Definition: sal.h:345
__int64 __time64_t
Definition: corecrt.h:480
#define __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(_ReturnType, _ReturnPolicy, _DeclSpec, _FuncName, _SalAttributeDst, _DstType, _Dst)
Definition: corecrt.h:709
__time32_t time_access
Definition: corecrt_io.h:45
__time64_t time_write
Definition: corecrt_io.h:56
_Check_return_ _In_ int _Check_return_ _In_ int _In_ int _ShareFlag
Definition: corecrt_wio.h:263
__int64 size
Definition: corecrt_io.h:47
__int64 size
Definition: corecrt_io.h:67
Definition: corecrt_io.h:31
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Offset
Definition: corecrt_malloc.h:159
__time32_t time_access
Definition: corecrt_io.h:35
#define _SH_DENYNO
Definition: corecrt_share.h:16
#define _Success_(expr)
Definition: sal.h:256
Definition: corecrt_io.h:51
_Result
Definition: corecrt_wconio.h:362
__time32_t time_create
Definition: corecrt_io.h:34
_Check_return_ _In_ int _OpenFlag
Definition: corecrt_wio.h:257