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