xref: /reactos/sdk/include/ucrt/corecrt_wio.h (revision 04e0dc4a)
1 //
2 // corecrt_wio.h
3 //
4 //      Copyright (c) Microsoft Corporation. All rights reserved.
5 //
6 // This file declares the wide character (wchar_t) I/O functionality, shared by
7 // <io.h> and <wchar.h>.
8 //
9 #pragma once
10 
11 #include <corecrt.h>
12 #include <corecrt_share.h>
13 
14 #pragma warning(push)
15 #pragma warning(disable: _UCRT_DISABLED_WARNINGS)
16 _UCRT_DISABLE_CLANG_WARNINGS
17 
18 _CRT_BEGIN_C_HEADER
19 
20 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21 //
22 // Types
23 //
24 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25 #ifdef _USE_32BIT_TIME_T
26     #define _wfinddata_t    _wfinddata32_t
27     #define _wfinddatai64_t _wfinddata32i64_t
28 #else
29     #define _wfinddata_t    _wfinddata64i32_t
30     #define _wfinddatai64_t _wfinddata64_t
31 #endif
32 
33 typedef unsigned long _fsize_t;
34 
35 struct _wfinddata32_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
40     __time32_t time_write;
41     _fsize_t   size;
42     wchar_t    name[260];
43 };
44 
45 struct _wfinddata32i64_t
46 {
47     unsigned   attrib;
48     __time32_t time_create;    // -1 for FAT file systems
49     __time32_t time_access;    // -1 for FAT file systems
50     __time32_t time_write;
51     __int64    size;
52     wchar_t    name[260];
53 };
54 
55 struct _wfinddata64i32_t
56 {
57     unsigned   attrib;
58     __time64_t time_create;    // -1 for FAT file systems
59     __time64_t time_access;    // -1 for FAT file systems
60     __time64_t time_write;
61     _fsize_t   size;
62     wchar_t    name[260];
63 };
64 
65 struct _wfinddata64_t
66 {
67     unsigned   attrib;
68     __time64_t time_create;    // -1 for FAT file systems
69     __time64_t time_access;    // -1 for FAT file systems
70     __time64_t time_write;
71     __int64    size;
72     wchar_t    name[260];
73 };
74 
75 
76 
77 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 //
79 // Functions
80 //
81 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
82 #ifdef _USE_32BIT_TIME_T
83     #define _wfindfirst     _wfindfirst32
84     #define _wfindnext      _wfindnext32
85     #define _wfindfirsti64  _wfindfirst32i64
86     #define _wfindnexti64   _wfindnext32i64
87 #else
88     #define _wfindfirst     _wfindfirst64i32
89     #define _wfindnext      _wfindnext64i32
90     #define _wfindfirsti64  _wfindfirst64
91     #define _wfindnexti64   _wfindnext64
92 #endif
93 
94 _Check_return_
95 _ACRTIMP int __cdecl _waccess(
96     _In_z_ wchar_t const* _FileName,
97     _In_   int            _AccessMode
98     );
99 
100 _Check_return_wat_
101 _ACRTIMP errno_t __cdecl _waccess_s(
102     _In_z_ wchar_t const* _FileName,
103     _In_   int            _AccessMode
104     );
105 
106 _Check_return_
107 _ACRTIMP int __cdecl _wchmod(
108     _In_z_ wchar_t const* _FileName,
109     _In_   int            _Mode
110     );
111 
112 _Check_return_ _CRT_INSECURE_DEPRECATE(_wsopen_s)
113 _ACRTIMP int __cdecl _wcreat(
114     _In_z_ wchar_t const* _FileName,
115     _In_   int            _PermissionMode
116     );
117 
118 _Success_(return != -1)
119 _Check_return_
120 _ACRTIMP intptr_t __cdecl _wfindfirst32(
121     _In_z_ wchar_t const*         _FileName,
122     _Out_  struct _wfinddata32_t* _FindData
123     );
124 
125 _Success_(return != -1)
126 _Check_return_
127 _ACRTIMP int __cdecl _wfindnext32(
128     _In_  intptr_t               _FindHandle,
129     _Out_ struct _wfinddata32_t* _FindData
130     );
131 
132 _ACRTIMP int __cdecl _wunlink(
133     _In_z_ wchar_t const* _FileName
134     );
135 
136 _Check_return_
137 _ACRTIMP int __cdecl _wrename(
138     _In_z_ wchar_t const* _OldFileName,
139     _In_z_ wchar_t const* _NewFileName
140     );
141 
142 _ACRTIMP errno_t __cdecl _wmktemp_s(
143     _Inout_updates_z_(_SizeInWords) wchar_t* _TemplateName,
144     _In_                            size_t   _SizeInWords
145     );
146 
147 __DEFINE_CPP_OVERLOAD_SECURE_FUNC_0_0(
148     errno_t, _wmktemp_s,
149     wchar_t, _TemplateName
150     )
151 
152 _Success_(return != 0)
153 __DEFINE_CPP_OVERLOAD_STANDARD_FUNC_0_0(
154     wchar_t*, __RETURN_POLICY_DST, _ACRTIMP, _wmktemp,
155     _Inout_z_, wchar_t, _TemplateName
156     )
157 
158 _Success_(return != -1)
159 _Check_return_
160 _ACRTIMP intptr_t __cdecl _wfindfirst32i64(
161     _In_z_ wchar_t const*            _FileName,
162     _Out_  struct _wfinddata32i64_t* _FindData
163     );
164 
165 _Success_(return != -1)
166 _Check_return_
167 _ACRTIMP intptr_t __cdecl _wfindfirst64i32(
168     _In_z_ wchar_t const*            _FileName,
169     _Out_  struct _wfinddata64i32_t* _FindData
170     );
171 
172 _Success_(return != -1)
173 _Check_return_
174 _ACRTIMP intptr_t __cdecl _wfindfirst64(
175     _In_z_ wchar_t const*         _FileName,
176     _Out_  struct _wfinddata64_t* _FindData
177     );
178 
179 _Success_(return != -1)
180 _Check_return_
181 _ACRTIMP int __cdecl _wfindnext32i64(
182     _In_  intptr_t                  _FindHandle,
183     _Out_ struct _wfinddata32i64_t* _FindData
184     );
185 
186 _Success_(return != -1)
187 _Check_return_
188 _ACRTIMP int __cdecl _wfindnext64i32(
189     _In_  intptr_t                  _FindHandle,
190     _Out_ struct _wfinddata64i32_t* _FindData
191     );
192 
193 _Success_(return != -1)
194 _Check_return_
195 _ACRTIMP int __cdecl _wfindnext64(
196     _In_  intptr_t               _FindHandle,
197     _Out_ struct _wfinddata64_t* _FindData
198     );
199 
200 _Check_return_wat_
201 _ACRTIMP errno_t __cdecl _wsopen_s(
202     _Out_  int*           _FileHandle,
203     _In_z_ wchar_t const* _FileName,
204     _In_   int            _OpenFlag,
205     _In_   int            _ShareFlag,
206     _In_   int            _PermissionFlag
207     );
208 
209 _ACRTIMP errno_t __cdecl _wsopen_dispatch(
210     _In_z_ wchar_t const* _FileName,
211     _In_   int            _OFlag,
212     _In_   int            _ShFlag,
213     _In_   int            _PMode,
214     _Out_  int*           _PFileHandle,
215     _In_   int            _BSecure
216     );
217 
218 
219 
220 #if defined __cplusplus
221 
222     // These functions do not validate pmode; use _wsopen_s instead.
_CRT_INSECURE_DEPRECATE(_wsopen_s)223     extern "C++" _Check_return_ _CRT_INSECURE_DEPRECATE(_wsopen_s)
224     inline int __CRTDECL _wopen(
225         _In_z_ wchar_t const* _FileName,
226         _In_   int            _OFlag,
227         _In_   int            _PMode = 0
228         )
229     {
230         int _FileHandle;
231         // Last parameter passed as 0 because we don't want to validate pmode from _open
232         errno_t const _Result = _wsopen_dispatch(_FileName, _OFlag, _SH_DENYNO, _PMode, &_FileHandle, 0);
233         return _Result ? -1 : _FileHandle;
234     }
235 
_CRT_INSECURE_DEPRECATE(_wsopen_s)236     extern "C++" _Check_return_ _CRT_INSECURE_DEPRECATE(_wsopen_s)
237     inline int __CRTDECL _wsopen(
238         _In_z_ wchar_t const* _FileName,
239         _In_   int            _OFlag,
240         _In_   int            _ShFlag,
241         _In_   int            _PMode = 0
242         )
243     {
244         int _FileHandle;
245         // Last parameter passed as 0 because we don't want to validate pmode from _sopen
246         errno_t const _Result = _wsopen_dispatch(_FileName, _OFlag, _ShFlag, _PMode, &_FileHandle, 0);
247         return _Result ? -1 : _FileHandle;
248     }
249 
250 
251 #else
252 
253     _Check_return_ _CRT_INSECURE_DEPRECATE(_wsopen_s)
254     _ACRTIMP int __cdecl _wopen(
255         _In_z_ wchar_t const* _FileName,
256         _In_   int            _OpenFlag,
257         ...);
258 
259     _Check_return_ _CRT_INSECURE_DEPRECATE(_wsopen_s)
260     _ACRTIMP int __cdecl _wsopen(
261         _In_z_ wchar_t const* _FileName,
262         _In_   int            _OpenFlag,
263         _In_   int            _ShareFlag,
264         ...);
265 
266 #endif
267 
268 _CRT_END_C_HEADER
269 _UCRT_RESTORE_CLANG_WARNINGS
270 #pragma warning(pop) // _UCRT_DISABLED_WARNINGS
271