35 IN BOOLEAN SilentMode,
36 IN BOOLEAN RecursiveMode,
58 IN BOOLEAN SilentMode,
64 SHELL_FILE_HANDLE SourceHandle;
65 SHELL_FILE_HANDLE DestHandle;
72 UINT64 SourceFileSize;
76 UINTN DestVolumeInfoSize;
78 ASSERT (Resp !=
NULL);
84 DestVolumeInfo =
NULL;
87 ReadSize =
PcdGet32 (PcdShellFileOperationSize);
89 if (
StrCmp (Source, Dest) == 0) {
97 if ((Response ==
NULL) && !SilentMode) {
105 if (Response ==
NULL) {
110 case ShellPromptResponseNo:
115 case ShellPromptResponseCancel:
121 case ShellPromptResponseAll:
123 case ShellPromptResponseYes:
133 if (EFI_ERROR (Status)) {
145 if (TempName !=
NULL) {
147 *TempName = CHAR_NULL;
152 SHELL_FREE_NON_NULL (TempName);
161 Status =
ShellOpenFileByName (Dest, &DestHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
162 if (EFI_ERROR (Status)) {
171 if (EFI_ERROR (Status)) {
185 if (DestFileSize < SourceFileSize) {
186 SourceFileSize -= DestFileSize;
195 DestVolumeInfo =
NULL;
196 DestVolumeInfoSize = 0;
197 Status = DestVolumeFP->GetInfo (
199 &gEfiFileSystemInfoGuid,
204 if (Status == EFI_BUFFER_TOO_SMALL) {
206 if (DestVolumeInfo ==
NULL) {
212 Status = DestVolumeFP->GetInfo (
214 &gEfiFileSystemInfoGuid,
223 if ((DestVolumeInfo !=
NULL) && (DestVolumeInfo->
FreeSpace < SourceFileSize)) {
227 SHELL_FREE_NON_NULL (DestVolumeInfo);
235 if (Buffer ==
NULL) {
240 while (ReadSize ==
PcdGet32 (PcdShellFileOperationSize) && !EFI_ERROR (Status)) {
242 if (!EFI_ERROR (Status)) {
244 if (EFI_ERROR (Status)) {
257 SHELL_FREE_NON_NULL (DestVolumeInfo);
264 if (DestHandle !=
NULL) {
269 if (SourceHandle !=
NULL) {
304 IN BOOLEAN SilentMode,
305 IN BOOLEAN RecursiveMode,
319 CHAR16 *CleanFilePathStr;
331 CleanFilePathStr =
NULL;
333 ASSERT (FileList !=
NULL);
334 ASSERT (DestDir !=
NULL);
337 if (EFI_ERROR (Status)) {
338 if (Status == EFI_OUT_OF_RESOURCES) {
345 ASSERT (CleanFilePathStr !=
NULL);
350 if (EFI_ERROR (
ShellIsDirectory (CleanFilePathStr)) && (FileList->Link.ForwardLink != FileList->Link.BackLink)) {
360 ; !
IsNull (&FileList->Link, &Node->Link)
367 if ((
StrCmp (Node->FileName, L
".") == 0) || (
StrCmp (Node->FileName, L
"..") == 0)) {
371 NewSize =
StrSize (CleanFilePathStr);
372 NewSize +=
StrSize (Node->FullName);
373 NewSize += (Cwd ==
NULL) ? 0 : (
StrSize (Cwd) +
sizeof (CHAR16));
374 if (NewSize > PathSize) {
404 if ((DestPath ==
NULL) || (HiiOutput ==
NULL) || (HiiResultOk ==
NULL)) {
405 SHELL_FREE_NON_NULL (DestPath);
406 SHELL_FREE_NON_NULL (HiiOutput);
407 SHELL_FREE_NON_NULL (HiiResultOk);
416 ; !
IsNull (&FileList->Link, &Node->Link)
424 ASSERT (Node->FileName !=
NULL);
425 ASSERT (Node->FullName !=
NULL);
430 if ((
StrCmp (Node->FileName, L
".") == 0) || (
StrCmp (Node->FileName, L
"..") == 0)) {
434 if ( (FileList->Link.ForwardLink == FileList->Link.BackLink)
438 if (
StrStr (CleanFilePathStr, L
":") ==
NULL) {
443 StrCpyS (DestPath, PathSize /
sizeof (CHAR16), Cwd);
444 StrCatS (DestPath, PathSize /
sizeof (CHAR16), L
"\\");
451 if ((DestPath[
StrLen (DestPath)-1] != L
'\\') && (CleanFilePathStr[0] != L
'\\')) {
452 StrCatS (DestPath, PathSize /
sizeof (CHAR16), L
"\\");
453 }
else if ((DestPath[
StrLen (DestPath)-1] == L
'\\') && (CleanFilePathStr[0] == L
'\\')) {
454 ((CHAR16 *)DestPath)[
StrLen (DestPath)-1] = CHAR_NULL;
457 StrCatS (DestPath, PathSize/
sizeof (CHAR16), CleanFilePathStr);
459 StrCpyS (DestPath, PathSize/
sizeof (CHAR16), CleanFilePathStr);
469 if (CleanFilePathStr[0] == L
'\\') {
474 StrCpyS (DestPath, PathSize/
sizeof (CHAR16), Cwd);
475 StrCatS (DestPath, PathSize/
sizeof (CHAR16), L
"\\");
485 StrCatS (DestPath, PathSize/
sizeof (CHAR16), CleanFilePathStr+1);
486 StrCatS (DestPath, PathSize/
sizeof (CHAR16), Node->FileName);
487 }
else if (
StrStr (CleanFilePathStr, L
":") ==
NULL) {
489 StrCpyS (DestPath, PathSize/
sizeof (CHAR16), Cwd);
490 StrCatS (DestPath, PathSize/
sizeof (CHAR16), L
"\\");
497 if ((DestPath[
StrLen (DestPath)-1] != L
'\\') && (CleanFilePathStr[0] != L
'\\')) {
498 StrCatS (DestPath, PathSize/
sizeof (CHAR16), L
"\\");
499 }
else if ((DestPath[
StrLen (DestPath)-1] == L
'\\') && (CleanFilePathStr[0] == L
'\\')) {
500 ((CHAR16 *)DestPath)[
StrLen (DestPath)-1] = CHAR_NULL;
503 StrCatS (DestPath, PathSize/
sizeof (CHAR16), CleanFilePathStr);
504 if ((CleanFilePathStr[
StrLen (CleanFilePathStr)-1] != L
'\\') && (Node->FileName[0] != L
'\\')) {
505 StrCatS (DestPath, PathSize/
sizeof (CHAR16), L
"\\");
506 }
else if ((CleanFilePathStr[
StrLen (CleanFilePathStr)-1] == L
'\\') && (Node->FileName[0] == L
'\\')) {
507 ((CHAR16 *)DestPath)[
StrLen (DestPath)-1] = CHAR_NULL;
510 StrCatS (DestPath, PathSize/
sizeof (CHAR16), Node->FileName);
512 StrCpyS (DestPath, PathSize/
sizeof (CHAR16), CleanFilePathStr);
513 if ((CleanFilePathStr[
StrLen (CleanFilePathStr)-1] != L
'\\') && (Node->FileName[0] != L
'\\')) {
514 StrCatS (DestPath, PathSize/
sizeof (CHAR16), L
"\\");
515 }
else if ((CleanFilePathStr[
StrLen (CleanFilePathStr)-1] == L
'\\') && (Node->FileName[0] == L
'\\')) {
516 ((CHAR16 *)CleanFilePathStr)[
StrLen (CleanFilePathStr)-1] = CHAR_NULL;
519 StrCatS (DestPath, PathSize/
sizeof (CHAR16), Node->FileName);
548 if ( (
StrniCmp (Node->FullName, DestPath,
StrLen (Node->FullName)) == 0)
549 && ((DestPath[
StrLen (Node->FullName)] == CHAR_NULL) || (DestPath[
StrLen (Node->FullName)] == L
'\\'))
560 ShellPrintEx (-1, -1, HiiOutput, Node->FullName, DestPath);
566 ShellStatus =
CopySingleFile (Node->FullName, DestPath, &Response, SilentMode, L
"cp");
576 SHELL_FREE_NON_NULL (DestPath);
577 SHELL_FREE_NON_NULL (HiiOutput);
578 SHELL_FREE_NON_NULL (HiiResultOk);
579 SHELL_FREE_NON_NULL (CleanFilePathStr);
581 SHELL_FREE_NON_NULL (Response);
584 return (ShellStatus);
603 IN BOOLEAN SilentMode,
604 IN BOOLEAN RecursiveMode
617 if ((List !=
NULL) && (List->
Link.ForwardLink != List->
Link.BackLink)) {
621 }
else if (List !=
NULL) {
640 SHELL_FREE_NON_NULL (FullName);
641 return (ShellStatus);
665 CHAR16 *ProblemParam;
671 BOOLEAN RecursiveMode;
693 if (EFI_ERROR (Status)) {
694 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam !=
NULL)) {
712 if (gEfiShellProtocol->BatchIsActive ()) {
744 if (FullCwd ==
NULL) {
760 for (ParamCount--, LoopCounter = 1; LoopCounter < ParamCount && ShellStatus ==
SHELL_SUCCESS; LoopCounter++) {
791 if (FileList !=
NULL) {
805 return (ShellStatus);
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
RETURN_STATUS EFIAPI StrCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
CHAR16 *EFIAPI PathCleanUpDirectories(IN CHAR16 *Path)
BOOLEAN EFIAPI PathRemoveLastItem(IN OUT CHAR16 *Path)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
SHELL_STATUS ValidateAndCopyFiles(IN CONST EFI_SHELL_FILE_INFO *FileList, IN CONST CHAR16 *DestDir, IN BOOLEAN SilentMode, IN BOOLEAN RecursiveMode, IN VOID **Resp)
SHELL_STATUS EFIAPI ShellCommandRunCp(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
SHELL_STATUS ProcessValidateAndCopyFiles(IN EFI_SHELL_FILE_INFO *FileList, IN CONST CHAR16 *DestDir, IN BOOLEAN SilentMode, IN BOOLEAN RecursiveMode)
SHELL_STATUS CopySingleFile(IN CONST CHAR16 *Source, IN CONST CHAR16 *Dest, OUT VOID **Resp, IN BOOLEAN SilentMode, IN CONST CHAR16 *CmdName)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
#define ASSERT_EFI_ERROR(StatusParameter)
@ SHELL_INVALID_PARAMETER
#define PcdGet32(TokenName)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
EFI_STATUS EFIAPI CommandInit(VOID)
EFI_FILE_PROTOCOL *EFIAPI ConvertShellHandleToEfiFileProtocol(IN CONST SHELL_FILE_HANDLE Handle)
EFI_STATUS EFIAPI ShellGetFileSize(IN SHELL_FILE_HANDLE FileHandle, OUT UINT64 *Size)
CONST CHAR16 *EFIAPI ShellGetCurrentDir(IN CHAR16 *CONST DeviceName OPTIONAL)
BOOLEAN EFIAPI ShellGetExecutionBreakFlag(VOID)
EFI_STATUS EFIAPI ShellDeleteFileByName(IN CONST CHAR16 *FileName)
EFI_STATUS EFIAPI ShellPromptForResponseHii(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle, IN OUT VOID **Response)
EFI_STATUS EFIAPI ShellCreateDirectory(IN CONST CHAR16 *DirectoryName, OUT SHELL_FILE_HANDLE *FileHandle)
EFI_STATUS EFIAPI ShellCloseFileMetaArg(IN OUT EFI_SHELL_FILE_INFO **ListHead)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeFlag
A flag that is present or not present only (IE "-a").
EFI_STATUS EFIAPI ShellOpenFileByName(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode, IN UINT64 Attributes)
CHAR16 *EFIAPI StrnCatGrow(IN OUT CHAR16 **Destination, IN OUT UINTN *CurrentSize, IN CONST CHAR16 *Source, IN UINTN Count)
EFI_STATUS EFIAPI ShellFileExists(IN CONST CHAR16 *Name)
EFI_STATUS EFIAPI ShellOpenFileMetaArg(IN CHAR16 *Arg, IN UINT64 OpenMode, IN OUT EFI_SHELL_FILE_INFO **ListHead)
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
EFI_STATUS EFIAPI ShellIsDirectory(IN CONST CHAR16 *DirName)
EFI_STATUS EFIAPI ShellPrintEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR16 *Format,...)
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellWriteFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI ShellCloseFile(IN SHELL_FILE_HANDLE *FileHandle)
EFI_STATUS EFIAPI ShellReadFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
INTN EFIAPI StringNoCaseCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
INTN StrniCmp(IN CONST CHAR16 *Source, IN CONST CHAR16 *Target, IN CONST UINTN Count)
EFI_STATUS VerifyIntermediateDirectories(IN CONST CHAR16 *Path)
EFI_STATUS ShellLevel2StripQuotes(IN CONST CHAR16 *OriginalString, OUT CHAR16 **CleanString)
LIST_ENTRY Link
Linked list members.