1 /*
2 * Copyright 2010 Vicente J. Botet Escriba
3 * Copyright 2015 Andrey Semashev
4 * Copyright 2016 Jorge Lodos
5 * Copyright 2017 James E. King, III
6 *
7 * Distributed under the Boost Software License, Version 1.0.
8 * See http://www.boost.org/LICENSE_1_0.txt
9 */
10
11 #ifndef BOOST_WINAPI_FILE_MANAGEMENT_HPP_INCLUDED_
12 #define BOOST_WINAPI_FILE_MANAGEMENT_HPP_INCLUDED_
13
14 #include <boost/winapi/basic_types.hpp>
15 #include <boost/winapi/limits.hpp>
16 #include <boost/winapi/time.hpp>
17 #include <boost/winapi/overlapped.hpp>
18 #include <boost/winapi/detail/header.hpp>
19
20 #ifdef BOOST_HAS_PRAGMA_ONCE
21 #pragma once
22 #endif
23
24 /*
25 * UWP:
26 * API SDK 8 SDK 10 _WIN32_WINNT
27 * AreFileApisANSI DESKTOP - DESKTOP | SYSTEM
28 * CreateFile DESKTOP - DESKTOP | SYSTEM
29 * DeleteFile APP - APP | SYSTEM
30 * FindClose APP - APP | SYSTEM
31 * FindFirstFile DESKTOP > APP | SYSTEM
32 * FindNextFile DESKTOP > APP | SYSTEM
33 * GetFileAttributes DESKTOP > APP | SYSTEM
34 * GetFileInformationByHandle DESKTOP - DESKTOP | SYSTEM
35 * GetFileSizeEx DESKTOP > APP | SYSTEM
36 * LockFile DESKTOP - DESKTOP | SYSTEM
37 * MoveFileEx APP - APP | SYSTEM
38 * ReadFile APP - APP | SYSTEM
39 * SetEndOfFile APP - APP | SYSTEM
40 * SetFilePointer DESKTOP > APP | SYSTEM
41 * SetFileValidData DESKTOP - DESKTOP | SYSTEM >= 0x0501
42 * UnlockFile DESKTOP - DESKTOP | SYSTEM
43 * WriteFile APP - APP | SYSTEM
44 */
45
46 #if !defined( BOOST_USE_WINDOWS_H )
47 extern "C" {
48
49 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
50 #if !defined( BOOST_NO_ANSI_APIS )
51 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
52 AreFileApisANSI(BOOST_WINAPI_DETAIL_VOID);
53
54 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
55 CreateFileA(
56 boost::winapi::LPCSTR_ lpFileName,
57 boost::winapi::DWORD_ dwDesiredAccess,
58 boost::winapi::DWORD_ dwShareMode,
59 ::_SECURITY_ATTRIBUTES* lpSecurityAttributes,
60 boost::winapi::DWORD_ dwCreationDisposition,
61 boost::winapi::DWORD_ dwFlagsAndAttributes,
62 boost::winapi::HANDLE_ hTemplateFile);
63
64 struct _WIN32_FIND_DATAA;
65 BOOST_WINAPI_IMPORT boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
66 FindFirstFileA(boost::winapi::LPCSTR_ lpFileName, ::_WIN32_FIND_DATAA* lpFindFileData);
67
68 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
69 FindNextFileA(boost::winapi::HANDLE_ hFindFile, ::_WIN32_FIND_DATAA* lpFindFileData);
70 #endif
71
72 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
73 CreateFileW(
74 boost::winapi::LPCWSTR_ lpFileName,
75 boost::winapi::DWORD_ dwDesiredAccess,
76 boost::winapi::DWORD_ dwShareMode,
77 ::_SECURITY_ATTRIBUTES* lpSecurityAttributes,
78 boost::winapi::DWORD_ dwCreationDisposition,
79 boost::winapi::DWORD_ dwFlagsAndAttributes,
80 boost::winapi::HANDLE_ hTemplateFile);
81
82 struct _WIN32_FIND_DATAW;
83 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::HANDLE_ BOOST_WINAPI_WINAPI_CC
84 FindFirstFileW(boost::winapi::LPCWSTR_ lpFileName, ::_WIN32_FIND_DATAW* lpFindFileData);
85
86 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
87 FindNextFileW(boost::winapi::HANDLE_ hFindFile, ::_WIN32_FIND_DATAW* lpFindFileData);
88
89 struct _BY_HANDLE_FILE_INFORMATION;
90 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
91 GetFileInformationByHandle(
92 boost::winapi::HANDLE_ hFile,
93 ::_BY_HANDLE_FILE_INFORMATION* lpFileInformation);
94
95 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
96 LockFile(
97 boost::winapi::HANDLE_ hFile,
98 boost::winapi::DWORD_ dwFileOffsetLow,
99 boost::winapi::DWORD_ dwFileOffsetHigh,
100 boost::winapi::DWORD_ nNumberOfBytesToLockLow,
101 boost::winapi::DWORD_ nNumberOfBytesToLockHigh);
102
103 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
104 LockFileEx(
105 boost::winapi::HANDLE_ hFile,
106 boost::winapi::DWORD_ dwFlags,
107 boost::winapi::DWORD_ dwReserved,
108 boost::winapi::DWORD_ nNumberOfBytesToLockLow,
109 boost::winapi::DWORD_ nNumberOfBytesToLockHigh,
110 ::_OVERLAPPED* lpOverlapped);
111
112 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP
113 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
114 SetFileValidData(
115 boost::winapi::HANDLE_ hFile,
116 boost::winapi::LONGLONG_ ValidDataLength);
117 #endif
118
119 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
120 UnlockFile(
121 boost::winapi::HANDLE_ hFile,
122 boost::winapi::DWORD_ dwFileOffsetLow,
123 boost::winapi::DWORD_ dwFileOffsetHigh,
124 boost::winapi::DWORD_ nNumberOfBytesToUnlockLow,
125 boost::winapi::DWORD_ nNumberOfBytesToUnlockHigh);
126
127 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
128 UnlockFileEx(
129 boost::winapi::HANDLE_ hFile,
130 boost::winapi::DWORD_ dwReserved,
131 boost::winapi::DWORD_ nNumberOfBytesToUnlockLow,
132 boost::winapi::DWORD_ nNumberOfBytesToUnlockHigh,
133 ::_OVERLAPPED* lpOverlapped);
134 #endif
135
136 #if BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM
137 #if !defined( BOOST_NO_ANSI_APIS )
138 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
139 DeleteFileA(boost::winapi::LPCSTR_ lpFileName);
140
141 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
142 MoveFileExA(
143 boost::winapi::LPCSTR_ lpExistingFileName,
144 boost::winapi::LPCSTR_ lpNewFileName,
145 boost::winapi::DWORD_ dwFlags);
146 #endif
147
148 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
149 DeleteFileW(boost::winapi::LPCWSTR_ lpFileName);
150
151 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
152 FindClose(boost::winapi::HANDLE_ hFindFile);
153
154 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
155 MoveFileExW(
156 boost::winapi::LPCWSTR_ lpExistingFileName,
157 boost::winapi::LPCWSTR_ lpNewFileName,
158 boost::winapi::DWORD_ dwFlags);
159
160 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
161 ReadFile(
162 boost::winapi::HANDLE_ hFile,
163 boost::winapi::LPVOID_ lpBuffer,
164 boost::winapi::DWORD_ nNumberOfBytesToRead,
165 boost::winapi::LPDWORD_ lpNumberOfBytesRead,
166 ::_OVERLAPPED* lpOverlapped);
167
168 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
169 SetEndOfFile(boost::winapi::HANDLE_ hFile);
170
171 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
172 WriteFile(
173 boost::winapi::HANDLE_ hFile,
174 boost::winapi::LPCVOID_ lpBuffer,
175 boost::winapi::DWORD_ nNumberOfBytesToWrite,
176 boost::winapi::LPDWORD_ lpNumberOfBytesWritten,
177 ::_OVERLAPPED* lpOverlapped);
178 #endif // BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM
179
180 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
181 #if !defined( BOOST_NO_ANSI_APIS )
182 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
183 GetFileAttributesA(boost::winapi::LPCSTR_ lpFileName);
184 #endif
185
186 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
187 GetFileAttributesW(boost::winapi::LPCWSTR_ lpFileName);
188
189 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
190 GetFileSizeEx(boost::winapi::HANDLE_ hFile, ::_LARGE_INTEGER* lpFileSize);
191
192 BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
193 SetFilePointer(
194 boost::winapi::HANDLE_ hFile,
195 boost::winapi::LONG_ lpDistanceToMove,
196 boost::winapi::PLONG_ lpDistanceToMoveHigh,
197 boost::winapi::DWORD_ dwMoveMethod);
198 #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
199
200 } // extern "C"
201 #endif // !defined(BOOST_USE_WINDOWS_H)
202
203 namespace boost {
204 namespace winapi {
205
206 #if defined( BOOST_USE_WINDOWS_H )
207
208 BOOST_CONSTEXPR_OR_CONST DWORD_ INVALID_FILE_SIZE_ = INVALID_FILE_SIZE;
209 BOOST_CONSTEXPR_OR_CONST DWORD_ INVALID_SET_FILE_POINTER_ = INVALID_SET_FILE_POINTER;
210 BOOST_CONSTEXPR_OR_CONST DWORD_ INVALID_FILE_ATTRIBUTES_ = INVALID_FILE_ATTRIBUTES;
211
212 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_READONLY_ = FILE_ATTRIBUTE_READONLY;
213 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_HIDDEN_ = FILE_ATTRIBUTE_HIDDEN;
214 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_SYSTEM_ = FILE_ATTRIBUTE_SYSTEM;
215 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_DIRECTORY_ = FILE_ATTRIBUTE_DIRECTORY;
216 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_ARCHIVE_ = FILE_ATTRIBUTE_ARCHIVE;
217 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_DEVICE_ = FILE_ATTRIBUTE_DEVICE;
218 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_NORMAL_ = FILE_ATTRIBUTE_NORMAL;
219 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_TEMPORARY_ = FILE_ATTRIBUTE_TEMPORARY;
220 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_SPARSE_FILE_ = FILE_ATTRIBUTE_SPARSE_FILE;
221 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_REPARSE_POINT_ = FILE_ATTRIBUTE_REPARSE_POINT;
222 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_COMPRESSED_ = FILE_ATTRIBUTE_COMPRESSED;
223 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_OFFLINE_ = FILE_ATTRIBUTE_OFFLINE;
224 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_ = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
225 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_ENCRYPTED_ = FILE_ATTRIBUTE_ENCRYPTED;
226
227 BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_NEW_ = CREATE_NEW;
228 BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_ALWAYS_ = CREATE_ALWAYS;
229 BOOST_CONSTEXPR_OR_CONST DWORD_ OPEN_EXISTING_ = OPEN_EXISTING;
230 BOOST_CONSTEXPR_OR_CONST DWORD_ OPEN_ALWAYS_ = OPEN_ALWAYS;
231 BOOST_CONSTEXPR_OR_CONST DWORD_ TRUNCATE_EXISTING_ = TRUNCATE_EXISTING;
232
233 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_SHARE_READ_ = FILE_SHARE_READ;
234 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_SHARE_WRITE_ = FILE_SHARE_WRITE;
235 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_SHARE_DELETE_ = FILE_SHARE_DELETE;
236
237 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_BEGIN_ = FILE_BEGIN;
238 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_CURRENT_ = FILE_CURRENT;
239 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_END_ = FILE_END;
240
241 #else // defined( BOOST_USE_WINDOWS_H )
242
243 BOOST_CONSTEXPR_OR_CONST DWORD_ INVALID_FILE_SIZE_ = ((DWORD_)0xFFFFFFFF);
244 BOOST_CONSTEXPR_OR_CONST DWORD_ INVALID_SET_FILE_POINTER_ = ((DWORD_)-1);
245 BOOST_CONSTEXPR_OR_CONST DWORD_ INVALID_FILE_ATTRIBUTES_ = ((DWORD_)-1);
246
247 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_READONLY_ = 0x00000001;
248 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_HIDDEN_ = 0x00000002;
249 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_SYSTEM_ = 0x00000004;
250 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_DIRECTORY_ = 0x00000010;
251 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_ARCHIVE_ = 0x00000020;
252 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_DEVICE_ = 0x00000040;
253 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_NORMAL_ = 0x00000080;
254 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_TEMPORARY_ = 0x00000100;
255 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_SPARSE_FILE_ = 0x00000200;
256 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_REPARSE_POINT_ = 0x00000400;
257 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_COMPRESSED_ = 0x00000800;
258 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_OFFLINE_ = 0x00001000;
259 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_ = 0x00002000;
260 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_ENCRYPTED_ = 0x00004000;
261
262 BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_NEW_ = 1;
263 BOOST_CONSTEXPR_OR_CONST DWORD_ CREATE_ALWAYS_ = 2;
264 BOOST_CONSTEXPR_OR_CONST DWORD_ OPEN_EXISTING_ = 3;
265 BOOST_CONSTEXPR_OR_CONST DWORD_ OPEN_ALWAYS_ = 4;
266 BOOST_CONSTEXPR_OR_CONST DWORD_ TRUNCATE_EXISTING_ = 5;
267
268 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_SHARE_READ_ = 0x00000001;
269 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_SHARE_WRITE_ = 0x00000002;
270 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_SHARE_DELETE_ = 0x00000004;
271
272 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_BEGIN_ = 0;
273 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_CURRENT_ = 1;
274 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_END_ = 2;
275
276 #endif // defined( BOOST_USE_WINDOWS_H )
277
278 // Some of these constants are not defined by Windows SDK in MinGW or older MSVC
279 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_WRITE_THROUGH_ = 0x80000000;
280 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_OVERLAPPED_ = 0x40000000;
281 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_NO_BUFFERING_ = 0x20000000;
282 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_RANDOM_ACCESS_ = 0x10000000;
283 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_SEQUENTIAL_SCAN_ = 0x08000000;
284 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_DELETE_ON_CLOSE_ = 0x04000000;
285 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_BACKUP_SEMANTICS_ = 0x02000000;
286 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_POSIX_SEMANTICS_ = 0x01000000;
287 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_SESSION_AWARE_ = 0x00800000;
288 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_OPEN_REPARSE_POINT_ = 0x00200000;
289 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_OPEN_NO_RECALL_ = 0x00100000;
290 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_FIRST_PIPE_INSTANCE_ = 0x00080000;
291
292 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN8
293 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_FLAG_OPEN_REQUIRING_OPLOCK_ = 0x00040000;
294 #endif
295
296 // This constant is not defined in Windows SDK up until 6.0A
297 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_VIRTUAL_ = 0x00010000;
298
299 // These constants are not defined in Windows SDK up until 8.0 and MinGW/MinGW-w64 (as of 2016-02-14).
300 // They are documented to be supported only since Windows 8/Windows Server 2012
301 // but defined unconditionally.
302 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_INTEGRITY_STREAM_ = 0x00008000;
303 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_NO_SCRUB_DATA_ = 0x00020000;
304 // Undocumented
305 BOOST_CONSTEXPR_OR_CONST DWORD_ FILE_ATTRIBUTE_EA_ = 0x00040000;
306
307 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
308 #if !defined( BOOST_NO_ANSI_APIS )
309 using ::AreFileApisANSI;
310
CreateFileA(LPCSTR_ lpFileName,DWORD_ dwDesiredAccess,DWORD_ dwShareMode,SECURITY_ATTRIBUTES_ * lpSecurityAttributes,DWORD_ dwCreationDisposition,DWORD_ dwFlagsAndAttributes,HANDLE_ hTemplateFile)311 BOOST_FORCEINLINE HANDLE_ CreateFileA(
312 LPCSTR_ lpFileName,
313 DWORD_ dwDesiredAccess,
314 DWORD_ dwShareMode,
315 SECURITY_ATTRIBUTES_* lpSecurityAttributes,
316 DWORD_ dwCreationDisposition,
317 DWORD_ dwFlagsAndAttributes,
318 HANDLE_ hTemplateFile)
319 {
320 return ::CreateFileA(
321 lpFileName,
322 dwDesiredAccess,
323 dwShareMode,
324 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes),
325 dwCreationDisposition,
326 dwFlagsAndAttributes,
327 hTemplateFile);
328 }
329
create_file(LPCSTR_ lpFileName,DWORD_ dwDesiredAccess,DWORD_ dwShareMode,SECURITY_ATTRIBUTES_ * lpSecurityAttributes,DWORD_ dwCreationDisposition,DWORD_ dwFlagsAndAttributes,HANDLE_ hTemplateFile)330 BOOST_FORCEINLINE HANDLE_ create_file(
331 LPCSTR_ lpFileName,
332 DWORD_ dwDesiredAccess,
333 DWORD_ dwShareMode,
334 SECURITY_ATTRIBUTES_* lpSecurityAttributes,
335 DWORD_ dwCreationDisposition,
336 DWORD_ dwFlagsAndAttributes,
337 HANDLE_ hTemplateFile)
338 {
339 return ::CreateFileA(
340 lpFileName,
341 dwDesiredAccess,
342 dwShareMode,
343 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes),
344 dwCreationDisposition,
345 dwFlagsAndAttributes,
346 hTemplateFile);
347 }
348
349 typedef struct BOOST_MAY_ALIAS _WIN32_FIND_DATAA {
350 DWORD_ dwFileAttributes;
351 FILETIME_ ftCreationTime;
352 FILETIME_ ftLastAccessTime;
353 FILETIME_ ftLastWriteTime;
354 DWORD_ nFileSizeHigh;
355 DWORD_ nFileSizeLow;
356 DWORD_ dwReserved0;
357 DWORD_ dwReserved1;
358 CHAR_ cFileName[MAX_PATH_];
359 CHAR_ cAlternateFileName[14];
360 #ifdef _MAC
361 DWORD_ dwFileType;
362 DWORD_ dwCreatorType;
363 WORD_ wFinderFlags;
364 #endif
365 } WIN32_FIND_DATAA_, *PWIN32_FIND_DATAA_, *LPWIN32_FIND_DATAA_;
366
FindFirstFileA(LPCSTR_ lpFileName,WIN32_FIND_DATAA_ * lpFindFileData)367 BOOST_FORCEINLINE HANDLE_ FindFirstFileA(LPCSTR_ lpFileName, WIN32_FIND_DATAA_* lpFindFileData)
368 {
369 return ::FindFirstFileA(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData));
370 }
371
find_first_file(LPCSTR_ lpFileName,WIN32_FIND_DATAA_ * lpFindFileData)372 BOOST_FORCEINLINE HANDLE_ find_first_file(LPCSTR_ lpFileName, WIN32_FIND_DATAA_* lpFindFileData)
373 {
374 return ::FindFirstFileA(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData));
375 }
376
FindNextFileA(HANDLE_ hFindFile,WIN32_FIND_DATAA_ * lpFindFileData)377 BOOST_FORCEINLINE BOOL_ FindNextFileA(HANDLE_ hFindFile, WIN32_FIND_DATAA_* lpFindFileData)
378 {
379 return ::FindNextFileA(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData));
380 }
381
find_next_file(HANDLE_ hFindFile,WIN32_FIND_DATAA_ * lpFindFileData)382 BOOST_FORCEINLINE BOOL_ find_next_file(HANDLE_ hFindFile, WIN32_FIND_DATAA_* lpFindFileData)
383 {
384 return ::FindNextFileA(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData));
385 }
386
387 #endif // !defined( BOOST_NO_ANSI_APIS )
388
CreateFileW(LPCWSTR_ lpFileName,DWORD_ dwDesiredAccess,DWORD_ dwShareMode,SECURITY_ATTRIBUTES_ * lpSecurityAttributes,DWORD_ dwCreationDisposition,DWORD_ dwFlagsAndAttributes,HANDLE_ hTemplateFile)389 BOOST_FORCEINLINE HANDLE_ CreateFileW(
390 LPCWSTR_ lpFileName,
391 DWORD_ dwDesiredAccess,
392 DWORD_ dwShareMode,
393 SECURITY_ATTRIBUTES_* lpSecurityAttributes,
394 DWORD_ dwCreationDisposition,
395 DWORD_ dwFlagsAndAttributes,
396 HANDLE_ hTemplateFile)
397 {
398 return ::CreateFileW(
399 lpFileName,
400 dwDesiredAccess,
401 dwShareMode,
402 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes),
403 dwCreationDisposition,
404 dwFlagsAndAttributes,
405 hTemplateFile);
406 }
407
create_file(LPCWSTR_ lpFileName,DWORD_ dwDesiredAccess,DWORD_ dwShareMode,SECURITY_ATTRIBUTES_ * lpSecurityAttributes,DWORD_ dwCreationDisposition,DWORD_ dwFlagsAndAttributes,HANDLE_ hTemplateFile)408 BOOST_FORCEINLINE HANDLE_ create_file(
409 LPCWSTR_ lpFileName,
410 DWORD_ dwDesiredAccess,
411 DWORD_ dwShareMode,
412 SECURITY_ATTRIBUTES_* lpSecurityAttributes,
413 DWORD_ dwCreationDisposition,
414 DWORD_ dwFlagsAndAttributes,
415 HANDLE_ hTemplateFile)
416 {
417 return ::CreateFileW(
418 lpFileName,
419 dwDesiredAccess,
420 dwShareMode,
421 reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes),
422 dwCreationDisposition,
423 dwFlagsAndAttributes,
424 hTemplateFile);
425 }
426
427 typedef struct BOOST_MAY_ALIAS _WIN32_FIND_DATAW {
428 DWORD_ dwFileAttributes;
429 FILETIME_ ftCreationTime;
430 FILETIME_ ftLastAccessTime;
431 FILETIME_ ftLastWriteTime;
432 DWORD_ nFileSizeHigh;
433 DWORD_ nFileSizeLow;
434 DWORD_ dwReserved0;
435 DWORD_ dwReserved1;
436 WCHAR_ cFileName[MAX_PATH_];
437 WCHAR_ cAlternateFileName[14];
438 #ifdef _MAC
439 DWORD_ dwFileType;
440 DWORD_ dwCreatorType;
441 WORD_ wFinderFlags;
442 #endif
443 } WIN32_FIND_DATAW_, *PWIN32_FIND_DATAW_, *LPWIN32_FIND_DATAW_;
444
445 typedef struct BOOST_MAY_ALIAS _BY_HANDLE_FILE_INFORMATION {
446 DWORD_ dwFileAttributes;
447 FILETIME_ ftCreationTime;
448 FILETIME_ ftLastAccessTime;
449 FILETIME_ ftLastWriteTime;
450 DWORD_ dwVolumeSerialNumber;
451 DWORD_ nFileSizeHigh;
452 DWORD_ nFileSizeLow;
453 DWORD_ nNumberOfLinks;
454 DWORD_ nFileIndexHigh;
455 DWORD_ nFileIndexLow;
456 } BY_HANDLE_FILE_INFORMATION_, *PBY_HANDLE_FILE_INFORMATION_, *LPBY_HANDLE_FILE_INFORMATION_;
457
FindFirstFileW(LPCWSTR_ lpFileName,WIN32_FIND_DATAW_ * lpFindFileData)458 BOOST_FORCEINLINE HANDLE_ FindFirstFileW(LPCWSTR_ lpFileName, WIN32_FIND_DATAW_* lpFindFileData)
459 {
460 return ::FindFirstFileW(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData));
461 }
462
find_first_file(LPCWSTR_ lpFileName,WIN32_FIND_DATAW_ * lpFindFileData)463 BOOST_FORCEINLINE HANDLE_ find_first_file(LPCWSTR_ lpFileName, WIN32_FIND_DATAW_* lpFindFileData)
464 {
465 return ::FindFirstFileW(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData));
466 }
467
FindNextFileW(HANDLE_ hFindFile,WIN32_FIND_DATAW_ * lpFindFileData)468 BOOST_FORCEINLINE BOOL_ FindNextFileW(HANDLE_ hFindFile, WIN32_FIND_DATAW_* lpFindFileData)
469 {
470 return ::FindNextFileW(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData));
471 }
472
find_next_file(HANDLE_ hFindFile,WIN32_FIND_DATAW_ * lpFindFileData)473 BOOST_FORCEINLINE BOOL_ find_next_file(HANDLE_ hFindFile, WIN32_FIND_DATAW_* lpFindFileData)
474 {
475 return ::FindNextFileW(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData));
476 }
477
GetFileInformationByHandle(HANDLE_ h,BY_HANDLE_FILE_INFORMATION_ * info)478 BOOST_FORCEINLINE BOOL_ GetFileInformationByHandle(HANDLE_ h, BY_HANDLE_FILE_INFORMATION_* info)
479 {
480 return ::GetFileInformationByHandle(h, reinterpret_cast< ::_BY_HANDLE_FILE_INFORMATION* >(info));
481 }
482
483 using ::LockFile;
484
LockFileEx(HANDLE_ hFile,DWORD_ dwFlags,DWORD_ dwReserved,DWORD_ nNumberOfBytesToLockLow,DWORD_ nNumberOfBytesToLockHigh,OVERLAPPED_ * lpOverlapped)485 BOOST_FORCEINLINE BOOL_ LockFileEx(
486 HANDLE_ hFile,
487 DWORD_ dwFlags,
488 DWORD_ dwReserved,
489 DWORD_ nNumberOfBytesToLockLow,
490 DWORD_ nNumberOfBytesToLockHigh,
491 OVERLAPPED_* lpOverlapped)
492 {
493 return ::LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped));
494 }
495
496 #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP
497 using ::SetFileValidData;
498 #endif
499
500 using ::UnlockFile;
501
UnlockFileEx(HANDLE_ hFile,DWORD_ dwReserved,DWORD_ nNumberOfBytesToUnlockLow,DWORD_ nNumberOfBytesToUnlockHigh,OVERLAPPED_ * lpOverlapped)502 BOOST_FORCEINLINE BOOL_ UnlockFileEx(
503 HANDLE_ hFile,
504 DWORD_ dwReserved,
505 DWORD_ nNumberOfBytesToUnlockLow,
506 DWORD_ nNumberOfBytesToUnlockHigh,
507 OVERLAPPED_* lpOverlapped)
508 {
509 return ::UnlockFileEx(hFile, dwReserved, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped));
510 }
511 #endif // BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
512
513 #if BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM
514 #if !defined( BOOST_NO_ANSI_APIS )
515 using ::DeleteFileA;
516
delete_file(LPCSTR_ lpFileName)517 BOOST_FORCEINLINE BOOL_ delete_file(LPCSTR_ lpFileName)
518 {
519 return ::DeleteFileA(lpFileName);
520 }
521
522 using ::MoveFileExA;
523
move_file(LPCSTR_ lpExistingFileName,LPCSTR_ lpNewFileName,DWORD_ dwFlags)524 BOOST_FORCEINLINE BOOL_ move_file(LPCSTR_ lpExistingFileName, LPCSTR_ lpNewFileName, DWORD_ dwFlags)
525 {
526 return ::MoveFileExA(lpExistingFileName, lpNewFileName, dwFlags);
527 }
528
529 #endif
530 using ::DeleteFileW;
531
delete_file(LPCWSTR_ lpFileName)532 BOOST_FORCEINLINE BOOL_ delete_file(LPCWSTR_ lpFileName)
533 {
534 return ::DeleteFileW(lpFileName);
535 }
536
537 using ::FindClose;
538 using ::MoveFileExW;
539
move_file(LPCWSTR_ lpExistingFileName,LPCWSTR_ lpNewFileName,DWORD_ dwFlags)540 BOOST_FORCEINLINE BOOL_ move_file(LPCWSTR_ lpExistingFileName, LPCWSTR_ lpNewFileName, DWORD_ dwFlags)
541 {
542 return ::MoveFileExW(lpExistingFileName, lpNewFileName, dwFlags);
543 }
544
ReadFile(HANDLE_ hFile,LPVOID_ lpBuffer,DWORD_ nNumberOfBytesToWrite,LPDWORD_ lpNumberOfBytesWritten,OVERLAPPED_ * lpOverlapped)545 BOOST_FORCEINLINE BOOL_ ReadFile(
546 HANDLE_ hFile,
547 LPVOID_ lpBuffer,
548 DWORD_ nNumberOfBytesToWrite,
549 LPDWORD_ lpNumberOfBytesWritten,
550 OVERLAPPED_* lpOverlapped)
551 {
552 return ::ReadFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped));
553 }
554
555 using ::SetEndOfFile;
556
WriteFile(HANDLE_ hFile,LPCVOID_ lpBuffer,DWORD_ nNumberOfBytesToWrite,LPDWORD_ lpNumberOfBytesWritten,OVERLAPPED_ * lpOverlapped)557 BOOST_FORCEINLINE BOOL_ WriteFile(
558 HANDLE_ hFile,
559 LPCVOID_ lpBuffer,
560 DWORD_ nNumberOfBytesToWrite,
561 LPDWORD_ lpNumberOfBytesWritten,
562 OVERLAPPED_* lpOverlapped)
563 {
564 return ::WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped));
565 }
566 #endif // BOOST_WINAPI_PARTITION_APP || BOOST_WINAPI_PARTITION_SYSTEM
567
568 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
569 #if !defined( BOOST_NO_ANSI_APIS )
570 using ::GetFileAttributesA;
571
get_file_attributes(LPCSTR_ lpFileName)572 BOOST_FORCEINLINE DWORD_ get_file_attributes(LPCSTR_ lpFileName)
573 {
574 return ::GetFileAttributesA(lpFileName);
575 }
576 #endif
577 using ::GetFileAttributesW;
578
get_file_attributes(LPCWSTR_ lpFileName)579 BOOST_FORCEINLINE DWORD_ get_file_attributes(LPCWSTR_ lpFileName)
580 {
581 return ::GetFileAttributesW(lpFileName);
582 }
583
GetFileSizeEx(HANDLE_ hFile,LARGE_INTEGER_ * lpFileSize)584 BOOST_FORCEINLINE BOOL_ GetFileSizeEx(HANDLE_ hFile, LARGE_INTEGER_* lpFileSize)
585 {
586 return ::GetFileSizeEx(hFile, reinterpret_cast< ::_LARGE_INTEGER* >(lpFileSize));
587 }
588
589 using ::SetFilePointer;
590 #endif // BOOST_WINAPI_PARTITION_APP_SYSTEM
591
592 }
593 }
594
595 #include <boost/winapi/detail/footer.hpp>
596
597 #endif // BOOST_WINAPI_FILE_MANAGEMENT_HPP_INCLUDED_
598