file_management.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // thread.hpp --------------------------------------------------------------//
  2. // Copyright 2010 Vicente J. Botet Escriba
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // See http://www.boost.org/LICENSE_1_0.txt
  5. #ifndef BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP
  6. #define BOOST_DETAIL_WINAPI_FILE_MANAGEMENT_HPP
  7. #include <boost/detail/winapi/basic_types.hpp>
  8. #include <boost/detail/winapi/security.hpp>
  9. #ifdef BOOST_HAS_PRAGMA_ONCE
  10. #pragma once
  11. #endif
  12. namespace boost
  13. {
  14. namespace detail
  15. {
  16. namespace winapi
  17. {
  18. #if defined( BOOST_USE_WINDOWS_H )
  19. using ::CreateFileA;
  20. using ::DeleteFileA;
  21. using ::FindFirstFileA;
  22. using ::FindNextFileA;
  23. using ::FindClose;
  24. using ::GetFileSizeEx;
  25. using ::MoveFileExA;
  26. using ::SetFileValidData;
  27. #else
  28. extern "C" {
  29. typedef struct _OVERLAPPED {
  30. ULONG_PTR Internal;
  31. ULONG_PTR InternalHigh;
  32. union {
  33. struct {
  34. DWORD Offset;
  35. DWORD OffsetHigh;
  36. } ;
  37. PVOID Pointer;
  38. } ;
  39. HANDLE hEvent;
  40. } OVERLAPPED, *LPOVERLAPPED;
  41. __declspec(dllimport) void * __stdcall
  42. CreateFileA (const char *, unsigned long, unsigned long, struct SECURITY_ATTRIBUTES_*, unsigned long, unsigned long, void *);
  43. __declspec(dllimport) int __stdcall
  44. DeleteFileA (const char *);
  45. __declspec(dllimport) void *__stdcall
  46. FindFirstFileA(const char *lpFileName, win32_find_data_t *lpFindFileData);
  47. __declspec(dllimport) int __stdcall
  48. FindNextFileA(void *hFindFile, win32_find_data_t *lpFindFileData);
  49. __declspec(dllimport) int __stdcall
  50. FindClose(void *hFindFile);
  51. __declspec(dllimport) BOOL __stdcall
  52. GetFileSizeEx(
  53. HANDLE_ hFile,
  54. PLARGE_INTEGER_ lpFileSize
  55. );
  56. __declspec(dllimport) int __stdcall
  57. MoveFileExA (const char *, const char *, unsigned long);
  58. __declspec(dllimport) BOOL_ __stdcall
  59. SetFileValidData(
  60. HANDLE_ hFile,
  61. LONGLONG_ ValidDataLength
  62. );
  63. __declspec(dllimport) BOOL_ __stdcall
  64. SetEndOfFile(
  65. HANDLE_ hFile
  66. );
  67. __declspec(dllimport) BOOL_ __stdcall
  68. SetFilePointerEx(
  69. HANDLE_ hFile,
  70. LARGE_INTEGER_ liDistanceToMove,
  71. PLARGE_INTEGER_ lpNewFilePointer,
  72. DWORD_ dwMoveMethod
  73. );
  74. __declspec(dllimport) BOOL_ __stdcall
  75. LockFile(
  76. HANDLE_ hFile,
  77. DWORD_ dwFileOffsetLow,
  78. DWORD_ dwFileOffsetHigh,
  79. DWORD_ nNumberOfBytesToLockLow,
  80. DWORD_ nNumberOfBytesToLockHigh
  81. );
  82. __declspec(dllimport) BOOL_ __stdcall
  83. UnlockFile(
  84. HANDLE_ hFile,
  85. DWORD_ dwFileOffsetLow,
  86. DWORD_ dwFileOffsetHigh,
  87. DWORD_ nNumberOfBytesToUnlockLow,
  88. DWORD_ nNumberOfBytesToUnlockHigh
  89. );
  90. __declspec(dllimport) BOOL_ __stdcall
  91. LockFileEx(
  92. HANDLE_ hFile,
  93. DWORD_ dwFlags,
  94. DWORD_ dwReserved,
  95. DWORD_ nNumberOfBytesToLockLow,
  96. DWORD_ nNumberOfBytesToLockHigh,
  97. LPOVERLAPPED_ lpOverlapped
  98. );
  99. __declspec(dllimport) BOOL_ __stdcall
  100. UnlockFileEx(
  101. HANDLE_ hFile,
  102. DWORD_ dwReserved,
  103. DWORD_ nNumberOfBytesToUnlockLow,
  104. DWORD_ nNumberOfBytesToUnlockHigh,
  105. LPOVERLAPPED_ lpOverlapped
  106. );
  107. __declspec(dllimport) BOOL_ __stdcall
  108. WriteFile(
  109. HANDLE_ hFile,
  110. LPCVOID_ lpBuffer,
  111. DWORD_ nNumberOfBytesToWrite,
  112. LPDWORD_ lpNumberOfBytesWritten,
  113. LPOVERLAPPED_ lpOverlapped
  114. );
  115. }
  116. #endif
  117. }
  118. }
  119. }
  120. #endif // BOOST_DETAIL_WINAPI_THREAD_HPP