Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

315 lines
6.6 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. basefile.c
  5. Abstract:
  6. Contains simple wrappers for commonly used file i/o functions.
  7. Author:
  8. Marc R. Whitten (marcw) 02-Sep-1999
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. #define INVALID_ATTRIBUTES 0xFFFFFFFF
  13. BOOL
  14. DoesFileExistExA (
  15. IN PCSTR Path,
  16. OUT PWIN32_FIND_DATAA FindData OPTIONAL
  17. );
  18. #define DoesFileExistA(x) DoesFileExistExA (x, NULL)
  19. BOOL
  20. DoesFileExistExW (
  21. IN PCWSTR Path,
  22. OUT PWIN32_FIND_DATAW FindData OPTIONAL
  23. );
  24. #define DoesFileExistW(x) DoesFileExistExW (x, NULL)
  25. BOOL
  26. BfPathIsDirectoryA (
  27. IN PCSTR PathSpec
  28. );
  29. BOOL
  30. BfPathIsDirectoryW (
  31. IN PCWSTR PathSpec
  32. );
  33. BOOL
  34. WriteFileStringA (
  35. IN HANDLE File,
  36. IN PCSTR String
  37. );
  38. BOOL
  39. WriteFileStringW (
  40. IN HANDLE File,
  41. IN PCWSTR String
  42. );
  43. PVOID
  44. MapFileIntoMemoryExA (
  45. IN PCSTR FileName,
  46. OUT PHANDLE FileHandle,
  47. OUT PHANDLE MapHandle,
  48. IN BOOL WriteAccess
  49. );
  50. PVOID
  51. MapFileIntoMemoryExW (
  52. IN PCWSTR FileName,
  53. OUT PHANDLE FileHandle,
  54. OUT PHANDLE MapHandle,
  55. IN BOOL WriteAccess
  56. );
  57. #define MapFileIntoMemoryA(FileName,FileHandle,MapHandle) MapFileIntoMemoryExA(FileName,FileHandle,MapHandle,FALSE)
  58. #define MapFileIntoMemoryW(FileName,FileHandle,MapHandle) MapFileIntoMemoryExW(FileName,FileHandle,MapHandle,FALSE)
  59. BOOL
  60. UnmapFile (
  61. IN PCVOID FileImage,
  62. IN HANDLE MapHandle,
  63. IN HANDLE FileHandle
  64. );
  65. BOOL
  66. BfGetTempFileNameExA (
  67. OUT PSTR Buffer,
  68. IN UINT BufferTchars,
  69. IN PCSTR Prefix
  70. );
  71. #define BfGetTempFileNameA(b,c) BfGetTempFileNameExA(b,c,"temp")
  72. BOOL
  73. BfGetTempFileNameExW (
  74. OUT PWSTR Buffer,
  75. IN UINT BufferTchars,
  76. IN PCWSTR Prefix
  77. );
  78. #define BfGetTempFileNameW(b,c) BfGetTempFileNameExW(b,c,L"temp")
  79. BOOL
  80. BfGetTempDirectoryExA (
  81. OUT PSTR Buffer,
  82. IN UINT BufferTchars,
  83. IN PCSTR Prefix
  84. );
  85. #define BfGetTempDirectoryA(b,c) BfGetTempDirectoryExA(b,c,"dir")
  86. BOOL
  87. BfGetTempDirectoryExW (
  88. OUT PWSTR Buffer,
  89. IN UINT BufferTchars,
  90. IN PCWSTR Prefix
  91. );
  92. #define BfGetTempDirectoryW(b,c) BfGetTempDirectoryExW(b,c,L"dir")
  93. HANDLE
  94. BfGetTempFile (
  95. VOID
  96. );
  97. BOOL
  98. BfSetFilePointer (
  99. IN HANDLE File,
  100. IN LONGLONG Offset
  101. );
  102. HANDLE
  103. BfOpenReadFileA (
  104. IN PCSTR FileName
  105. );
  106. HANDLE
  107. BfOpenReadFileW (
  108. IN PCWSTR FileName
  109. );
  110. HANDLE
  111. BfOpenFileA (
  112. IN PCSTR FileName
  113. );
  114. HANDLE
  115. BfOpenFileW (
  116. IN PCWSTR FileName
  117. );
  118. HANDLE
  119. BfCreateFileA (
  120. IN PCSTR FileName
  121. );
  122. HANDLE
  123. BfCreateFileW (
  124. IN PCWSTR FileName
  125. );
  126. HANDLE
  127. BfCreateSharedFileA (
  128. IN PCSTR FileName
  129. );
  130. HANDLE
  131. BfCreateSharedFileW (
  132. IN PCWSTR FileName
  133. );
  134. BOOL
  135. BfSetSizeOfFile (
  136. HANDLE File,
  137. LONGLONG Size
  138. );
  139. BOOL
  140. BfGoToEndOfFile (
  141. IN HANDLE File,
  142. OUT PLONGLONG FileSize OPTIONAL
  143. );
  144. BOOL
  145. BfGetFilePointer (
  146. IN HANDLE File,
  147. OUT PLONGLONG FilePointer OPTIONAL
  148. );
  149. BOOL
  150. BfReadFile (
  151. IN HANDLE File,
  152. OUT PBYTE Buffer,
  153. IN UINT BytesToRead
  154. );
  155. BOOL
  156. BfWriteFile (
  157. IN HANDLE File,
  158. OUT PCBYTE Buffer,
  159. IN UINT BytesToWrite
  160. );
  161. BOOL
  162. BfCreateDirectoryExA (
  163. IN PCSTR FullPath,
  164. IN BOOL CreateLastSegment
  165. );
  166. #define BfCreateDirectoryA(d) BfCreateDirectoryExA(d,TRUE)
  167. BOOL
  168. BfCreateDirectoryExW (
  169. IN PCWSTR FullPath,
  170. IN BOOL CreateLastSegment
  171. );
  172. #define BfCreateDirectoryW(d) BfCreateDirectoryExW(d,TRUE)
  173. LONGLONG
  174. BfGetFileSizeA (
  175. IN PCSTR FileName
  176. );
  177. LONGLONG
  178. BfGetFileSizeW (
  179. IN PCWSTR FileName
  180. );
  181. PCSTR
  182. BfGetLongFileNameA (
  183. IN PCSTR SrcFileName
  184. );
  185. BOOL
  186. BfGetLongFileNameExA (
  187. IN PCSTR SrcFileName,
  188. IN PGROWBUFFER GrowBuff
  189. );
  190. PCWSTR
  191. BfGetLongFileNameW (
  192. IN PCWSTR SrcFileName
  193. );
  194. BOOL
  195. BfGetLongFileNameExW (
  196. IN PCWSTR SrcFileName,
  197. IN PGROWBUFFER GrowBuff
  198. );
  199. BOOL
  200. BfCopyAndFlushFileA (
  201. IN PCSTR SrcFileName,
  202. IN PCSTR DestFileName,
  203. IN BOOL FailIfExists
  204. );
  205. BOOL
  206. BfCopyAndFlushFileW (
  207. IN PCWSTR SrcFileName,
  208. IN PCWSTR DestFileName,
  209. IN BOOL FailIfExists
  210. );
  211. #ifdef UNICODE
  212. #define DoesFileExist DoesFileExistW
  213. #define DoesFileExistEx DoesFileExistExW
  214. #define BfPathIsDirectory BfPathIsDirectoryW
  215. #define WriteFileString WriteFileStringW
  216. #define MapFileIntoMemory MapFileIntoMemoryW
  217. #define MapFileIntoMemoryEx MapFileIntoMemoryExW
  218. #define BfGetTempFileName BfGetTempFileNameW
  219. #define BfGetTempFileNameEx BfGetTempFileNameExW
  220. #define BfGetTempDirectory BfGetTempDirectoryW
  221. #define BfGetTempDirectoryEx BfGetTempDirectoryExW
  222. #define BfOpenReadFile BfOpenReadFileW
  223. #define BfOpenFile BfOpenFileW
  224. #define BfCreateFile BfCreateFileW
  225. #define BfCreateSharedFile BfCreateSharedFileW
  226. #define BfCreateDirectoryEx BfCreateDirectoryExW
  227. #define BfCreateDirectory BfCreateDirectoryW
  228. #define BfGetFileSize BfGetFileSizeW
  229. #define BfGetLongFileName BfGetLongFileNameW
  230. #define BfGetLongFileNameEx BfGetLongFileNameExW
  231. #define BfCopyAndFlushFile BfCopyAndFlushFileW
  232. #else
  233. #define DoesFileExist DoesFileExistA
  234. #define DoesFileExistEx DoesFileExistExA
  235. #define BfPathIsDirectory BfPathIsDirectoryA
  236. #define WriteFileString WriteFileStringA
  237. #define MapFileIntoMemory MapFileIntoMemoryA
  238. #define MapFileIntoMemoryEx MapFileIntoMemoryExA
  239. #define BfGetTempFileName BfGetTempFileNameA
  240. #define BfGetTempFileNameEx BfGetTempFileNameExA
  241. #define BfGetTempDirectory BfGetTempDirectoryA
  242. #define BfGetTempDirectoryEx BfGetTempDirectoryExA
  243. #define BfOpenReadFile BfOpenReadFileA
  244. #define BfOpenFile BfOpenFileA
  245. #define BfCreateFile BfCreateFileA
  246. #define BfCreateSharedFile BfCreateSharedFileA
  247. #define BfCreateDirectoryEx BfCreateDirectoryExA
  248. #define BfCreateDirectory BfCreateDirectoryA
  249. #define BfGetFileSize BfGetFileSizeA
  250. #define BfGetLongFileName BfGetLongFileNameA
  251. #define BfGetLongFileNameEx BfGetLongFileNameExA
  252. #define BfCopyAndFlushFile BfCopyAndFlushFileA
  253. #endif