]>
Commit | Line | Data |
---|---|---|
94b17fa1 | 1 | /** @file\r |
2 | Provides interface to shell functionality for shell commands and applications.\r | |
3 | \r | |
fbd2dfad | 4 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r |
1e6e84c7 | 5 | This program and the accompanying materials\r |
b3011f40 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
94b17fa1 | 9 | \r |
b3011f40 | 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
94b17fa1 | 12 | \r |
13 | **/\r | |
14 | \r | |
a405b86d | 15 | #ifndef __SHELL_LIB__\r |
94b17fa1 | 16 | #define __SHELL_LIB__\r |
17 | \r | |
b3011f40 | 18 | #include <Uefi.h>\r |
19 | #include <Guid/FileInfo.h>\r | |
94b17fa1 | 20 | #include <Protocol/SimpleFileSystem.h>\r |
b3011f40 | 21 | #include <Protocol/LoadedImage.h>\r |
22 | #include <Protocol/EfiShellInterface.h>\r | |
23 | #include <Protocol/EfiShellEnvironment2.h>\r | |
94b17fa1 | 24 | #include <Protocol/EfiShell.h>\r |
b3011f40 | 25 | #include <Protocol/EfiShellParameters.h>\r |
94b17fa1 | 26 | \r |
a405b86d | 27 | // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)\r |
28 | #define MAX_FILE_NAME_LEN 512\r | |
29 | \r | |
366f81a0 | 30 | extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;\r |
31 | extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;\r | |
a405b86d | 32 | \r |
94b17fa1 | 33 | /**\r |
1e6e84c7 | 34 | This function will retrieve the information about the file for the handle\r |
94b17fa1 | 35 | specified and store it in allocated pool memory.\r |
36 | \r | |
1e6e84c7 | 37 | This function allocates a buffer to store the file's information. It is the\r |
18cefebe | 38 | caller's responsibility to free the buffer.\r |
94b17fa1 | 39 | \r |
1e6e84c7 | 40 | @param[in] FileHandle The file handle of the file for which information is\r |
18cefebe | 41 | being requested.\r |
94b17fa1 | 42 | \r |
18cefebe | 43 | @retval NULL Information could not be retrieved.\r |
94b17fa1 | 44 | \r |
18cefebe | 45 | @return The information about the file.\r |
94b17fa1 | 46 | **/\r |
47 | EFI_FILE_INFO*\r | |
48 | EFIAPI\r | |
49 | ShellGetFileInfo (\r | |
a405b86d | 50 | IN SHELL_FILE_HANDLE FileHandle\r |
94b17fa1 | 51 | );\r |
52 | \r | |
53 | /**\r | |
a405b86d | 54 | This function sets the information about the file for the opened handle\r |
94b17fa1 | 55 | specified.\r |
56 | \r | |
1e6e84c7 | 57 | @param[in] FileHandle The file handle of the file for which information\r |
a5bd42b9 | 58 | is being set.\r |
94b17fa1 | 59 | \r |
a405b86d | 60 | @param[in] FileInfo The information to set.\r |
94b17fa1 | 61 | \r |
b0934ac4 | 62 | @retval EFI_SUCCESS The information was set.\r |
a405b86d | 63 | @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.\r |
64 | @retval EFI_UNSUPPORTED The FileHandle does not support FileInfo.\r | |
b0934ac4 | 65 | @retval EFI_NO_MEDIA The device has no medium.\r |
66 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
67 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
68 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r | |
a405b86d | 69 | @retval EFI_ACCESS_DENIED The file was opened read only.\r |
70 | @retval EFI_VOLUME_FULL The volume is full.\r | |
94b17fa1 | 71 | **/\r |
72 | EFI_STATUS\r | |
73 | EFIAPI\r | |
74 | ShellSetFileInfo (\r | |
b0934ac4 | 75 | IN SHELL_FILE_HANDLE FileHandle,\r |
94b17fa1 | 76 | IN EFI_FILE_INFO *FileInfo\r |
77 | );\r | |
78 | \r | |
79 | /**\r | |
80 | This function will open a file or directory referenced by DevicePath.\r | |
81 | \r | |
1e6e84c7 | 82 | This function opens a file with the open mode according to the file path. The\r |
94b17fa1 | 83 | Attributes is valid only for EFI_FILE_MODE_CREATE.\r |
84 | \r | |
4ff7e37b ED |
85 | @param[in, out] FilePath On input, the device path to the file. On output,\r |
86 | the remaining device path.\r | |
87 | @param[out] DeviceHandle Pointer to the system device handle.\r | |
88 | @param[out] FileHandle Pointer to the file handle.\r | |
89 | @param[in] OpenMode The mode to open the file with.\r | |
90 | @param[in] Attributes The file's file attributes.\r | |
94b17fa1 | 91 | \r |
b0934ac4 | 92 | @retval EFI_SUCCESS The information was set.\r |
93 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
a405b86d | 94 | @retval EFI_UNSUPPORTED Could not open the file path.\r |
b0934ac4 | 95 | @retval EFI_NOT_FOUND The specified file could not be found on the\r |
1e6e84c7 | 96 | device or the file system could not be found on\r |
94b17fa1 | 97 | the device.\r |
a405b86d | 98 | @retval EFI_NO_MEDIA The device has no medium.\r |
99 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r | |
94b17fa1 | 100 | medium is no longer supported.\r |
a405b86d | 101 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
b0934ac4 | 102 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
a405b86d | 103 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
104 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
b0934ac4 | 105 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r |
94b17fa1 | 106 | file.\r |
a405b86d | 107 | @retval EFI_VOLUME_FULL The volume is full.\r |
94b17fa1 | 108 | **/\r |
109 | EFI_STATUS\r | |
110 | EFIAPI\r | |
111 | ShellOpenFileByDevicePath(\r | |
b0934ac4 | 112 | IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r |
113 | OUT EFI_HANDLE *DeviceHandle,\r | |
114 | OUT SHELL_FILE_HANDLE *FileHandle,\r | |
115 | IN UINT64 OpenMode,\r | |
116 | IN UINT64 Attributes\r | |
94b17fa1 | 117 | );\r |
118 | \r | |
119 | /**\r | |
120 | This function will open a file or directory referenced by filename.\r | |
121 | \r | |
1e6e84c7 | 122 | If return is EFI_SUCCESS, the Filehandle is the opened file's handle;\r |
a405b86d | 123 | otherwise, the Filehandle is NULL. Attributes is valid only for\r |
94b17fa1 | 124 | EFI_FILE_MODE_CREATE.\r |
125 | \r | |
a405b86d | 126 | @param[in] FilePath The pointer to file name.\r |
127 | @param[out] FileHandle The pointer to the file handle.\r | |
128 | @param[in] OpenMode The mode to open the file with.\r | |
129 | @param[in] Attributes The file's file attributes.\r | |
94b17fa1 | 130 | \r |
b0934ac4 | 131 | @retval EFI_SUCCESS The information was set.\r |
132 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
a405b86d | 133 | @retval EFI_UNSUPPORTED Could not open the file path.\r |
b0934ac4 | 134 | @retval EFI_NOT_FOUND The specified file could not be found on the\r |
1e6e84c7 | 135 | device or the file system could not be found\r |
94b17fa1 | 136 | on the device.\r |
a405b86d | 137 | @retval EFI_NO_MEDIA The device has no medium.\r |
138 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r | |
94b17fa1 | 139 | medium is no longer supported.\r |
a405b86d | 140 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
b0934ac4 | 141 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
a405b86d | 142 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
143 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
b0934ac4 | 144 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r |
94b17fa1 | 145 | file.\r |
a405b86d | 146 | @retval EFI_VOLUME_FULL The volume is full.\r |
94b17fa1 | 147 | **/\r |
148 | EFI_STATUS\r | |
149 | EFIAPI\r | |
150 | ShellOpenFileByName(\r | |
b0934ac4 | 151 | IN CONST CHAR16 *FilePath,\r |
a405b86d | 152 | OUT SHELL_FILE_HANDLE *FileHandle,\r |
94b17fa1 | 153 | IN UINT64 OpenMode,\r |
b0934ac4 | 154 | IN UINT64 Attributes\r |
94b17fa1 | 155 | );\r |
156 | \r | |
157 | /**\r | |
18cefebe | 158 | This function creates a directory.\r |
94b17fa1 | 159 | \r |
1e6e84c7 | 160 | If return is EFI_SUCCESS, the Filehandle is the opened directory's handle;\r |
161 | otherwise, the Filehandle is NULL. If the directory already existed, this\r | |
94b17fa1 | 162 | function opens the existing directory.\r |
163 | \r | |
a405b86d | 164 | @param[in] DirectoryName The pointer to Directory name.\r |
165 | @param[out] FileHandle The pointer to the file handle.\r | |
94b17fa1 | 166 | \r |
b0934ac4 | 167 | @retval EFI_SUCCESS The information was set.\r |
168 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
a405b86d | 169 | @retval EFI_UNSUPPORTED Could not open the file path.\r |
b0934ac4 | 170 | @retval EFI_NOT_FOUND The specified file could not be found on the\r |
a405b86d | 171 | device, or the file system could not be found\r |
94b17fa1 | 172 | on the device.\r |
a405b86d | 173 | @retval EFI_NO_MEDIA The device has no medium.\r |
174 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r | |
94b17fa1 | 175 | medium is no longer supported.\r |
a405b86d | 176 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
b0934ac4 | 177 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
a405b86d | 178 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
179 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
b0934ac4 | 180 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r |
94b17fa1 | 181 | file.\r |
a405b86d | 182 | @retval EFI_VOLUME_FULL The volume is full.\r |
94b17fa1 | 183 | **/\r |
184 | EFI_STATUS\r | |
185 | EFIAPI\r | |
186 | ShellCreateDirectory(\r | |
b82bfcc1 | 187 | IN CONST CHAR16 *DirectoryName,\r |
a405b86d | 188 | OUT SHELL_FILE_HANDLE *FileHandle\r |
94b17fa1 | 189 | );\r |
190 | \r | |
191 | /**\r | |
192 | This function reads information from an opened file.\r | |
193 | \r | |
1e6e84c7 | 194 | If FileHandle is not a directory, the function reads the requested number of\r |
195 | bytes from the file at the file's current position and returns them in Buffer.\r | |
94b17fa1 | 196 | If the read goes beyond the end of the file, the read length is truncated to the\r |
1e6e84c7 | 197 | end of the file. The file's current position is increased by the number of bytes\r |
198 | returned. If FileHandle is a directory, the function reads the directory entry\r | |
199 | at the file's current position and returns the entry in Buffer. If the Buffer\r | |
200 | is not large enough to hold the current directory entry, then\r | |
201 | EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.\r | |
202 | BufferSize is set to be the size of the buffer needed to read the entry. On\r | |
203 | success, the current position is updated to the next directory entry. If there\r | |
204 | are no more directory entries, the read returns a zero-length buffer.\r | |
94b17fa1 | 205 | EFI_FILE_INFO is the structure returned as the directory entry.\r |
206 | \r | |
4ff7e37b ED |
207 | @param[in] FileHandle The opened file handle.\r |
208 | @param[in, out] ReadSize On input the size of buffer in bytes. On return\r | |
209 | the number of bytes written.\r | |
210 | @param[out] Buffer The buffer to put read data into.\r | |
94b17fa1 | 211 | \r |
a405b86d | 212 | @retval EFI_SUCCESS Data was read.\r |
b0934ac4 | 213 | @retval EFI_NO_MEDIA The device has no media.\r |
a405b86d | 214 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
b0934ac4 | 215 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
a405b86d | 216 | @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required\r |
94b17fa1 | 217 | size.\r |
218 | \r | |
219 | **/\r | |
220 | EFI_STATUS\r | |
221 | EFIAPI\r | |
222 | ShellReadFile(\r | |
a405b86d | 223 | IN SHELL_FILE_HANDLE FileHandle,\r |
94b17fa1 | 224 | IN OUT UINTN *ReadSize,\r |
225 | OUT VOID *Buffer\r | |
226 | );\r | |
227 | \r | |
228 | /**\r | |
229 | Write data to a file.\r | |
230 | \r | |
1e6e84c7 | 231 | This function writes the specified number of bytes to the file at the current\r |
232 | file position. The current file position is advanced the actual number of bytes\r | |
233 | written, which is returned in BufferSize. Partial writes only occur when there\r | |
234 | has been a data error during the write attempt (such as "volume space full").\r | |
235 | The file is automatically grown to hold the data if required. Direct writes to\r | |
94b17fa1 | 236 | opened directories are not supported.\r |
237 | \r | |
4ff7e37b | 238 | @param[in] FileHandle The opened file for writing.\r |
94b17fa1 | 239 | \r |
4ff7e37b ED |
240 | @param[in, out] BufferSize On input the number of bytes in Buffer. On output\r |
241 | the number of bytes written.\r | |
94b17fa1 | 242 | \r |
4ff7e37b | 243 | @param[in] Buffer The buffer containing data to write is stored.\r |
94b17fa1 | 244 | \r |
a405b86d | 245 | @retval EFI_SUCCESS Data was written.\r |
246 | @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r | |
b0934ac4 | 247 | @retval EFI_NO_MEDIA The device has no media.\r |
a405b86d | 248 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
249 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
250 | @retval EFI_WRITE_PROTECTED The device is write-protected.\r | |
251 | @retval EFI_ACCESS_DENIED The file was open for read only.\r | |
252 | @retval EFI_VOLUME_FULL The volume is full.\r | |
94b17fa1 | 253 | **/\r |
254 | EFI_STATUS\r | |
255 | EFIAPI\r | |
256 | ShellWriteFile(\r | |
a405b86d | 257 | IN SHELL_FILE_HANDLE FileHandle,\r |
94b17fa1 | 258 | IN OUT UINTN *BufferSize,\r |
08d7f8e8 | 259 | IN VOID *Buffer\r |
94b17fa1 | 260 | );\r |
261 | \r | |
1e6e84c7 | 262 | /**\r |
94b17fa1 | 263 | Close an open file handle.\r |
264 | \r | |
1e6e84c7 | 265 | This function closes a specified file handle. All "dirty" cached file data is\r |
266 | flushed to the device, and the file is closed. In all cases the handle is\r | |
94b17fa1 | 267 | closed.\r |
268 | \r | |
18cefebe | 269 | @param[in] FileHandle The file handle to close.\r |
94b17fa1 | 270 | \r |
125c2cf4 | 271 | @retval EFI_SUCCESS The file handle was closed sucessfully.\r |
a405b86d | 272 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r |
94b17fa1 | 273 | **/\r |
274 | EFI_STATUS\r | |
275 | EFIAPI\r | |
276 | ShellCloseFile (\r | |
a405b86d | 277 | IN SHELL_FILE_HANDLE *FileHandle\r |
94b17fa1 | 278 | );\r |
279 | \r | |
280 | /**\r | |
281 | Delete a file and close the handle\r | |
282 | \r | |
283 | This function closes and deletes a file. In all cases the file handle is closed.\r | |
1e6e84c7 | 284 | If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r |
94b17fa1 | 285 | returned, but the handle is still closed.\r |
286 | \r | |
18cefebe | 287 | @param[in] FileHandle The file handle to delete.\r |
94b17fa1 | 288 | \r |
125c2cf4 | 289 | @retval EFI_SUCCESS The file was closed sucessfully.\r |
1e6e84c7 | 290 | @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not\r |
125c2cf4 | 291 | deleted.\r |
b0934ac4 | 292 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r |
94b17fa1 | 293 | **/\r |
294 | EFI_STATUS\r | |
295 | EFIAPI\r | |
296 | ShellDeleteFile (\r | |
a405b86d | 297 | IN SHELL_FILE_HANDLE *FileHandle\r |
94b17fa1 | 298 | );\r |
299 | \r | |
300 | /**\r | |
301 | Set the current position in a file.\r | |
302 | \r | |
1e6e84c7 | 303 | This function sets the current file position for the handle to the position\r |
94b17fa1 | 304 | supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r |
a405b86d | 305 | absolute positioning is supported, and moving past the end of the file is\r |
306 | allowed (a subsequent write would grow the file). Moving to position\r | |
94b17fa1 | 307 | 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r |
1e6e84c7 | 308 | If FileHandle is a directory, the only position that may be set is zero. This\r |
94b17fa1 | 309 | has the effect of starting the read process of the directory entries over.\r |
310 | \r | |
18cefebe | 311 | @param[in] FileHandle The file handle on which the position is being set.\r |
94b17fa1 | 312 | \r |
a405b86d | 313 | @param[in] Position The byte position from the begining of the file.\r |
94b17fa1 | 314 | \r |
315 | @retval EFI_SUCCESS Operation completed sucessfully.\r | |
1e6e84c7 | 316 | @retval EFI_UNSUPPORTED The seek request for non-zero is not valid on\r |
94b17fa1 | 317 | directories.\r |
318 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r | |
319 | **/\r | |
320 | EFI_STATUS\r | |
321 | EFIAPI\r | |
322 | ShellSetFilePosition (\r | |
b0934ac4 | 323 | IN SHELL_FILE_HANDLE FileHandle,\r |
324 | IN UINT64 Position\r | |
94b17fa1 | 325 | );\r |
326 | \r | |
1e6e84c7 | 327 | /**\r |
94b17fa1 | 328 | Gets a file's current position\r |
329 | \r | |
1e6e84c7 | 330 | This function retrieves the current file position for the file handle. For\r |
331 | directories, the current file position has no meaning outside of the file\r | |
94b17fa1 | 332 | system driver and as such the operation is not supported. An error is returned\r |
333 | if FileHandle is a directory.\r | |
334 | \r | |
18cefebe | 335 | @param[in] FileHandle The open file handle on which to get the position.\r |
a405b86d | 336 | @param[out] Position The byte position from the begining of the file.\r |
94b17fa1 | 337 | \r |
18cefebe | 338 | @retval EFI_SUCCESS The operation completed sucessfully.\r |
94b17fa1 | 339 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r |
18cefebe | 340 | @retval EFI_UNSUPPORTED The request is not valid on directories.\r |
94b17fa1 | 341 | **/\r |
342 | EFI_STATUS\r | |
343 | EFIAPI\r | |
344 | ShellGetFilePosition (\r | |
a405b86d | 345 | IN SHELL_FILE_HANDLE FileHandle,\r |
94b17fa1 | 346 | OUT UINT64 *Position\r |
347 | );\r | |
348 | \r | |
349 | /**\r | |
350 | Flushes data on a file\r | |
1e6e84c7 | 351 | \r |
94b17fa1 | 352 | This function flushes all modified data associated with a file to a device.\r |
353 | \r | |
18cefebe | 354 | @param[in] FileHandle The file handle on which to flush data.\r |
94b17fa1 | 355 | \r |
356 | @retval EFI_SUCCESS The data was flushed.\r | |
357 | @retval EFI_NO_MEDIA The device has no media.\r | |
358 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
359 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
360 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r | |
361 | @retval EFI_ACCESS_DENIED The file was opened for read only.\r | |
362 | **/\r | |
363 | EFI_STATUS\r | |
364 | EFIAPI\r | |
365 | ShellFlushFile (\r | |
a405b86d | 366 | IN SHELL_FILE_HANDLE FileHandle\r |
94b17fa1 | 367 | );\r |
368 | \r | |
b0934ac4 | 369 | /** Retrieve first entry from a directory.\r |
94b17fa1 | 370 | \r |
b0934ac4 | 371 | This function takes an open directory handle and gets information from the\r |
372 | first entry in the directory. A buffer is allocated to contain\r | |
373 | the information and a pointer to the buffer is returned in *Buffer. The\r | |
374 | caller can use ShellFindNextFile() to get subsequent directory entries.\r | |
94b17fa1 | 375 | \r |
b0934ac4 | 376 | The buffer will be freed by ShellFindNextFile() when the last directory\r |
377 | entry is read. Otherwise, the caller must free the buffer, using FreePool,\r | |
378 | when finished with it.\r | |
d2b4564b | 379 | \r |
b0934ac4 | 380 | @param[in] DirHandle The file handle of the directory to search.\r |
a405b86d | 381 | @param[out] Buffer The pointer to the buffer for the file's information.\r |
94b17fa1 | 382 | \r |
383 | @retval EFI_SUCCESS Found the first file.\r | |
384 | @retval EFI_NOT_FOUND Cannot find the directory.\r | |
385 | @retval EFI_NO_MEDIA The device has no media.\r | |
386 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
387 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
b0934ac4 | 388 | @return Others Status of ShellGetFileInfo, ShellSetFilePosition,\r |
389 | or ShellReadFile.\r | |
390 | \r | |
a405b86d | 391 | @sa ShellReadFile\r |
94b17fa1 | 392 | **/\r |
393 | EFI_STATUS\r | |
394 | EFIAPI\r | |
395 | ShellFindFirstFile (\r | |
b0934ac4 | 396 | IN SHELL_FILE_HANDLE DirHandle,\r |
397 | OUT EFI_FILE_INFO **Buffer\r | |
94b17fa1 | 398 | );\r |
399 | \r | |
b0934ac4 | 400 | /** Retrieve next entries from a directory.\r |
94b17fa1 | 401 | \r |
b0934ac4 | 402 | To use this function, the caller must first call the ShellFindFirstFile()\r |
403 | function to get the first directory entry. Subsequent directory entries are\r | |
404 | retrieved by using the ShellFindNextFile() function. This function can\r | |
405 | be called several times to get each entry from the directory. If the call of\r | |
406 | ShellFindNextFile() retrieved the last directory entry, the next call of\r | |
407 | this function will set *NoFile to TRUE and free the buffer.\r | |
94b17fa1 | 408 | \r |
b0934ac4 | 409 | @param[in] DirHandle The file handle of the directory.\r |
37d5c6ee ED |
410 | @param[in, out] Buffer The pointer to buffer for file's information.\r |
411 | @param[in, out] NoFile The pointer to boolean when last file is found.\r | |
94b17fa1 | 412 | \r |
413 | @retval EFI_SUCCESS Found the next file.\r | |
414 | @retval EFI_NO_MEDIA The device has no media.\r | |
415 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
416 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
b0934ac4 | 417 | \r |
a405b86d | 418 | @sa ShellReadFile\r |
94b17fa1 | 419 | **/\r |
420 | EFI_STATUS\r | |
421 | EFIAPI\r | |
422 | ShellFindNextFile(\r | |
b0934ac4 | 423 | IN SHELL_FILE_HANDLE DirHandle,\r |
424 | IN OUT EFI_FILE_INFO *Buffer,\r | |
425 | IN OUT BOOLEAN *NoFile\r | |
94b17fa1 | 426 | );\r |
427 | \r | |
428 | /**\r | |
429 | Retrieve the size of a file.\r | |
430 | \r | |
1e6e84c7 | 431 | This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r |
94b17fa1 | 432 | data.\r |
433 | \r | |
18cefebe | 434 | @param[in] FileHandle The file handle from which size is retrieved.\r |
a405b86d | 435 | @param[out] Size The pointer to size.\r |
94b17fa1 | 436 | \r |
125c2cf4 | 437 | @retval EFI_SUCCESS The operation was completed sucessfully.\r |
a31bd33c | 438 | @retval EFI_DEVICE_ERROR Cannot access the file.\r |
94b17fa1 | 439 | **/\r |
440 | EFI_STATUS\r | |
441 | EFIAPI\r | |
442 | ShellGetFileSize (\r | |
a405b86d | 443 | IN SHELL_FILE_HANDLE FileHandle,\r |
94b17fa1 | 444 | OUT UINT64 *Size\r |
445 | );\r | |
446 | \r | |
447 | /**\r | |
448 | Retrieves the status of the break execution flag\r | |
449 | \r | |
18cefebe | 450 | This function is useful to check whether the application is being asked to halt by the shell.\r |
94b17fa1 | 451 | \r |
a405b86d | 452 | @retval TRUE The execution break is enabled.\r |
453 | @retval FALSE The execution break is not enabled.\r | |
94b17fa1 | 454 | **/\r |
455 | BOOLEAN\r | |
456 | EFIAPI\r | |
457 | ShellGetExecutionBreakFlag(\r | |
458 | VOID\r | |
459 | );\r | |
460 | \r | |
461 | /**\r | |
125c2cf4 | 462 | Return the value of an environment variable.\r |
94b17fa1 | 463 | \r |
1e6e84c7 | 464 | This function gets the value of the environment variable set by the\r |
125c2cf4 | 465 | ShellSetEnvironmentVariable function.\r |
94b17fa1 | 466 | \r |
18cefebe | 467 | @param[in] EnvKey The key name of the environment variable.\r |
94b17fa1 | 468 | \r |
a31bd33c | 469 | @retval NULL The named environment variable does not exist.\r |
a405b86d | 470 | @return != NULL The pointer to the value of the environment variable.\r |
94b17fa1 | 471 | **/\r |
472 | CONST CHAR16*\r | |
473 | EFIAPI\r | |
474 | ShellGetEnvironmentVariable (\r | |
9b3bf083 | 475 | IN CONST CHAR16 *EnvKey\r |
94b17fa1 | 476 | );\r |
477 | \r | |
478 | /**\r | |
18cefebe | 479 | Set the value of an environment variable.\r |
94b17fa1 | 480 | \r |
125c2cf4 | 481 | This function changes the current value of the specified environment variable. If the\r |
482 | environment variable exists and the Value is an empty string, then the environment\r | |
483 | variable is deleted. If the environment variable exists and the Value is not an empty\r | |
484 | string, then the value of the environment variable is changed. If the environment\r | |
485 | variable does not exist and the Value is an empty string, there is no action. If the\r | |
486 | environment variable does not exist and the Value is a non-empty string, then the\r | |
487 | environment variable is created and assigned the specified value.\r | |
94b17fa1 | 488 | \r |
489 | This is not supported pre-UEFI Shell 2.0.\r | |
490 | \r | |
18cefebe | 491 | @param[in] EnvKey The key name of the environment variable.\r |
492 | @param[in] EnvVal The Value of the environment variable\r | |
493 | @param[in] Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r | |
94b17fa1 | 494 | \r |
a405b86d | 495 | @retval EFI_SUCCESS The operation completed sucessfully\r |
496 | @retval EFI_UNSUPPORTED This operation is not allowed in pre-UEFI 2.0 Shell environments.\r | |
94b17fa1 | 497 | **/\r |
498 | EFI_STATUS\r | |
499 | EFIAPI\r | |
500 | ShellSetEnvironmentVariable (\r | |
501 | IN CONST CHAR16 *EnvKey,\r | |
502 | IN CONST CHAR16 *EnvVal,\r | |
503 | IN BOOLEAN Volatile\r | |
504 | );\r | |
505 | \r | |
506 | /**\r | |
125c2cf4 | 507 | Cause the shell to parse and execute a command line.\r |
94b17fa1 | 508 | \r |
509 | This function creates a nested instance of the shell and executes the specified\r | |
125c2cf4 | 510 | command (CommandLine) with the specified environment (Environment). Upon return,\r |
511 | the status code returned by the specified command is placed in StatusCode.\r | |
512 | If Environment is NULL, then the current environment is used and all changes made\r | |
513 | by the commands executed will be reflected in the current environment. If the\r | |
514 | Environment is non-NULL, then the changes made will be discarded.\r | |
515 | The CommandLine is executed from the current working directory on the current\r | |
516 | device.\r | |
94b17fa1 | 517 | \r |
7e4ed4b8 | 518 | The EnvironmentVariables and Status parameters are ignored in a pre-UEFI Shell 2.0\r |
519 | environment. The values pointed to by the parameters will be unchanged by the\r | |
520 | ShellExecute() function. The Output parameter has no effect in a\r | |
521 | UEFI Shell 2.0 environment.\r | |
94b17fa1 | 522 | \r |
a405b86d | 523 | @param[in] ParentHandle The parent image starting the operation.\r |
524 | @param[in] CommandLine The pointer to a NULL terminated command line.\r | |
18cefebe | 525 | @param[in] Output True to display debug output. False to hide it.\r |
526 | @param[in] EnvironmentVariables Optional pointer to array of environment variables\r | |
a405b86d | 527 | in the form "x=y". If NULL, the current set is used.\r |
18cefebe | 528 | @param[out] Status The status of the run command line.\r |
94b17fa1 | 529 | \r |
18cefebe | 530 | @retval EFI_SUCCESS The operation completed sucessfully. Status\r |
531 | contains the status code returned.\r | |
532 | @retval EFI_INVALID_PARAMETER A parameter contains an invalid value.\r | |
533 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r | |
534 | @retval EFI_UNSUPPORTED The operation is not allowed.\r | |
94b17fa1 | 535 | **/\r |
536 | EFI_STATUS\r | |
537 | EFIAPI\r | |
538 | ShellExecute (\r | |
539 | IN EFI_HANDLE *ParentHandle,\r | |
540 | IN CHAR16 *CommandLine,\r | |
541 | IN BOOLEAN Output,\r | |
542 | IN CHAR16 **EnvironmentVariables,\r | |
543 | OUT EFI_STATUS *Status\r | |
544 | );\r | |
545 | \r | |
546 | /**\r | |
a31bd33c | 547 | Retreives the current directory path.\r |
94b17fa1 | 548 | \r |
1e6e84c7 | 549 | If the DeviceName is NULL, it returns the current device's current directory\r |
550 | name. If the DeviceName is not NULL, it returns the current directory name\r | |
94b17fa1 | 551 | on specified drive.\r |
552 | \r | |
fbd2dfad QS |
553 | Note that the current directory string should exclude the tailing backslash character.\r |
554 | \r | |
18cefebe | 555 | @param[in] DeviceName The name of the file system to get directory on.\r |
94b17fa1 | 556 | \r |
a31bd33c | 557 | @retval NULL The directory does not exist.\r |
18cefebe | 558 | @retval != NULL The directory.\r |
94b17fa1 | 559 | **/\r |
560 | CONST CHAR16*\r | |
561 | EFIAPI\r | |
562 | ShellGetCurrentDir (\r | |
a405b86d | 563 | IN CHAR16 * CONST DeviceName OPTIONAL\r |
94b17fa1 | 564 | );\r |
565 | \r | |
566 | /**\r | |
125c2cf4 | 567 | Sets (enabled or disabled) the page break mode.\r |
94b17fa1 | 568 | \r |
1e6e84c7 | 569 | When page break mode is enabled the screen will stop scrolling\r |
94b17fa1 | 570 | and wait for operator input before scrolling a subsequent screen.\r |
571 | \r | |
18cefebe | 572 | @param[in] CurrentState TRUE to enable and FALSE to disable.\r |
94b17fa1 | 573 | **/\r |
1e6e84c7 | 574 | VOID\r |
94b17fa1 | 575 | EFIAPI\r |
576 | ShellSetPageBreakMode (\r | |
577 | IN BOOLEAN CurrentState\r | |
578 | );\r | |
579 | \r | |
580 | /**\r | |
581 | Opens a group of files based on a path.\r | |
582 | \r | |
1e6e84c7 | 583 | This function uses the Arg to open all the matching files. Each matched\r |
584 | file has a SHELL_FILE_ARG structure to record the file information. These\r | |
585 | structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG\r | |
94b17fa1 | 586 | structures from ListHead to access each file. This function supports wildcards\r |
1e6e84c7 | 587 | and will process '?' and '*' as such. The list must be freed with a call to\r |
94b17fa1 | 588 | ShellCloseFileMetaArg().\r |
589 | \r | |
1e6e84c7 | 590 | If you are NOT appending to an existing list *ListHead must be NULL. If\r |
eb646684 | 591 | *ListHead is NULL then it must be callee freed.\r |
94b17fa1 | 592 | \r |
4ff7e37b ED |
593 | @param[in] Arg The pointer to path string.\r |
594 | @param[in] OpenMode Mode to open files with.\r | |
595 | @param[in, out] ListHead Head of linked list of results.\r | |
94b17fa1 | 596 | \r |
1e6e84c7 | 597 | @retval EFI_SUCCESS The operation was sucessful and the list head\r |
125c2cf4 | 598 | contains the list of opened files.\r |
a31bd33c | 599 | @retval != EFI_SUCCESS The operation failed.\r |
94b17fa1 | 600 | \r |
601 | @sa InternalShellConvertFileListType\r | |
602 | **/\r | |
603 | EFI_STATUS\r | |
604 | EFIAPI\r | |
605 | ShellOpenFileMetaArg (\r | |
606 | IN CHAR16 *Arg,\r | |
607 | IN UINT64 OpenMode,\r | |
608 | IN OUT EFI_SHELL_FILE_INFO **ListHead\r | |
609 | );\r | |
610 | \r | |
611 | /**\r | |
a31bd33c | 612 | Free the linked list returned from ShellOpenFileMetaArg.\r |
94b17fa1 | 613 | \r |
4ff7e37b | 614 | @param[in, out] ListHead The pointer to free.\r |
94b17fa1 | 615 | \r |
a31bd33c | 616 | @retval EFI_SUCCESS The operation was sucessful.\r |
617 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
94b17fa1 | 618 | **/\r |
619 | EFI_STATUS\r | |
620 | EFIAPI\r | |
621 | ShellCloseFileMetaArg (\r | |
622 | IN OUT EFI_SHELL_FILE_INFO **ListHead\r | |
623 | );\r | |
624 | \r | |
125c2cf4 | 625 | /**\r |
626 | Find a file by searching the CWD and then the path.\r | |
627 | \r | |
a31bd33c | 628 | If FileName is NULL, then ASSERT.\r |
125c2cf4 | 629 | \r |
a31bd33c | 630 | If the return value is not NULL then the memory must be caller freed.\r |
125c2cf4 | 631 | \r |
18cefebe | 632 | @param[in] FileName Filename string.\r |
125c2cf4 | 633 | \r |
a31bd33c | 634 | @retval NULL The file was not found.\r |
18cefebe | 635 | @retval !NULL The path to the file.\r |
125c2cf4 | 636 | **/\r |
637 | CHAR16 *\r | |
638 | EFIAPI\r | |
639 | ShellFindFilePath (\r | |
640 | IN CONST CHAR16 *FileName\r | |
641 | );\r | |
642 | \r | |
b3011f40 | 643 | /**\r |
1e6e84c7 | 644 | Find a file by searching the CWD and then the path with a variable set of file\r |
645 | extensions. If the file is not found it will append each extension in the list\r | |
b3011f40 | 646 | in the order provided and return the first one that is successful.\r |
647 | \r | |
648 | If FileName is NULL, then ASSERT.\r | |
a405b86d | 649 | If FileExtension is NULL, then the behavior is identical to ShellFindFilePath.\r |
b3011f40 | 650 | \r |
651 | If the return value is not NULL then the memory must be caller freed.\r | |
652 | \r | |
a405b86d | 653 | @param[in] FileName The filename string.\r |
654 | @param[in] FileExtension Semicolon delimited list of possible extensions.\r | |
b3011f40 | 655 | \r |
656 | @retval NULL The file was not found.\r | |
657 | @retval !NULL The path to the file.\r | |
658 | **/\r | |
659 | CHAR16 *\r | |
660 | EFIAPI\r | |
661 | ShellFindFilePathEx (\r | |
662 | IN CONST CHAR16 *FileName,\r | |
663 | IN CONST CHAR16 *FileExtension\r | |
664 | );\r | |
665 | \r | |
94b17fa1 | 666 | typedef enum {\r |
18cefebe | 667 | TypeFlag = 0, ///< A flag that is present or not present only (IE "-a").\r |
668 | TypeValue, ///< A flag that has some data following it with a space (IE "-a 1").\r | |
669 | TypePosition, ///< Some data that did not follow a parameter (IE "filename.txt").\r | |
670 | TypeStart, ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).\r | |
671 | TypeDoubleValue, ///< A flag that has 2 space seperated value data following it (IE "-a 1 2").\r | |
672 | TypeMaxValue, ///< A flag followed by all the command line data before the next flag.\r | |
658bf43e | 673 | TypeTimeValue, ///< A flag that has a time value following it (IE "-a -5:00").\r |
94b17fa1 | 674 | TypeMax,\r |
a405b86d | 675 | } SHELL_PARAM_TYPE;\r |
94b17fa1 | 676 | \r |
677 | typedef struct {\r | |
a405b86d | 678 | CHAR16 *Name;\r |
679 | SHELL_PARAM_TYPE Type;\r | |
94b17fa1 | 680 | } SHELL_PARAM_ITEM;\r |
681 | \r | |
d2b4564b | 682 | \r |
683 | /// Helper structure for no parameters (besides -? and -b)\r | |
684 | extern SHELL_PARAM_ITEM EmptyParamList[];\r | |
685 | \r | |
a405b86d | 686 | /// Helper structure for -sfo only (besides -? and -b)\r |
687 | extern SHELL_PARAM_ITEM SfoParamList[];\r | |
688 | \r | |
94b17fa1 | 689 | /**\r |
1e6e84c7 | 690 | Checks the command line arguments passed against the list of valid ones.\r |
94b17fa1 | 691 | Optionally removes NULL values first.\r |
1e6e84c7 | 692 | \r |
94b17fa1 | 693 | If no initialization is required, then return RETURN_SUCCESS.\r |
1e6e84c7 | 694 | \r |
a405b86d | 695 | @param[in] CheckList The pointer to list of parameters to check.\r |
696 | @param[out] CheckPackage The package of checked values.\r | |
1e6e84c7 | 697 | @param[out] ProblemParam Optional pointer to pointer to unicode string for\r |
94b17fa1 | 698 | the paramater that caused failure.\r |
18cefebe | 699 | @param[in] AutoPageBreak Will automatically set PageBreakEnabled.\r |
700 | @param[in] AlwaysAllowNumbers Will never fail for number based flags.\r | |
94b17fa1 | 701 | \r |
702 | @retval EFI_SUCCESS The operation completed sucessfully.\r | |
a31bd33c | 703 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r |
704 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
a405b86d | 705 | @retval EFI_VOLUME_CORRUPTED The command line was corrupt.\r |
a31bd33c | 706 | @retval EFI_DEVICE_ERROR The commands contained 2 opposing arguments. One\r |
1e6e84c7 | 707 | of the command line arguments was returned in\r |
94b17fa1 | 708 | ProblemParam if provided.\r |
1e6e84c7 | 709 | @retval EFI_NOT_FOUND A argument required a value that was missing.\r |
a31bd33c | 710 | The invalid command line argument was returned in\r |
94b17fa1 | 711 | ProblemParam if provided.\r |
712 | **/\r | |
713 | EFI_STATUS\r | |
714 | EFIAPI\r | |
2247dde4 | 715 | ShellCommandLineParseEx (\r |
94b17fa1 | 716 | IN CONST SHELL_PARAM_ITEM *CheckList,\r |
717 | OUT LIST_ENTRY **CheckPackage,\r | |
718 | OUT CHAR16 **ProblemParam OPTIONAL,\r | |
2247dde4 | 719 | IN BOOLEAN AutoPageBreak,\r |
720 | IN BOOLEAN AlwaysAllowNumbers\r | |
94b17fa1 | 721 | );\r |
722 | \r | |
18cefebe | 723 | /// Make it easy to upgrade from older versions of the shell library.\r |
2247dde4 | 724 | #define ShellCommandLineParse(CheckList,CheckPackage,ProblemParam,AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE)\r |
725 | \r | |
94b17fa1 | 726 | /**\r |
727 | Frees shell variable list that was returned from ShellCommandLineParse.\r | |
728 | \r | |
729 | This function will free all the memory that was used for the CheckPackage\r | |
730 | list of postprocessed shell arguments.\r | |
731 | \r | |
a31bd33c | 732 | If CheckPackage is NULL, then return.\r |
94b17fa1 | 733 | \r |
18cefebe | 734 | @param[in] CheckPackage The list to de-allocate.\r |
94b17fa1 | 735 | **/\r |
736 | VOID\r | |
737 | EFIAPI\r | |
738 | ShellCommandLineFreeVarList (\r | |
739 | IN LIST_ENTRY *CheckPackage\r | |
740 | );\r | |
741 | \r | |
742 | /**\r | |
a31bd33c | 743 | Checks for presence of a flag parameter.\r |
94b17fa1 | 744 | \r |
18cefebe | 745 | Flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key.\r |
94b17fa1 | 746 | \r |
18cefebe | 747 | If CheckPackage is NULL then return FALSE.\r |
748 | If KeyString is NULL then ASSERT().\r | |
1e6e84c7 | 749 | \r |
18cefebe | 750 | @param[in] CheckPackage The package of parsed command line arguments.\r |
751 | @param[in] KeyString The Key of the command line argument to check for.\r | |
94b17fa1 | 752 | \r |
a31bd33c | 753 | @retval TRUE The flag is on the command line.\r |
754 | @retval FALSE The flag is not on the command line.\r | |
a405b86d | 755 | **/\r |
94b17fa1 | 756 | BOOLEAN\r |
757 | EFIAPI\r | |
758 | ShellCommandLineGetFlag (\r | |
a405b86d | 759 | IN CONST LIST_ENTRY * CONST CheckPackage,\r |
760 | IN CONST CHAR16 * CONST KeyString\r | |
94b17fa1 | 761 | );\r |
762 | \r | |
763 | /**\r | |
a31bd33c | 764 | Returns value from command line argument.\r |
94b17fa1 | 765 | \r |
18cefebe | 766 | Value parameters are in the form of "-<Key> value" or "/<Key> value".\r |
1e6e84c7 | 767 | \r |
a31bd33c | 768 | If CheckPackage is NULL, then return NULL.\r |
94b17fa1 | 769 | \r |
36a9d672 | 770 | @param[in] CheckPackage The package of parsed command line arguments.\r |
771 | @param[in] KeyString The Key of the command line argument to check for.\r | |
94b17fa1 | 772 | \r |
a31bd33c | 773 | @retval NULL The flag is not on the command line.\r |
a405b86d | 774 | @retval !=NULL The pointer to unicode string of the value.\r |
775 | **/\r | |
94b17fa1 | 776 | CONST CHAR16*\r |
777 | EFIAPI\r | |
778 | ShellCommandLineGetValue (\r | |
779 | IN CONST LIST_ENTRY *CheckPackage,\r | |
780 | IN CHAR16 *KeyString\r | |
781 | );\r | |
782 | \r | |
783 | /**\r | |
a31bd33c | 784 | Returns raw value from command line argument.\r |
94b17fa1 | 785 | \r |
a31bd33c | 786 | Raw value parameters are in the form of "value" in a specific position in the list.\r |
1e6e84c7 | 787 | \r |
36a9d672 | 788 | If CheckPackage is NULL, then return NULL.\r |
94b17fa1 | 789 | \r |
36a9d672 | 790 | @param[in] CheckPackage The package of parsed command line arguments.\r |
791 | @param[in] Position The position of the value.\r | |
94b17fa1 | 792 | \r |
a31bd33c | 793 | @retval NULL The flag is not on the command line.\r |
a405b86d | 794 | @retval !=NULL The pointer to unicode string of the value.\r |
795 | **/\r | |
94b17fa1 | 796 | CONST CHAR16*\r |
797 | EFIAPI\r | |
798 | ShellCommandLineGetRawValue (\r | |
a405b86d | 799 | IN CONST LIST_ENTRY * CONST CheckPackage,\r |
800 | IN UINTN Position\r | |
94b17fa1 | 801 | );\r |
802 | \r | |
2247dde4 | 803 | /**\r |
1e6e84c7 | 804 | Returns the number of command line value parameters that were parsed.\r |
805 | \r | |
a31bd33c | 806 | This will not include flags.\r |
2247dde4 | 807 | \r |
a405b86d | 808 | @param[in] CheckPackage The package of parsed command line arguments.\r |
809 | \r | |
810 | @retval (UINTN)-1 No parsing has occurred.\r | |
811 | @retval other The number of value parameters found.\r | |
2247dde4 | 812 | **/\r |
813 | UINTN\r | |
814 | EFIAPI\r | |
815 | ShellCommandLineGetCount(\r | |
a405b86d | 816 | IN CONST LIST_ENTRY *CheckPackage\r |
2247dde4 | 817 | );\r |
818 | \r | |
36a9d672 | 819 | /**\r |
a405b86d | 820 | Determines if a parameter is duplicated.\r |
36a9d672 | 821 | \r |
a405b86d | 822 | If Param is not NULL, then it will point to a callee-allocated string buffer\r |
823 | with the parameter value, if a duplicate is found.\r | |
36a9d672 | 824 | \r |
825 | If CheckPackage is NULL, then ASSERT.\r | |
826 | \r | |
827 | @param[in] CheckPackage The package of parsed command line arguments.\r | |
828 | @param[out] Param Upon finding one, a pointer to the duplicated parameter.\r | |
829 | \r | |
830 | @retval EFI_SUCCESS No parameters were duplicated.\r | |
831 | @retval EFI_DEVICE_ERROR A duplicate was found.\r | |
832 | **/\r | |
833 | EFI_STATUS\r | |
834 | EFIAPI\r | |
835 | ShellCommandLineCheckDuplicate (\r | |
836 | IN CONST LIST_ENTRY *CheckPackage,\r | |
837 | OUT CHAR16 **Param\r | |
838 | );\r | |
839 | \r | |
d2b4564b | 840 | /**\r |
841 | This function causes the shell library to initialize itself. If the shell library\r | |
a405b86d | 842 | is already initialized it will de-initialize all the current protocol pointers and\r |
d2b4564b | 843 | re-populate them again.\r |
844 | \r | |
845 | When the library is used with PcdShellLibAutoInitialize set to true this function\r | |
846 | will return EFI_SUCCESS and perform no actions.\r | |
847 | \r | |
848 | This function is intended for internal access for shell commands only.\r | |
849 | \r | |
a405b86d | 850 | @retval EFI_SUCCESS The initialization was complete sucessfully.\r |
d2b4564b | 851 | \r |
852 | **/\r | |
853 | EFI_STATUS\r | |
854 | EFIAPI\r | |
855 | ShellInitialize (\r | |
125c2cf4 | 856 | VOID\r |
d2b4564b | 857 | );\r |
858 | \r | |
b1f95a06 | 859 | /**\r |
860 | Print at a specific location on the screen.\r | |
861 | \r | |
a5bd42b9 | 862 | This function will move the cursor to a given screen location and print the specified string.\r |
1e6e84c7 | 863 | \r |
864 | If -1 is specified for either the Row or Col the current screen location for BOTH\r | |
a5bd42b9 | 865 | will be used.\r |
b1f95a06 | 866 | \r |
a31bd33c | 867 | If either Row or Col is out of range for the current console, then ASSERT.\r |
868 | If Format is NULL, then ASSERT.\r | |
b1f95a06 | 869 | \r |
1e6e84c7 | 870 | In addition to the standard %-based flags as supported by UefiLib Print() this supports\r |
b1f95a06 | 871 | the following additional flags:\r |
872 | %N - Set output attribute to normal\r | |
873 | %H - Set output attribute to highlight\r | |
874 | %E - Set output attribute to error\r | |
875 | %B - Set output attribute to blue color\r | |
876 | %V - Set output attribute to green color\r | |
877 | \r | |
878 | Note: The background color is controlled by the shell command cls.\r | |
879 | \r | |
18cefebe | 880 | @param[in] Col The column to print at.\r |
a405b86d | 881 | @param[in] Row The row to print at.\r |
18cefebe | 882 | @param[in] Format The format string.\r |
a405b86d | 883 | @param[in] ... The variable argument list.\r |
b1f95a06 | 884 | \r |
a405b86d | 885 | @return EFI_SUCCESS The printing was successful.\r |
886 | @return EFI_DEVICE_ERROR The console device reported an error.\r | |
b1f95a06 | 887 | **/\r |
a405b86d | 888 | EFI_STATUS\r |
b1f95a06 | 889 | EFIAPI\r |
890 | ShellPrintEx(\r | |
891 | IN INT32 Col OPTIONAL,\r | |
892 | IN INT32 Row OPTIONAL,\r | |
893 | IN CONST CHAR16 *Format,\r | |
894 | ...\r | |
895 | );\r | |
896 | \r | |
2247dde4 | 897 | /**\r |
898 | Print at a specific location on the screen.\r | |
899 | \r | |
a5bd42b9 | 900 | This function will move the cursor to a given screen location and print the specified string.\r |
1e6e84c7 | 901 | \r |
902 | If -1 is specified for either the Row or Col the current screen location for BOTH\r | |
a5bd42b9 | 903 | will be used.\r |
2247dde4 | 904 | \r |
a5bd42b9 | 905 | If either Row or Col is out of range for the current console, then ASSERT.\r |
906 | If Format is NULL, then ASSERT.\r | |
2247dde4 | 907 | \r |
1e6e84c7 | 908 | In addition to the standard %-based flags as supported by UefiLib Print() this supports\r |
2247dde4 | 909 | the following additional flags:\r |
18cefebe | 910 | %N - Set output attribute to normal.\r |
911 | %H - Set output attribute to highlight.\r | |
912 | %E - Set output attribute to error.\r | |
913 | %B - Set output attribute to blue color.\r | |
914 | %V - Set output attribute to green color.\r | |
2247dde4 | 915 | \r |
916 | Note: The background color is controlled by the shell command cls.\r | |
917 | \r | |
18cefebe | 918 | @param[in] Col The column to print at.\r |
a405b86d | 919 | @param[in] Row The row to print at.\r |
1e6e84c7 | 920 | @param[in] Language The language of the string to retrieve. If this parameter\r |
921 | is NULL, then the current platform language is used.\r | |
18cefebe | 922 | @param[in] HiiFormatStringId The format string Id for getting from Hii.\r |
923 | @param[in] HiiFormatHandle The format string Handle for getting from Hii.\r | |
a405b86d | 924 | @param[in] ... The variable argument list.\r |
2247dde4 | 925 | \r |
a405b86d | 926 | @return EFI_SUCCESS The printing was successful.\r |
927 | @return EFI_DEVICE_ERROR The console device reported an error.\r | |
2247dde4 | 928 | **/\r |
a405b86d | 929 | EFI_STATUS\r |
2247dde4 | 930 | EFIAPI\r |
931 | ShellPrintHiiEx(\r | |
932 | IN INT32 Col OPTIONAL,\r | |
933 | IN INT32 Row OPTIONAL,\r | |
1e6e84c7 | 934 | IN CONST CHAR8 *Language OPTIONAL,\r |
2247dde4 | 935 | IN CONST EFI_STRING_ID HiiFormatStringId,\r |
936 | IN CONST EFI_HANDLE HiiFormatHandle,\r | |
937 | ...\r | |
938 | );\r | |
939 | \r | |
940 | /**\r | |
a31bd33c | 941 | Function to determine if a given filename represents a directory.\r |
2247dde4 | 942 | \r |
18cefebe | 943 | If DirName is NULL, then ASSERT.\r |
944 | \r | |
2247dde4 | 945 | @param[in] DirName Path to directory to test.\r |
946 | \r | |
a31bd33c | 947 | @retval EFI_SUCCESS The Path represents a directory.\r |
948 | @retval EFI_NOT_FOUND The Path does not represent a directory.\r | |
949 | @retval other The path failed to open.\r | |
2247dde4 | 950 | **/\r |
951 | EFI_STATUS\r | |
952 | EFIAPI\r | |
953 | ShellIsDirectory(\r | |
954 | IN CONST CHAR16 *DirName\r | |
955 | );\r | |
956 | \r | |
a31bd33c | 957 | /**\r |
958 | Function to determine if a given filename represents a file.\r | |
959 | \r | |
b3011f40 | 960 | This will search the CWD only.\r |
961 | \r | |
18cefebe | 962 | If Name is NULL, then ASSERT.\r |
963 | \r | |
a31bd33c | 964 | @param[in] Name Path to file to test.\r |
965 | \r | |
966 | @retval EFI_SUCCESS The Path represents a file.\r | |
967 | @retval EFI_NOT_FOUND The Path does not represent a file.\r | |
968 | @retval other The path failed to open.\r | |
969 | **/\r | |
970 | EFI_STATUS\r | |
971 | EFIAPI\r | |
972 | ShellIsFile(\r | |
973 | IN CONST CHAR16 *Name\r | |
974 | );\r | |
975 | \r | |
b3011f40 | 976 | /**\r |
977 | Function to determine if a given filename represents a file.\r | |
978 | \r | |
979 | This will search the CWD and then the Path.\r | |
980 | \r | |
981 | If Name is NULL, then ASSERT.\r | |
982 | \r | |
983 | @param[in] Name Path to file to test.\r | |
984 | \r | |
985 | @retval EFI_SUCCESS The Path represents a file.\r | |
986 | @retval EFI_NOT_FOUND The Path does not represent a file.\r | |
987 | @retval other The path failed to open.\r | |
988 | **/\r | |
989 | EFI_STATUS\r | |
990 | EFIAPI\r | |
991 | ShellIsFileInPath(\r | |
992 | IN CONST CHAR16 *Name\r | |
993 | );\r | |
994 | \r | |
125c2cf4 | 995 | /**\r |
1e6e84c7 | 996 | Function to determine whether a string is decimal or hex representation of a number\r |
125c2cf4 | 997 | and return the number converted from the string.\r |
998 | \r | |
b0934ac4 | 999 | Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r |
4bbdc0e1 | 1000 | result. Use ShellConvertStringToUint64 instead.\r |
1001 | \r | |
1002 | @param[in] String String representation of a number.\r | |
125c2cf4 | 1003 | \r |
a31bd33c | 1004 | @return The unsigned integer result of the conversion.\r |
4bbdc0e1 | 1005 | @retval (UINTN)(-1) An error occured.\r |
125c2cf4 | 1006 | **/\r |
1007 | UINTN\r | |
1008 | EFIAPI\r | |
1009 | ShellStrToUintn(\r | |
1010 | IN CONST CHAR16 *String\r | |
74b0fb8c JC |
1011 | );\r |
1012 | \r | |
1013 | /**\r | |
1014 | Function return the number converted from a hex representation of a number.\r | |
1015 | \r | |
1016 | Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r | |
1017 | result. Use ShellConvertStringToUint64 instead.\r | |
1018 | \r | |
1019 | @param[in] String String representation of a number.\r | |
1020 | \r | |
1021 | @return The unsigned integer result of the conversion.\r | |
1022 | @retval (UINTN)(-1) An error occured.\r | |
1023 | **/\r | |
1024 | UINTN\r | |
1025 | EFIAPI\r | |
1026 | ShellHexStrToUintn(\r | |
1027 | IN CONST CHAR16 *String\r | |
125c2cf4 | 1028 | );\r |
1029 | \r | |
1030 | /**\r | |
1e6e84c7 | 1031 | Safely append with automatic string resizing given length of Destination and\r |
125c2cf4 | 1032 | desired length of copy from Source.\r |
1033 | \r | |
1e6e84c7 | 1034 | Append the first D characters of Source to the end of Destination, where D is\r |
1035 | the lesser of Count and the StrLen() of Source. If appending those D characters\r | |
1036 | will fit within Destination (whose Size is given as CurrentSize) and\r | |
1037 | still leave room for a NULL terminator, then those characters are appended,\r | |
1038 | starting at the original terminating NULL of Destination, and a new terminating\r | |
1039 | NULL is appended.\r | |
125c2cf4 | 1040 | \r |
1041 | If appending D characters onto Destination will result in a overflow of the size\r | |
1042 | given in CurrentSize the string will be grown such that the copy can be performed\r | |
1043 | and CurrentSize will be updated to the new size.\r | |
1044 | \r | |
a405b86d | 1045 | If Source is NULL, there is nothing to append, so return the current buffer in\r |
125c2cf4 | 1046 | Destination.\r |
1047 | \r | |
18cefebe | 1048 | If Destination is NULL, then ASSERT().\r |
1e6e84c7 | 1049 | If Destination's current length (including NULL terminator) is already more than\r |
a31bd33c | 1050 | CurrentSize, then ASSERT().\r |
125c2cf4 | 1051 | \r |
4ff7e37b ED |
1052 | @param[in, out] Destination The String to append onto.\r |
1053 | @param[in, out] CurrentSize On call, the number of bytes in Destination. On\r | |
1054 | return, possibly the new size (still in bytes). If NULL,\r | |
1055 | then allocate whatever is needed.\r | |
1056 | @param[in] Source The String to append from.\r | |
1057 | @param[in] Count The maximum number of characters to append. If 0, then\r | |
1058 | all are appended.\r | |
125c2cf4 | 1059 | \r |
a405b86d | 1060 | @return The Destination after appending the Source.\r |
125c2cf4 | 1061 | **/\r |
1e6e84c7 | 1062 | CHAR16*\r |
125c2cf4 | 1063 | EFIAPI\r |
1064 | StrnCatGrow (\r | |
1065 | IN OUT CHAR16 **Destination,\r | |
1066 | IN OUT UINTN *CurrentSize,\r | |
1067 | IN CONST CHAR16 *Source,\r | |
1068 | IN UINTN Count\r | |
1069 | );\r | |
2247dde4 | 1070 | \r |
b3011f40 | 1071 | /**\r |
1e6e84c7 | 1072 | This is a find and replace function. Upon successful return the NewString is a copy of\r |
b3011f40 | 1073 | SourceString with each instance of FindTarget replaced with ReplaceWith.\r |
1074 | \r | |
1075 | If SourceString and NewString overlap the behavior is undefined.\r | |
1076 | \r | |
1077 | If the string would grow bigger than NewSize it will halt and return error.\r | |
1078 | \r | |
4ff7e37b ED |
1079 | @param[in] SourceString The string with source buffer.\r |
1080 | @param[in, out] NewString The string with resultant buffer.\r | |
1081 | @param[in] NewSize The size in bytes of NewString.\r | |
1082 | @param[in] FindTarget The string to look for.\r | |
1083 | @param[in] ReplaceWith The string to replace FindTarget with.\r | |
1084 | @param[in] SkipPreCarrot If TRUE will skip a FindTarget that has a '^'\r | |
1085 | immediately before it.\r | |
1086 | @param[in] ParameterReplacing If TRUE will add "" around items with spaces.\r | |
b3011f40 | 1087 | \r |
1088 | @retval EFI_INVALID_PARAMETER SourceString was NULL.\r | |
1089 | @retval EFI_INVALID_PARAMETER NewString was NULL.\r | |
1090 | @retval EFI_INVALID_PARAMETER FindTarget was NULL.\r | |
1091 | @retval EFI_INVALID_PARAMETER ReplaceWith was NULL.\r | |
1092 | @retval EFI_INVALID_PARAMETER FindTarget had length < 1.\r | |
1093 | @retval EFI_INVALID_PARAMETER SourceString had length < 1.\r | |
1e6e84c7 | 1094 | @retval EFI_BUFFER_TOO_SMALL NewSize was less than the minimum size to hold\r |
b3011f40 | 1095 | the new string (truncation occurred).\r |
a405b86d | 1096 | @retval EFI_SUCCESS The string was successfully copied with replacement.\r |
b3011f40 | 1097 | **/\r |
b3011f40 | 1098 | EFI_STATUS\r |
1099 | EFIAPI\r | |
a405b86d | 1100 | ShellCopySearchAndReplace(\r |
b3011f40 | 1101 | IN CHAR16 CONST *SourceString,\r |
a405b86d | 1102 | IN OUT CHAR16 *NewString,\r |
b3011f40 | 1103 | IN UINTN NewSize,\r |
1104 | IN CONST CHAR16 *FindTarget,\r | |
969c783b | 1105 | IN CONST CHAR16 *ReplaceWith,\r |
a405b86d | 1106 | IN CONST BOOLEAN SkipPreCarrot,\r |
1107 | IN CONST BOOLEAN ParameterReplacing\r | |
b3011f40 | 1108 | );\r |
1109 | \r | |
1110 | /**\r | |
1111 | Check if a Unicode character is a hexadecimal character.\r | |
1112 | \r | |
1e6e84c7 | 1113 | This internal function checks if a Unicode character is a\r |
a405b86d | 1114 | numeric character. The valid hexadecimal characters are\r |
b3011f40 | 1115 | L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r |
1116 | \r | |
b3011f40 | 1117 | \r |
a405b86d | 1118 | @param Char The character to check against.\r |
1119 | \r | |
1120 | @retval TRUE The Char is a hexadecmial character.\r | |
1121 | @retval FALSE The Char is not a hexadecmial character.\r | |
b3011f40 | 1122 | \r |
1123 | **/\r | |
1124 | BOOLEAN\r | |
1125 | EFIAPI\r | |
969c783b | 1126 | ShellIsHexaDecimalDigitCharacter (\r |
b3011f40 | 1127 | IN CHAR16 Char\r |
1128 | );\r | |
1129 | \r | |
a405b86d | 1130 | /**\r |
1131 | Check if a Unicode character is a decimal character.\r | |
1132 | \r | |
1133 | This internal function checks if a Unicode character is a\r | |
1134 | decimal character. The valid characters are\r | |
1135 | L'0' to L'9'.\r | |
1136 | \r | |
1137 | \r | |
1138 | @param Char The character to check against.\r | |
1139 | \r | |
1140 | @retval TRUE The Char is a hexadecmial character.\r | |
1141 | @retval FALSE The Char is not a hexadecmial character.\r | |
1142 | \r | |
1143 | **/\r | |
1144 | BOOLEAN\r | |
1145 | EFIAPI\r | |
1146 | ShellIsDecimalDigitCharacter (\r | |
1147 | IN CHAR16 Char\r | |
1148 | );\r | |
1149 | \r | |
334f978e | 1150 | ///\r |
a405b86d | 1151 | /// What type of answer is requested.\r |
334f978e | 1152 | ///\r |
1153 | typedef enum {\r | |
a405b86d | 1154 | ShellPromptResponseTypeYesNo,\r |
1155 | ShellPromptResponseTypeYesNoCancel,\r | |
1156 | ShellPromptResponseTypeFreeform,\r | |
1157 | ShellPromptResponseTypeQuitContinue,\r | |
1158 | ShellPromptResponseTypeYesNoAllCancel,\r | |
1159 | ShellPromptResponseTypeEnterContinue,\r | |
1160 | ShellPromptResponseTypeAnyKeyContinue,\r | |
1161 | ShellPromptResponseTypeMax\r | |
334f978e | 1162 | } SHELL_PROMPT_REQUEST_TYPE;\r |
1163 | \r | |
1164 | ///\r | |
a405b86d | 1165 | /// What answer was given.\r |
334f978e | 1166 | ///\r |
1167 | typedef enum {\r | |
a405b86d | 1168 | ShellPromptResponseYes,\r |
1169 | ShellPromptResponseNo,\r | |
1170 | ShellPromptResponseCancel,\r | |
1171 | ShellPromptResponseQuit,\r | |
1172 | ShellPromptResponseContinue,\r | |
1173 | ShellPromptResponseAll,\r | |
1174 | ShellPromptResponseMax\r | |
334f978e | 1175 | } SHELL_PROMPT_RESPONSE;\r |
1176 | \r | |
1177 | /**\r | |
1178 | Prompt the user and return the resultant answer to the requestor.\r | |
1179 | \r | |
1180 | This function will display the requested question on the shell prompt and then\r | |
1181 | wait for an apropriate answer to be input from the console.\r | |
1182 | \r | |
a405b86d | 1183 | If the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, ShellPromptResponseTypeQuitContinue\r |
334f978e | 1184 | or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.\r |
1185 | \r | |
a405b86d | 1186 | If the SHELL_PROMPT_REQUEST_TYPE is ShellPromptResponseTypeFreeform then *Response is of type\r |
334f978e | 1187 | CHAR16*.\r |
1188 | \r | |
1189 | In either case *Response must be callee freed if Response was not NULL;\r | |
1190 | \r | |
1191 | @param Type What type of question is asked. This is used to filter the input\r | |
1192 | to prevent invalid answers to question.\r | |
a405b86d | 1193 | @param Prompt The pointer to a string prompt used to request input.\r |
1194 | @param Response The pointer to Response, which will be populated upon return.\r | |
334f978e | 1195 | \r |
a405b86d | 1196 | @retval EFI_SUCCESS The operation was successful.\r |
334f978e | 1197 | @retval EFI_UNSUPPORTED The operation is not supported as requested.\r |
1198 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
1199 | @return other The operation failed.\r | |
1200 | **/\r | |
1201 | EFI_STATUS\r | |
1202 | EFIAPI\r | |
1203 | ShellPromptForResponse (\r | |
1204 | IN SHELL_PROMPT_REQUEST_TYPE Type,\r | |
1205 | IN CHAR16 *Prompt OPTIONAL,\r | |
1206 | IN OUT VOID **Response OPTIONAL\r | |
1207 | );\r | |
1208 | \r | |
1209 | /**\r | |
1210 | Prompt the user and return the resultant answer to the requestor.\r | |
1211 | \r | |
1212 | This function is the same as ShellPromptForResponse, except that the prompt is\r | |
1213 | automatically pulled from HII.\r | |
1214 | \r | |
4bbdc0e1 | 1215 | @param[in] Type What type of question is asked. This is used to filter the input\r |
334f978e | 1216 | to prevent invalid answers to question.\r |
4ff7e37b ED |
1217 | @param[in] HiiFormatStringId The format string Id for getting from Hii.\r |
1218 | @param[in] HiiFormatHandle The format string Handle for getting from Hii.\r | |
1219 | @param[in, out] Response The pointer to Response, which will be populated upon return.\r | |
334f978e | 1220 | \r |
a405b86d | 1221 | @retval EFI_SUCCESS The operation was sucessful.\r |
1222 | @return other The operation failed.\r | |
334f978e | 1223 | \r |
1224 | @sa ShellPromptForResponse\r | |
1225 | **/\r | |
1226 | EFI_STATUS\r | |
1227 | EFIAPI\r | |
1228 | ShellPromptForResponseHii (\r | |
1229 | IN SHELL_PROMPT_REQUEST_TYPE Type,\r | |
1230 | IN CONST EFI_STRING_ID HiiFormatStringId,\r | |
1231 | IN CONST EFI_HANDLE HiiFormatHandle,\r | |
1232 | IN OUT VOID **Response\r | |
1233 | );\r | |
1234 | \r | |
a405b86d | 1235 | /**\r |
1236 | Function to determin if an entire string is a valid number.\r | |
1237 | \r | |
4bbdc0e1 | 1238 | If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.\r |
a405b86d | 1239 | \r |
1240 | @param[in] String The string to evaluate.\r | |
1241 | @param[in] ForceHex TRUE - always assume hex.\r | |
1242 | @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to keep going.\r | |
1243 | \r | |
1244 | @retval TRUE It is all numeric (dec/hex) characters.\r | |
1245 | @retval FALSE There is a non-numeric character.\r | |
1246 | **/\r | |
1247 | BOOLEAN\r | |
1248 | EFIAPI\r | |
1249 | ShellIsHexOrDecimalNumber (\r | |
1250 | IN CONST CHAR16 *String,\r | |
1251 | IN CONST BOOLEAN ForceHex,\r | |
1252 | IN CONST BOOLEAN StopAtSpace\r | |
1253 | );\r | |
1254 | \r | |
4bbdc0e1 | 1255 | /**\r |
1256 | Function to verify and convert a string to its numerical 64 bit representation.\r | |
1257 | \r | |
1258 | If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.\r | |
1259 | \r | |
1260 | @param[in] String The string to evaluate.\r | |
1261 | @param[out] Value Upon a successful return the value of the conversion.\r | |
1262 | @param[in] ForceHex TRUE - always assume hex.\r | |
b0934ac4 | 1263 | @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to\r |
4bbdc0e1 | 1264 | process the entire String.\r |
b0934ac4 | 1265 | \r |
4bbdc0e1 | 1266 | @retval EFI_SUCCESS The conversion was successful.\r |
1267 | @retval EFI_INVALID_PARAMETER String contained an invalid character.\r | |
1268 | @retval EFI_NOT_FOUND String was a number, but Value was NULL.\r | |
1269 | **/\r | |
1270 | EFI_STATUS\r | |
1271 | EFIAPI\r | |
1272 | ShellConvertStringToUint64(\r | |
1273 | IN CONST CHAR16 *String,\r | |
1274 | OUT UINT64 *Value,\r | |
1275 | IN CONST BOOLEAN ForceHex,\r | |
1276 | IN CONST BOOLEAN StopAtSpace\r | |
1277 | );\r | |
1278 | \r | |
a405b86d | 1279 | /**\r |
1280 | Function to determine if a given filename exists.\r | |
1281 | \r | |
1282 | @param[in] Name Path to test.\r | |
1283 | \r | |
1284 | @retval EFI_SUCCESS The Path represents a file.\r | |
1285 | @retval EFI_NOT_FOUND The Path does not represent a file.\r | |
1286 | @retval other The path failed to open.\r | |
1287 | **/\r | |
1288 | EFI_STATUS\r | |
1289 | EFIAPI\r | |
1290 | ShellFileExists(\r | |
1291 | IN CONST CHAR16 *Name\r | |
1292 | );\r | |
334f978e | 1293 | \r |
4d0a4fce | 1294 | /**\r |
1295 | Function to read a single line from a SHELL_FILE_HANDLE. The \n is not included in the returned\r | |
1296 | buffer. The returned buffer must be callee freed.\r | |
1297 | \r | |
1298 | If the position upon start is 0, then the Ascii Boolean will be set. This should be\r | |
1299 | maintained and not changed for all operations with the same file.\r | |
1300 | \r | |
4ff7e37b ED |
1301 | @param[in] Handle SHELL_FILE_HANDLE to read from.\r |
1302 | @param[in, out] Ascii Boolean value for indicating whether the file is\r | |
1303 | Ascii (TRUE) or UCS2 (FALSE).\r | |
4d0a4fce | 1304 | \r |
4ff7e37b | 1305 | @return The line of text from the file.\r |
4d0a4fce | 1306 | \r |
1307 | @sa ShellFileHandleReadLine\r | |
1308 | **/\r | |
1309 | CHAR16*\r | |
1310 | EFIAPI\r | |
1311 | ShellFileHandleReturnLine(\r | |
1312 | IN SHELL_FILE_HANDLE Handle,\r | |
1313 | IN OUT BOOLEAN *Ascii\r | |
1314 | );\r | |
1315 | \r | |
1316 | /**\r | |
1317 | Function to read a single line (up to but not including the \n) from a SHELL_FILE_HANDLE.\r | |
1318 | \r | |
1319 | If the position upon start is 0, then the Ascii Boolean will be set. This should be\r | |
1320 | maintained and not changed for all operations with the same file.\r | |
1321 | \r | |
4ff7e37b ED |
1322 | @param[in] Handle SHELL_FILE_HANDLE to read from.\r |
1323 | @param[in, out] Buffer The pointer to buffer to read into.\r | |
1324 | @param[in, out] Size The pointer to number of bytes in Buffer.\r | |
1325 | @param[in] Truncate If the buffer is large enough, this has no effect.\r | |
1326 | If the buffer is is too small and Truncate is TRUE,\r | |
1327 | the line will be truncated.\r | |
1328 | If the buffer is is too small and Truncate is FALSE,\r | |
1329 | then no read will occur.\r | |
1330 | \r | |
1331 | @param[in, out] Ascii Boolean value for indicating whether the file is\r | |
1332 | Ascii (TRUE) or UCS2 (FALSE).\r | |
4d0a4fce | 1333 | \r |
1334 | @retval EFI_SUCCESS The operation was successful. The line is stored in\r | |
1335 | Buffer.\r | |
1336 | @retval EFI_INVALID_PARAMETER Handle was NULL.\r | |
1337 | @retval EFI_INVALID_PARAMETER Size was NULL.\r | |
1338 | @retval EFI_BUFFER_TOO_SMALL Size was not large enough to store the line.\r | |
1339 | Size was updated to the minimum space required.\r | |
1340 | **/\r | |
1341 | EFI_STATUS\r | |
1342 | EFIAPI\r | |
1343 | ShellFileHandleReadLine(\r | |
1344 | IN SHELL_FILE_HANDLE Handle,\r | |
1345 | IN OUT CHAR16 *Buffer,\r | |
1346 | IN OUT UINTN *Size,\r | |
1347 | IN BOOLEAN Truncate,\r | |
1348 | IN OUT BOOLEAN *Ascii\r | |
1349 | );\r | |
1350 | \r | |
fb5278ef | 1351 | /**\r |
1352 | Function to delete a file by name\r | |
1353 | \r | |
1354 | @param[in] FileName Pointer to file name to delete.\r | |
1355 | \r | |
1356 | @retval EFI_SUCCESS the file was deleted sucessfully\r | |
1357 | @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not\r | |
1358 | deleted\r | |
1359 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r | |
1360 | @retval EFI_NOT_FOUND The specified file could not be found on the\r | |
1361 | device or the file system could not be found\r | |
1362 | on the device.\r | |
1363 | @retval EFI_NO_MEDIA The device has no medium.\r | |
1364 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r | |
1365 | medium is no longer supported.\r | |
1366 | @retval EFI_DEVICE_ERROR The device reported an error.\r | |
1367 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r | |
1368 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r | |
1369 | @retval EFI_ACCESS_DENIED The file was opened read only.\r | |
1370 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r | |
1371 | file.\r | |
1372 | @retval other The file failed to open\r | |
1373 | **/\r | |
1374 | EFI_STATUS\r | |
1375 | EFIAPI\r | |
1376 | ShellDeleteFileByName(\r | |
1377 | IN CONST CHAR16 *FileName\r | |
1378 | );\r | |
1379 | \r | |
365aa98a | 1380 | /**\r |
1381 | Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.\r | |
1382 | \r | |
1383 | @param[in] CommandToGetHelpOn Pointer to a string containing the command name of help file to be printed.\r | |
1384 | @param[in] SectionToGetHelpOn Pointer to the section specifier(s).\r | |
1385 | @param[in] PrintCommandText If TRUE, prints the command followed by the help content, otherwise prints \r | |
1386 | the help content only.\r | |
1387 | @retval EFI_DEVICE_ERROR The help data format was incorrect.\r | |
1388 | @retval EFI_NOT_FOUND The help data could not be found.\r | |
1389 | @retval EFI_SUCCESS The operation was successful.\r | |
1390 | **/\r | |
1391 | EFI_STATUS\r | |
1392 | EFIAPI\r | |
1393 | ShellPrintHelp (\r | |
1394 | IN CONST CHAR16 *CommandToGetHelpOn,\r | |
1395 | IN CONST CHAR16 *SectionToGetHelpOn,\r | |
1396 | IN BOOLEAN PrintCommandText\r | |
1397 | );\r | |
1398 | \r | |
e9880e25 | 1399 | #endif // __SHELL_LIB__\r |