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