]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Library/FileHandleLib.h
Fix several Unicode issues that fails VS2005.
[mirror_edk2.git] / ShellPkg / Include / Library / FileHandleLib.h
CommitLineData
d2b4564b 1/** @file\r
2 Provides interface to EFI_FILE_HANDLE functionality.\r
3\r
4Copyright (c) 2006 - 2009, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <Uefi.h>\r
16#include <Library/UefiBootServicesTableLib.h>\r
17#include <Library/BaseLib.h>\r
18#include <Library/BaseMemoryLib.h>\r
19#include <Library/DebugLib.h>\r
20#include <Library/MemoryAllocationLib.h>\r
21\r
22/**\r
23 This function will retrieve the information about the file for the handle \r
24 specified and store it in allocated pool memory.\r
25\r
69817bf8 26 This function allocates a buffer to store the file's information. It is the \r
27 caller's responsibility to free the buffer\r
d2b4564b 28\r
29 @param FileHandle The file handle of the file for which information is \r
30 being requested.\r
31\r
32 @retval NULL information could not be retrieved.\r
33\r
34 @return the information about the file\r
35**/\r
36EFI_FILE_INFO*\r
37EFIAPI\r
38FileHandleGetInfo (\r
39 IN EFI_FILE_HANDLE FileHandle\r
40 );\r
41\r
42/**\r
43 This function will set the information about the file for the opened handle \r
44 specified.\r
45\r
46 @param FileHandle The file handle of the file for which information \r
47 is being set\r
48\r
49 @param FileInfo The infotmation to set.\r
50\r
51 @retval EFI_SUCCESS The information was set.\r
52 @retval EFI_UNSUPPORTED The InformationType is not known.\r
53 @retval EFI_NO_MEDIA The device has no medium.\r
54 @retval EFI_DEVICE_ERROR The device reported an error.\r
55 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
56 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
57 @retval EFI_ACCESS_DENIED The file was opened read only.\r
58 @retval EFI_VOLUME_FULL The volume is full.\r
59**/\r
60EFI_STATUS\r
61EFIAPI\r
62FileHandleSetInfo (\r
63 IN EFI_FILE_HANDLE FileHandle,\r
64 IN CONST EFI_FILE_INFO *FileInfo\r
65 );\r
66\r
67/**\r
68 This function reads information from an opened file.\r
69\r
70 If FileHandle is not a directory, the function reads the requested number of \r
69817bf8 71 bytes from the file at the file's current position and returns them in Buffer. \r
d2b4564b 72 If the read goes beyond the end of the file, the read length is truncated to the\r
69817bf8 73 end of the file. The file's current position is increased by the number of bytes \r
d2b4564b 74 returned. If FileHandle is a directory, the function reads the directory entry \r
69817bf8 75 at the file's current position and returns the entry in Buffer. If the Buffer \r
d2b4564b 76 is not large enough to hold the current directory entry, then \r
77 EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated. \r
78 BufferSize is set to be the size of the buffer needed to read the entry. On \r
79 success, the current position is updated to the next directory entry. If there \r
80 are no more directory entries, the read returns a zero-length buffer. \r
81 EFI_FILE_INFO is the structure returned as the directory entry.\r
82\r
83 @param FileHandle the opened file handle\r
84 @param BufferSize on input the size of buffer in bytes. on return \r
85 the number of bytes written.\r
86 @param Buffer the buffer to put read data into.\r
87\r
88 @retval EFI_SUCCESS Data was read.\r
89 @retval EFI_NO_MEDIA The device has no media.\r
90 @retval EFI_DEVICE_ERROR The device reported an error.\r
91 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
92 @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required \r
93 size.\r
94\r
95**/\r
96EFI_STATUS\r
97EFIAPI\r
98FileHandleRead(\r
99 IN EFI_FILE_HANDLE FileHandle,\r
100 IN OUT UINTN *BufferSize,\r
101 OUT VOID *Buffer\r
102 );\r
103\r
104/**\r
105 Write data to a file.\r
106\r
107 This function writes the specified number of bytes to the file at the current \r
108 file position. The current file position is advanced the actual number of bytes \r
109 written, which is returned in BufferSize. Partial writes only occur when there \r
69817bf8 110 has been a data error during the write attempt (such as "volume space full"). \r
d2b4564b 111 The file is automatically grown to hold the data if required. Direct writes to \r
112 opened directories are not supported.\r
113\r
114 @param FileHandle The opened file for writing\r
115 @param BufferSize on input the number of bytes in Buffer. On output\r
116 the number of bytes written.\r
117 @param Buffer the buffer containing data to write is stored.\r
118\r
119 @retval EFI_SUCCESS Data was written.\r
120 @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r
121 @retval EFI_NO_MEDIA The device has no media.\r
122 @retval EFI_DEVICE_ERROR The device reported an error.\r
123 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
124 @retval EFI_WRITE_PROTECTED The device is write-protected.\r
125 @retval EFI_ACCESS_DENIED The file was open for read only.\r
126 @retval EFI_VOLUME_FULL The volume is full.\r
127**/\r
128EFI_STATUS\r
129EFIAPI\r
130FileHandleWrite(\r
131 IN EFI_FILE_HANDLE FileHandle,\r
132 IN OUT UINTN *BufferSize,\r
133 IN VOID *Buffer\r
134 );\r
135\r
136/** \r
137 Close an open file handle.\r
138\r
69817bf8 139 This function closes a specified file handle. All "dirty" cached file data is \r
d2b4564b 140 flushed to the device, and the file is closed. In all cases the handle is \r
141 closed.\r
142\r
143@param FileHandle the file handle to close.\r
144\r
145@retval EFI_SUCCESS the file handle was closed sucessfully.\r
146**/\r
147EFI_STATUS\r
148EFIAPI\r
149FileHandleClose (\r
150 IN EFI_FILE_HANDLE FileHandle\r
151 );\r
152\r
153/**\r
154 Delete a file and close the handle\r
155\r
156 This function closes and deletes a file. In all cases the file handle is closed.\r
157 If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is \r
158 returned, but the handle is still closed.\r
159\r
160 @param FileHandle the file handle to delete\r
161\r
162 @retval EFI_SUCCESS the file was closed sucessfully\r
163 @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not \r
164 deleted\r
165 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
166**/\r
167EFI_STATUS\r
168EFIAPI\r
169FileHandleDelete (\r
170 IN EFI_FILE_HANDLE FileHandle\r
171 );\r
172\r
173/**\r
174 Set the current position in a file.\r
175\r
176 This function sets the current file position for the handle to the position \r
177 supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r
178 absolute positioning is supported, and seeking past the end of the file is \r
179 allowed (a subsequent write would grow the file). Seeking to position \r
180 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
181 If FileHandle is a directory, the only position that may be set is zero. This \r
182 has the effect of starting the read process of the directory entries over.\r
183\r
184 @param FileHandle The file handle on which the position is being set\r
185 @param Position Byte position from begining of file\r
186\r
187 @retval EFI_SUCCESS Operation completed sucessfully.\r
188 @retval EFI_UNSUPPORTED the seek request for non-zero is not valid on \r
189 directories.\r
190 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
191**/\r
192EFI_STATUS\r
193EFIAPI\r
194FileHandleSetPosition (\r
195 IN EFI_FILE_HANDLE FileHandle,\r
196 IN UINT64 Position\r
197 );\r
198\r
199/** \r
200 Gets a file's current position\r
201\r
202 This function retrieves the current file position for the file handle. For \r
203 directories, the current file position has no meaning outside of the file \r
204 system driver and as such the operation is not supported. An error is returned\r
205 if FileHandle is a directory.\r
206\r
207 @param FileHandle The open file handle on which to get the position.\r
208 @param Position Byte position from begining of file.\r
209\r
210 @retval EFI_SUCCESS the operation completed sucessfully.\r
211 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
212 @retval EFI_UNSUPPORTED the request is not valid on directories.\r
213**/\r
214EFI_STATUS\r
215EFIAPI\r
216FileHandleGetPosition (\r
217 IN EFI_FILE_HANDLE FileHandle,\r
218 OUT UINT64 *Position\r
219 );\r
220/**\r
221 Flushes data on a file\r
222 \r
223 This function flushes all modified data associated with a file to a device.\r
224\r
225 @param FileHandle The file handle on which to flush data\r
226\r
227 @retval EFI_SUCCESS The data was flushed.\r
228 @retval EFI_NO_MEDIA The device has no media.\r
229 @retval EFI_DEVICE_ERROR The device reported an error.\r
230 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
231 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
232 @retval EFI_ACCESS_DENIED The file was opened for read only.\r
233**/\r
234EFI_STATUS\r
235EFIAPI\r
236FileHandleFlush (\r
237 IN EFI_FILE_HANDLE FileHandle\r
238 );\r
239\r
240/**\r
241 function to determine if a given handle is a directory handle\r
242\r
243 if DirHandle is NULL then ASSERT()\r
244\r
245 open the file information on the DirHandle and verify that the Attribute\r
246 includes EFI_FILE_DIRECTORY bit set.\r
247\r
248 @param DirHandle Handle to open file\r
249\r
250 @retval EFI_SUCCESS DirHandle is a directory\r
251 @retval EFI_INVALID_PARAMETER DirHandle did not have EFI_FILE_INFO available\r
252 @retval EFI_NOT_FOUND DirHandle is not a directory\r
253**/\r
254EFI_STATUS\r
255EFIAPI\r
256FileHandleIsDirectory (\r
257 IN EFI_FILE_HANDLE DirHandle\r
258 );\r
259\r
260/**\r
261 Retrieves the first file from a directory\r
262\r
69817bf8 263 This function opens a directory and gets the first file's info in the \r
d2b4564b 264 directory. Caller can use FileHandleFindNextFile() to get other files. When \r
265 complete the caller is responsible for calling FreePool() on *Buffer.\r
266\r
267 @param DirHandle The file handle of the directory to search\r
268 @param Buffer Pointer to pointer to buffer for file's information\r
269\r
270 @retval EFI_SUCCESS Found the first file.\r
271 @retval EFI_NOT_FOUND Cannot find the directory.\r
272 @retval EFI_NO_MEDIA The device has no media.\r
273 @retval EFI_DEVICE_ERROR The device reported an error.\r
274 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
275 @return Others status of FileHandleGetInfo, FileHandleSetPosition,\r
276 or FileHandleRead\r
277**/\r
278EFI_STATUS\r
279EFIAPI\r
280FileHandleFindFirstFile (\r
281 IN EFI_FILE_HANDLE DirHandle,\r
282 OUT EFI_FILE_INFO **Buffer\r
283 );\r
284/**\r
285 Retrieves the next file in a directory.\r
286\r
287 To use this function, caller must call the FileHandleFindFirstFile() to get the \r
288 first file, and then use this function get other files. This function can be \r
289 called for several times to get each file's information in the directory. If \r
290 the call of FileHandleFindNextFile() got the last file in the directory, the next \r
291 call of this function has no file to get. *NoFile will be set to TRUE and the \r
292 Buffer memory will be automatically freed. \r
293\r
294 @param DirHandle the file handle of the directory\r
295 @param Buffer pointer to buffer for file's information\r
296 @param NoFile pointer to boolean when last file is found\r
297\r
298 @retval EFI_SUCCESS Found the next file, or reached last file\r
299 @retval EFI_NO_MEDIA The device has no media.\r
300 @retval EFI_DEVICE_ERROR The device reported an error.\r
301 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
302**/\r
303EFI_STATUS\r
304EFIAPI\r
305FileHandleFindNextFile(\r
306 IN EFI_FILE_HANDLE DirHandle,\r
307 OUT EFI_FILE_INFO *Buffer,\r
308 OUT BOOLEAN *NoFile\r
309 );\r
310\r
311/**\r
312 Retrieve the size of a file.\r
313\r
314 if FileHandle is NULL then ASSERT()\r
315 if Size is NULL then ASSERT()\r
316\r
69817bf8 317 This function extracts the file size info from the FileHandle's EFI_FILE_INFO \r
d2b4564b 318 data.\r
319\r
320 @param FileHandle file handle from which size is retrieved\r
321 @param Size pointer to size\r
322\r
323 @retval EFI_SUCCESS operation was completed sucessfully\r
324 @retval EFI_DEVICE_ERROR cannot access the file\r
325**/\r
326EFI_STATUS\r
327EFIAPI\r
328FileHandleGetSize (\r
329 IN EFI_FILE_HANDLE FileHandle,\r
330 OUT UINT64 *Size\r
331 );