file_management.hpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. // file_management.hpp --------------------------------------------------------------//
  2. // Copyright 2010 Vicente J. Botet Escriba
  3. // Copyright 2015 Andrey Semashev
  4. // Copyright 2016 Jorge Lodos
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // See http://www.boost.org/LICENSE_1_0.txt
  7. #ifndef BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP
  8. #define BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP
  9. #include <boost/detail/winapi/basic_types.hpp>
  10. #include <boost/detail/winapi/limits.hpp>
  11. #include <boost/detail/winapi/time.hpp>
  12. #include <boost/detail/winapi/overlapped.hpp>
  13. #ifdef BOOST_HAS_PRAGMA_ONCE
  14. #pragma once
  15. #endif
  16. #if !defined( BOOST_USE_WINDOWS_H )
  17. extern "C" {
  18. #if !defined( BOOST_NO_ANSI_APIS )
  19. BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
  20. CreateFileA(
  21. boost::detail::winapi::LPCSTR_ lpFileName,
  22. boost::detail::winapi::DWORD_ dwDesiredAccess,
  23. boost::detail::winapi::DWORD_ dwShareMode,
  24. ::_SECURITY_ATTRIBUTES* lpSecurityAttributes,
  25. boost::detail::winapi::DWORD_ dwCreationDisposition,
  26. boost::detail::winapi::DWORD_ dwFlagsAndAttributes,
  27. boost::detail::winapi::HANDLE_ hTemplateFile);
  28. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  29. DeleteFileA(boost::detail::winapi::LPCSTR_ lpFileName);
  30. struct _WIN32_FIND_DATAA;
  31. BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
  32. FindFirstFileA(boost::detail::winapi::LPCSTR_ lpFileName, ::_WIN32_FIND_DATAA* lpFindFileData);
  33. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  34. FindNextFileA(boost::detail::winapi::HANDLE_ hFindFile, ::_WIN32_FIND_DATAA* lpFindFileData);
  35. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  36. MoveFileExA(
  37. boost::detail::winapi::LPCSTR_ lpExistingFileName,
  38. boost::detail::winapi::LPCSTR_ lpNewFileName,
  39. boost::detail::winapi::DWORD_ dwFlags);
  40. BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI
  41. GetFileAttributesA(boost::detail::winapi::LPCSTR_ lpFileName);
  42. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  43. AreFileApisANSI(BOOST_DETAIL_WINAPI_VOID);
  44. #endif
  45. BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
  46. CreateFileW(
  47. boost::detail::winapi::LPCWSTR_ lpFileName,
  48. boost::detail::winapi::DWORD_ dwDesiredAccess,
  49. boost::detail::winapi::DWORD_ dwShareMode,
  50. ::_SECURITY_ATTRIBUTES* lpSecurityAttributes,
  51. boost::detail::winapi::DWORD_ dwCreationDisposition,
  52. boost::detail::winapi::DWORD_ dwFlagsAndAttributes,
  53. boost::detail::winapi::HANDLE_ hTemplateFile);
  54. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  55. DeleteFileW(boost::detail::winapi::LPCWSTR_ lpFileName);
  56. struct _WIN32_FIND_DATAW;
  57. BOOST_SYMBOL_IMPORT boost::detail::winapi::HANDLE_ WINAPI
  58. FindFirstFileW(boost::detail::winapi::LPCWSTR_ lpFileName, ::_WIN32_FIND_DATAW* lpFindFileData);
  59. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  60. FindNextFileW(boost::detail::winapi::HANDLE_ hFindFile, ::_WIN32_FIND_DATAW* lpFindFileData);
  61. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  62. MoveFileExW(
  63. boost::detail::winapi::LPCWSTR_ lpExistingFileName,
  64. boost::detail::winapi::LPCWSTR_ lpNewFileName,
  65. boost::detail::winapi::DWORD_ dwFlags);
  66. BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI
  67. GetFileAttributesW(boost::detail::winapi::LPCWSTR_ lpFileName);
  68. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  69. FindClose(boost::detail::winapi::HANDLE_ hFindFile);
  70. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  71. GetFileSizeEx(boost::detail::winapi::HANDLE_ hFile, ::_LARGE_INTEGER* lpFileSize);
  72. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP
  73. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  74. SetFileValidData(boost::detail::winapi::HANDLE_ hFile, boost::detail::winapi::LONGLONG_ ValidDataLength);
  75. #endif
  76. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  77. SetEndOfFile(boost::detail::winapi::HANDLE_ hFile);
  78. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  79. LockFile(
  80. boost::detail::winapi::HANDLE_ hFile,
  81. boost::detail::winapi::DWORD_ dwFileOffsetLow,
  82. boost::detail::winapi::DWORD_ dwFileOffsetHigh,
  83. boost::detail::winapi::DWORD_ nNumberOfBytesToLockLow,
  84. boost::detail::winapi::DWORD_ nNumberOfBytesToLockHigh);
  85. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  86. UnlockFile(
  87. boost::detail::winapi::HANDLE_ hFile,
  88. boost::detail::winapi::DWORD_ dwFileOffsetLow,
  89. boost::detail::winapi::DWORD_ dwFileOffsetHigh,
  90. boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockLow,
  91. boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockHigh);
  92. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  93. LockFileEx(
  94. boost::detail::winapi::HANDLE_ hFile,
  95. boost::detail::winapi::DWORD_ dwFlags,
  96. boost::detail::winapi::DWORD_ dwReserved,
  97. boost::detail::winapi::DWORD_ nNumberOfBytesToLockLow,
  98. boost::detail::winapi::DWORD_ nNumberOfBytesToLockHigh,
  99. ::_OVERLAPPED* lpOverlapped);
  100. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  101. UnlockFileEx(
  102. boost::detail::winapi::HANDLE_ hFile,
  103. boost::detail::winapi::DWORD_ dwReserved,
  104. boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockLow,
  105. boost::detail::winapi::DWORD_ nNumberOfBytesToUnlockHigh,
  106. ::_OVERLAPPED* lpOverlapped);
  107. BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI
  108. WriteFile(
  109. boost::detail::winapi::HANDLE_ hFile,
  110. boost::detail::winapi::LPCVOID_ lpBuffer,
  111. boost::detail::winapi::DWORD_ nNumberOfBytesToWrite,
  112. boost::detail::winapi::LPDWORD_ lpNumberOfBytesWritten,
  113. ::_OVERLAPPED* lpOverlapped);
  114. BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI
  115. SetFilePointer(
  116. boost::detail::winapi::HANDLE_ hFile,
  117. boost::detail::winapi::LONG_ lpDistanceToMove,
  118. boost::detail::winapi::PLONG_ lpDistanceToMoveHigh,
  119. boost::detail::winapi::DWORD_ dwMoveMethod);
  120. }
  121. #endif
  122. namespace boost {
  123. namespace detail {
  124. namespace winapi {
  125. #if defined( BOOST_USE_WINDOWS_H )
  126. const DWORD_ INVALID_FILE_SIZE_ = INVALID_FILE_SIZE;
  127. const DWORD_ INVALID_SET_FILE_POINTER_ = INVALID_SET_FILE_POINTER;
  128. const DWORD_ INVALID_FILE_ATTRIBUTES_ = INVALID_FILE_ATTRIBUTES;
  129. const DWORD_ FILE_ATTRIBUTE_READONLY_ = FILE_ATTRIBUTE_READONLY;
  130. const DWORD_ FILE_ATTRIBUTE_HIDDEN_ = FILE_ATTRIBUTE_HIDDEN;
  131. const DWORD_ FILE_ATTRIBUTE_SYSTEM_ = FILE_ATTRIBUTE_SYSTEM;
  132. const DWORD_ FILE_ATTRIBUTE_DIRECTORY_ = FILE_ATTRIBUTE_DIRECTORY;
  133. const DWORD_ FILE_ATTRIBUTE_ARCHIVE_ = FILE_ATTRIBUTE_ARCHIVE;
  134. const DWORD_ FILE_ATTRIBUTE_DEVICE_ = FILE_ATTRIBUTE_DEVICE;
  135. const DWORD_ FILE_ATTRIBUTE_NORMAL_ = FILE_ATTRIBUTE_NORMAL;
  136. const DWORD_ FILE_ATTRIBUTE_TEMPORARY_ = FILE_ATTRIBUTE_TEMPORARY;
  137. const DWORD_ FILE_ATTRIBUTE_SPARSE_FILE_ = FILE_ATTRIBUTE_SPARSE_FILE;
  138. const DWORD_ FILE_ATTRIBUTE_REPARSE_POINT_ = FILE_ATTRIBUTE_REPARSE_POINT;
  139. const DWORD_ FILE_ATTRIBUTE_COMPRESSED_ = FILE_ATTRIBUTE_COMPRESSED;
  140. const DWORD_ FILE_ATTRIBUTE_OFFLINE_ = FILE_ATTRIBUTE_OFFLINE;
  141. const DWORD_ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_ = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED;
  142. const DWORD_ FILE_ATTRIBUTE_ENCRYPTED_ = FILE_ATTRIBUTE_ENCRYPTED;
  143. const DWORD_ CREATE_NEW_ = CREATE_NEW;
  144. const DWORD_ CREATE_ALWAYS_ = CREATE_ALWAYS;
  145. const DWORD_ OPEN_EXISTING_ = OPEN_EXISTING;
  146. const DWORD_ OPEN_ALWAYS_ = OPEN_ALWAYS;
  147. const DWORD_ TRUNCATE_EXISTING_ = TRUNCATE_EXISTING;
  148. const DWORD_ FILE_SHARE_READ_ = FILE_SHARE_READ;
  149. const DWORD_ FILE_SHARE_WRITE_ = FILE_SHARE_WRITE;
  150. const DWORD_ FILE_SHARE_DELETE_ = FILE_SHARE_DELETE;
  151. const DWORD_ FILE_BEGIN_ = FILE_BEGIN;
  152. const DWORD_ FILE_CURRENT_ = FILE_CURRENT;
  153. const DWORD_ FILE_END_ = FILE_END;
  154. #else // defined( BOOST_USE_WINDOWS_H )
  155. const DWORD_ INVALID_FILE_SIZE_ = ((DWORD_)0xFFFFFFFF);
  156. const DWORD_ INVALID_SET_FILE_POINTER_ = ((DWORD_)-1);
  157. const DWORD_ INVALID_FILE_ATTRIBUTES_ = ((DWORD_)-1);
  158. const DWORD_ FILE_ATTRIBUTE_READONLY_ = 0x00000001;
  159. const DWORD_ FILE_ATTRIBUTE_HIDDEN_ = 0x00000002;
  160. const DWORD_ FILE_ATTRIBUTE_SYSTEM_ = 0x00000004;
  161. const DWORD_ FILE_ATTRIBUTE_DIRECTORY_ = 0x00000010;
  162. const DWORD_ FILE_ATTRIBUTE_ARCHIVE_ = 0x00000020;
  163. const DWORD_ FILE_ATTRIBUTE_DEVICE_ = 0x00000040;
  164. const DWORD_ FILE_ATTRIBUTE_NORMAL_ = 0x00000080;
  165. const DWORD_ FILE_ATTRIBUTE_TEMPORARY_ = 0x00000100;
  166. const DWORD_ FILE_ATTRIBUTE_SPARSE_FILE_ = 0x00000200;
  167. const DWORD_ FILE_ATTRIBUTE_REPARSE_POINT_ = 0x00000400;
  168. const DWORD_ FILE_ATTRIBUTE_COMPRESSED_ = 0x00000800;
  169. const DWORD_ FILE_ATTRIBUTE_OFFLINE_ = 0x00001000;
  170. const DWORD_ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED_ = 0x00002000;
  171. const DWORD_ FILE_ATTRIBUTE_ENCRYPTED_ = 0x00004000;
  172. const DWORD_ CREATE_NEW_ = 1;
  173. const DWORD_ CREATE_ALWAYS_ = 2;
  174. const DWORD_ OPEN_EXISTING_ = 3;
  175. const DWORD_ OPEN_ALWAYS_ = 4;
  176. const DWORD_ TRUNCATE_EXISTING_ = 5;
  177. const DWORD_ FILE_SHARE_READ_ = 0x00000001;
  178. const DWORD_ FILE_SHARE_WRITE_ = 0x00000002;
  179. const DWORD_ FILE_SHARE_DELETE_ = 0x00000004;
  180. const DWORD_ FILE_BEGIN_ = 0;
  181. const DWORD_ FILE_CURRENT_ = 1;
  182. const DWORD_ FILE_END_ = 2;
  183. #endif // defined( BOOST_USE_WINDOWS_H )
  184. // This constant is not defined in Windows SDK up until 6.0A
  185. const DWORD_ FILE_ATTRIBUTE_VIRTUAL_ = 0x00010000;
  186. // These constants are not defined in Windows SDK up until 8.0 and MinGW/MinGW-w64 (as of 2016-02-14).
  187. // They are documented to be supported only since Windows 8/Windows Server 2012
  188. // but defined unconditionally.
  189. const DWORD_ FILE_ATTRIBUTE_INTEGRITY_STREAM_ = 0x00008000;
  190. const DWORD_ FILE_ATTRIBUTE_NO_SCRUB_DATA_ = 0x00020000;
  191. // Undocumented
  192. const DWORD_ FILE_ATTRIBUTE_EA_ = 0x00040000;
  193. #if !defined( BOOST_NO_ANSI_APIS )
  194. using ::DeleteFileA;
  195. using ::MoveFileExA;
  196. using ::GetFileAttributesA;
  197. using ::AreFileApisANSI;
  198. #endif
  199. using ::DeleteFileW;
  200. using ::MoveFileExW;
  201. using ::GetFileAttributesW;
  202. using ::FindClose;
  203. #if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WINXP
  204. using ::SetFileValidData;
  205. #endif
  206. using ::SetEndOfFile;
  207. using ::LockFile;
  208. using ::UnlockFile;
  209. using ::SetFilePointer;
  210. #if !defined( BOOST_NO_ANSI_APIS )
  211. BOOST_FORCEINLINE HANDLE_ CreateFileA(
  212. LPCSTR_ lpFileName,
  213. DWORD_ dwDesiredAccess,
  214. DWORD_ dwShareMode,
  215. SECURITY_ATTRIBUTES_* lpSecurityAttributes,
  216. DWORD_ dwCreationDisposition,
  217. DWORD_ dwFlagsAndAttributes,
  218. HANDLE_ hTemplateFile)
  219. {
  220. return ::CreateFileA(
  221. lpFileName,
  222. dwDesiredAccess,
  223. dwShareMode,
  224. reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes),
  225. dwCreationDisposition,
  226. dwFlagsAndAttributes,
  227. hTemplateFile);
  228. }
  229. typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _WIN32_FIND_DATAA {
  230. DWORD_ dwFileAttributes;
  231. FILETIME_ ftCreationTime;
  232. FILETIME_ ftLastAccessTime;
  233. FILETIME_ ftLastWriteTime;
  234. DWORD_ nFileSizeHigh;
  235. DWORD_ nFileSizeLow;
  236. DWORD_ dwReserved0;
  237. DWORD_ dwReserved1;
  238. CHAR_ cFileName[MAX_PATH_];
  239. CHAR_ cAlternateFileName[14];
  240. #ifdef _MAC
  241. DWORD_ dwFileType;
  242. DWORD_ dwCreatorType;
  243. WORD_ wFinderFlags;
  244. #endif
  245. } WIN32_FIND_DATAA_, *PWIN32_FIND_DATAA_, *LPWIN32_FIND_DATAA_;
  246. BOOST_FORCEINLINE HANDLE_ FindFirstFileA(LPCSTR_ lpFileName, WIN32_FIND_DATAA_* lpFindFileData)
  247. {
  248. return ::FindFirstFileA(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData));
  249. }
  250. BOOST_FORCEINLINE BOOL_ FindNextFileA(HANDLE_ hFindFile, WIN32_FIND_DATAA_* lpFindFileData)
  251. {
  252. return ::FindNextFileA(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData));
  253. }
  254. #endif
  255. BOOST_FORCEINLINE HANDLE_ CreateFileW(
  256. LPCWSTR_ lpFileName,
  257. DWORD_ dwDesiredAccess,
  258. DWORD_ dwShareMode,
  259. SECURITY_ATTRIBUTES_* lpSecurityAttributes,
  260. DWORD_ dwCreationDisposition,
  261. DWORD_ dwFlagsAndAttributes,
  262. HANDLE_ hTemplateFile)
  263. {
  264. return ::CreateFileW(
  265. lpFileName,
  266. dwDesiredAccess,
  267. dwShareMode,
  268. reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes),
  269. dwCreationDisposition,
  270. dwFlagsAndAttributes,
  271. hTemplateFile);
  272. }
  273. typedef struct BOOST_DETAIL_WINAPI_MAY_ALIAS _WIN32_FIND_DATAW {
  274. DWORD_ dwFileAttributes;
  275. FILETIME_ ftCreationTime;
  276. FILETIME_ ftLastAccessTime;
  277. FILETIME_ ftLastWriteTime;
  278. DWORD_ nFileSizeHigh;
  279. DWORD_ nFileSizeLow;
  280. DWORD_ dwReserved0;
  281. DWORD_ dwReserved1;
  282. WCHAR_ cFileName[MAX_PATH_];
  283. WCHAR_ cAlternateFileName[14];
  284. #ifdef _MAC
  285. DWORD_ dwFileType;
  286. DWORD_ dwCreatorType;
  287. WORD_ wFinderFlags;
  288. #endif
  289. } WIN32_FIND_DATAW_, *PWIN32_FIND_DATAW_, *LPWIN32_FIND_DATAW_;
  290. BOOST_FORCEINLINE HANDLE_ FindFirstFileW(LPCWSTR_ lpFileName, WIN32_FIND_DATAW_* lpFindFileData)
  291. {
  292. return ::FindFirstFileW(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData));
  293. }
  294. BOOST_FORCEINLINE BOOL_ FindNextFileW(HANDLE_ hFindFile, WIN32_FIND_DATAW_* lpFindFileData)
  295. {
  296. return ::FindNextFileW(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData));
  297. }
  298. BOOST_FORCEINLINE BOOL_ GetFileSizeEx(HANDLE_ hFile, LARGE_INTEGER_* lpFileSize)
  299. {
  300. return ::GetFileSizeEx(hFile, reinterpret_cast< ::_LARGE_INTEGER* >(lpFileSize));
  301. }
  302. BOOST_FORCEINLINE BOOL_ LockFileEx(
  303. HANDLE_ hFile,
  304. DWORD_ dwFlags,
  305. DWORD_ dwReserved,
  306. DWORD_ nNumberOfBytesToLockLow,
  307. DWORD_ nNumberOfBytesToLockHigh,
  308. OVERLAPPED_* lpOverlapped)
  309. {
  310. return ::LockFileEx(hFile, dwFlags, dwReserved, nNumberOfBytesToLockLow, nNumberOfBytesToLockHigh, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped));
  311. }
  312. BOOST_FORCEINLINE BOOL_ UnlockFileEx(
  313. HANDLE_ hFile,
  314. DWORD_ dwReserved,
  315. DWORD_ nNumberOfBytesToUnlockLow,
  316. DWORD_ nNumberOfBytesToUnlockHigh,
  317. OVERLAPPED_* lpOverlapped)
  318. {
  319. return ::UnlockFileEx(hFile, dwReserved, nNumberOfBytesToUnlockLow, nNumberOfBytesToUnlockHigh, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped));
  320. }
  321. BOOST_FORCEINLINE BOOL_ WriteFile(
  322. HANDLE_ hFile,
  323. LPCVOID_ lpBuffer,
  324. DWORD_ nNumberOfBytesToWrite,
  325. LPDWORD_ lpNumberOfBytesWritten,
  326. OVERLAPPED_* lpOverlapped)
  327. {
  328. return ::WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, reinterpret_cast< ::_OVERLAPPED* >(lpOverlapped));
  329. };
  330. #if !defined( BOOST_NO_ANSI_APIS )
  331. BOOST_FORCEINLINE HANDLE_ create_file(
  332. LPCSTR_ lpFileName,
  333. DWORD_ dwDesiredAccess,
  334. DWORD_ dwShareMode,
  335. SECURITY_ATTRIBUTES_* lpSecurityAttributes,
  336. DWORD_ dwCreationDisposition,
  337. DWORD_ dwFlagsAndAttributes,
  338. HANDLE_ hTemplateFile)
  339. {
  340. return ::CreateFileA(
  341. lpFileName,
  342. dwDesiredAccess,
  343. dwShareMode,
  344. reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes),
  345. dwCreationDisposition,
  346. dwFlagsAndAttributes,
  347. hTemplateFile);
  348. }
  349. BOOST_FORCEINLINE BOOL_ delete_file(LPCSTR_ lpFileName)
  350. {
  351. return ::DeleteFileA(lpFileName);
  352. }
  353. BOOST_FORCEINLINE HANDLE_ find_first_file(LPCSTR_ lpFileName, WIN32_FIND_DATAA_* lpFindFileData)
  354. {
  355. return ::FindFirstFileA(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData));
  356. }
  357. BOOST_FORCEINLINE BOOL_ find_next_file(HANDLE_ hFindFile, WIN32_FIND_DATAA_* lpFindFileData)
  358. {
  359. return ::FindNextFileA(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAA* >(lpFindFileData));
  360. }
  361. BOOST_FORCEINLINE BOOL_ move_file(LPCSTR_ lpExistingFileName, LPCSTR_ lpNewFileName, DWORD_ dwFlags)
  362. {
  363. return ::MoveFileExA(lpExistingFileName, lpNewFileName, dwFlags);
  364. }
  365. BOOST_FORCEINLINE DWORD_ get_file_attributes(LPCSTR_ lpFileName)
  366. {
  367. return ::GetFileAttributesA(lpFileName);
  368. }
  369. #endif
  370. BOOST_FORCEINLINE HANDLE_ create_file(
  371. LPCWSTR_ lpFileName,
  372. DWORD_ dwDesiredAccess,
  373. DWORD_ dwShareMode,
  374. SECURITY_ATTRIBUTES_* lpSecurityAttributes,
  375. DWORD_ dwCreationDisposition,
  376. DWORD_ dwFlagsAndAttributes,
  377. HANDLE_ hTemplateFile)
  378. {
  379. return ::CreateFileW(
  380. lpFileName,
  381. dwDesiredAccess,
  382. dwShareMode,
  383. reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(lpSecurityAttributes),
  384. dwCreationDisposition,
  385. dwFlagsAndAttributes,
  386. hTemplateFile);
  387. }
  388. BOOST_FORCEINLINE BOOL_ delete_file(LPCWSTR_ lpFileName)
  389. {
  390. return ::DeleteFileW(lpFileName);
  391. }
  392. BOOST_FORCEINLINE HANDLE_ find_first_file(LPCWSTR_ lpFileName, WIN32_FIND_DATAW_* lpFindFileData)
  393. {
  394. return ::FindFirstFileW(lpFileName, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData));
  395. }
  396. BOOST_FORCEINLINE BOOL_ find_next_file(HANDLE_ hFindFile, WIN32_FIND_DATAW_* lpFindFileData)
  397. {
  398. return ::FindNextFileW(hFindFile, reinterpret_cast< ::_WIN32_FIND_DATAW* >(lpFindFileData));
  399. }
  400. BOOST_FORCEINLINE BOOL_ move_file(LPCWSTR_ lpExistingFileName, LPCWSTR_ lpNewFileName, DWORD_ dwFlags)
  401. {
  402. return ::MoveFileExW(lpExistingFileName, lpNewFileName, dwFlags);
  403. }
  404. BOOST_FORCEINLINE DWORD_ get_file_attributes(LPCWSTR_ lpFileName)
  405. {
  406. return ::GetFileAttributesW(lpFileName);
  407. }
  408. }
  409. }
  410. }
  411. #endif // BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP