2 Main file for cp shell level 2 function.
4 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "UefiShellLevel2CommandsLib.h"
16 #include <Guid/FileSystemInfo.h>
17 #include <Guid/FileSystemVolumeLabelInfo.h>
20 Function to take a list of files to copy and a destination location and do
21 the verification and copying of those files to that location. This function
22 will report any errors to the user and halt.
24 @param[in] FileList A LIST_ENTRY* based list of files to move.
25 @param[in] DestDir The destination location.
26 @param[in] SilentMode TRUE to eliminate screen output.
27 @param[in] RecursiveMode TRUE to copy directories.
28 @param[in] Resp The response to the overwrite query (if always).
30 @retval SHELL_SUCCESS the files were all moved.
31 @retval SHELL_INVALID_PARAMETER a parameter was invalid
32 @retval SHELL_SECURITY_VIOLATION a security violation ocurred
33 @retval SHELL_WRITE_PROTECTED the destination was write protected
34 @retval SHELL_OUT_OF_RESOURCES a memory allocation failed
39 IN CONST EFI_SHELL_FILE_INFO
*FileList
,
40 IN CONST CHAR16
*DestDir
,
41 IN BOOLEAN SilentMode
,
42 IN BOOLEAN RecursiveMode
,
47 Function to Copy one file to another location
49 If the destination exists the user will be prompted and the result put into *resp
51 @param[in] Source pointer to source file name
52 @param[in] Dest pointer to destination file name
53 @param[out] Resp pointer to response from question. Pass back on looped calling
54 @param[in] SilentMode whether to run in quiet mode or not
56 @retval SHELL_SUCCESS The source file was copied to the destination
61 IN CONST CHAR16
*Source
,
62 IN CONST CHAR16
*Dest
,
69 SHELL_FILE_HANDLE SourceHandle
;
70 SHELL_FILE_HANDLE DestHandle
;
75 EFI_SHELL_FILE_INFO
*List
;
76 SHELL_STATUS ShellStatus
;
77 UINT64 SourceFileSize
;
79 EFI_FILE_PROTOCOL
*DestVolumeFP
;
80 EFI_FILE_SYSTEM_INFO
*DestVolumeInfo
;
81 UINTN DestVolumeInfoSize
;
89 DestVolumeInfo
= NULL
;
90 ShellStatus
= SHELL_SUCCESS
;
92 ReadSize
= PcdGet16(PcdShellFileOperationSize
);
93 // Why bother copying a file to itself
94 if (StrCmp(Source
, Dest
) == 0) {
95 return (SHELL_SUCCESS
);
99 // Open destination file without create
101 Status
= ShellOpenFileByName(Dest
, &DestHandle
, EFI_FILE_MODE_READ
|EFI_FILE_MODE_WRITE
, 0);
106 if (DestHandle
!= NULL
) {
107 ShellCloseFile(&DestHandle
);
112 // if the destination file existed check response and possibly prompt user
114 if (!EFI_ERROR(Status
)) {
115 if (Response
== NULL
&& !SilentMode
) {
116 Status
= ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel
, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR
), gShellLevel2HiiHandle
, &Response
);
119 // possibly return based on response
122 switch (*(SHELL_PROMPT_RESPONSE
*)Response
) {
123 case ShellPromptResponseNo
:
125 // return success here so we dont stop the process
127 return (SHELL_SUCCESS
);
128 case ShellPromptResponseCancel
:
131 // indicate to stop everything
133 return (SHELL_ABORTED
);
134 case ShellPromptResponseAll
:
136 case ShellPromptResponseYes
:
139 return SHELL_ABORTED
;
144 if (ShellIsDirectory(Source
) == EFI_SUCCESS
) {
145 Status
= ShellCreateDirectory(Dest
, &DestHandle
);
146 if (EFI_ERROR(Status
)) {
147 return (SHELL_ACCESS_DENIED
);
151 // Now copy all the files under the directory...
155 StrnCatGrow(&TempName
, &Size
, Source
, 0);
156 StrnCatGrow(&TempName
, &Size
, L
"\\*", 0);
157 if (TempName
!= NULL
) {
158 ShellOpenFileMetaArg((CHAR16
*)TempName
, EFI_FILE_MODE_READ
, &List
);
159 *TempName
= CHAR_NULL
;
160 StrnCatGrow(&TempName
, &Size
, Dest
, 0);
161 StrnCatGrow(&TempName
, &Size
, L
"\\", 0);
162 ShellStatus
= ValidateAndCopyFiles(List
, TempName
, SilentMode
, TRUE
, Resp
);
163 ShellCloseFileMetaArg(&List
);
164 SHELL_FREE_NON_NULL(TempName
);
169 // open file with create enabled
171 Status
= ShellOpenFileByName(Dest
, &DestHandle
, EFI_FILE_MODE_READ
|EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_CREATE
, 0);
172 if (EFI_ERROR(Status
)) {
173 return (SHELL_ACCESS_DENIED
);
179 Status
= ShellOpenFileByName(Source
, &SourceHandle
, EFI_FILE_MODE_READ
, 0);
180 ASSERT_EFI_ERROR(Status
);
183 //get file size of source file and freespace available on destination volume
185 ShellGetFileSize(SourceHandle
, &SourceFileSize
);
186 ShellGetFileSize(DestHandle
, &DestFileSize
);
189 //if the destination file already exists then it will be replaced, meaning the sourcefile effectively needs less storage space
191 if(DestFileSize
< SourceFileSize
){
192 SourceFileSize
-= DestFileSize
;
198 //get the system volume info to check the free space
200 DestVolumeFP
= ConvertShellHandleToEfiFileProtocol(DestHandle
);
201 DestVolumeInfo
= NULL
;
202 DestVolumeInfoSize
= 0;
203 Status
= DestVolumeFP
->GetInfo(
205 &gEfiFileSystemInfoGuid
,
210 if (Status
== EFI_BUFFER_TOO_SMALL
) {
211 DestVolumeInfo
= AllocateZeroPool(DestVolumeInfoSize
);
212 Status
= DestVolumeFP
->GetInfo(
214 &gEfiFileSystemInfoGuid
,
221 //check if enough space available on destination drive to complete copy
223 if (DestVolumeInfo
!= NULL
&& (DestVolumeInfo
->FreeSpace
< SourceFileSize
)) {
225 //not enough space on destination directory to copy file
227 SHELL_FREE_NON_NULL(DestVolumeInfo
);
228 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_CPY_FAIL
), gShellLevel2HiiHandle
);
229 return(SHELL_VOLUME_FULL
);
232 // copy data between files
234 Buffer
= AllocateZeroPool(ReadSize
);
235 ASSERT(Buffer
!= NULL
);
236 while (ReadSize
== PcdGet16(PcdShellFileOperationSize
) && !EFI_ERROR(Status
)) {
237 Status
= ShellReadFile(SourceHandle
, &ReadSize
, Buffer
);
238 Status
= ShellWriteFile(DestHandle
, &ReadSize
, Buffer
);
241 SHELL_FREE_NON_NULL(DestVolumeInfo
);
247 if (DestHandle
!= NULL
) {
248 ShellCloseFile(&DestHandle
);
251 if (SourceHandle
!= NULL
) {
252 ShellCloseFile(&SourceHandle
);
263 function to take a list of files to copy and a destination location and do
264 the verification and copying of those files to that location. This function
265 will report any errors to the user and halt.
267 The key is to have this function called ONLY once. this allows for the parameter
268 verification to happen correctly.
270 @param[in] FileList A LIST_ENTRY* based list of files to move.
271 @param[in] DestDir The destination location.
272 @param[in] SilentMode TRUE to eliminate screen output.
273 @param[in] RecursiveMode TRUE to copy directories.
274 @param[in] Resp The response to the overwrite query (if always).
276 @retval SHELL_SUCCESS the files were all moved.
277 @retval SHELL_INVALID_PARAMETER a parameter was invalid
278 @retval SHELL_SECURITY_VIOLATION a security violation ocurred
279 @retval SHELL_WRITE_PROTECTED the destination was write protected
280 @retval SHELL_OUT_OF_RESOURCES a memory allocation failed
284 ValidateAndCopyFiles(
285 IN CONST EFI_SHELL_FILE_INFO
*FileList
,
286 IN CONST CHAR16
*DestDir
,
287 IN BOOLEAN SilentMode
,
288 IN BOOLEAN RecursiveMode
,
294 CONST EFI_SHELL_FILE_INFO
*Node
;
295 SHELL_STATUS ShellStatus
;
300 CONST CHAR16
*TempLocation
;
310 ShellStatus
= SHELL_SUCCESS
;
312 Cwd
= ShellGetCurrentDir(NULL
);
314 ASSERT(FileList
!= NULL
);
315 ASSERT(DestDir
!= NULL
);
318 // We already verified that this was present.
323 // If we are trying to copy multiple files... make sure we got a directory for the target...
325 if (EFI_ERROR(ShellIsDirectory(DestDir
)) && FileList
->Link
.ForwardLink
!= FileList
->Link
.BackLink
) {
327 // Error for destination not a directory
329 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NOT_DIR
), gShellLevel2HiiHandle
, DestDir
);
330 return (SHELL_INVALID_PARAMETER
);
332 for (Node
= (EFI_SHELL_FILE_INFO
*)GetFirstNode(&FileList
->Link
)
333 ; !IsNull(&FileList
->Link
, &Node
->Link
)
334 ; Node
= (EFI_SHELL_FILE_INFO
*)GetNextNode(&FileList
->Link
, &Node
->Link
)
337 // skip the directory traversing stuff...
339 if (StrCmp(Node
->FileName
, L
".") == 0 || StrCmp(Node
->FileName
, L
"..") == 0) {
343 NewSize
= StrSize(DestDir
);
344 NewSize
+= StrSize(Node
->FullName
);
345 NewSize
+= StrSize(Cwd
);
346 if (NewSize
> PathLen
) {
351 // Make sure got -r if required
353 if (!RecursiveMode
&& !EFI_ERROR(ShellIsDirectory(Node
->FullName
))) {
354 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_DIR_REQ
), gShellLevel2HiiHandle
);
355 return (SHELL_INVALID_PARAMETER
);
359 // make sure got dest as dir if needed
361 if (!EFI_ERROR(ShellIsDirectory(Node
->FullName
)) && EFI_ERROR(ShellIsDirectory(DestDir
))) {
363 // Error for destination not a directory
365 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NOT_DIR
), gShellLevel2HiiHandle
, DestDir
);
366 return (SHELL_INVALID_PARAMETER
);
370 HiiOutput
= HiiGetString (gShellLevel2HiiHandle
, STRING_TOKEN (STR_CP_OUTPUT
), NULL
);
371 HiiResultOk
= HiiGetString (gShellLevel2HiiHandle
, STRING_TOKEN (STR_GEN_RES_OK
), NULL
);
372 DestPath
= AllocateZeroPool(PathLen
);
374 if (DestPath
== NULL
|| HiiOutput
== NULL
|| HiiResultOk
== NULL
) {
375 SHELL_FREE_NON_NULL(DestPath
);
376 SHELL_FREE_NON_NULL(HiiOutput
);
377 SHELL_FREE_NON_NULL(HiiResultOk
);
378 return (SHELL_OUT_OF_RESOURCES
);
382 // Go through the list of files to copy...
384 for (Node
= (EFI_SHELL_FILE_INFO
*)GetFirstNode(&FileList
->Link
)
385 ; !IsNull(&FileList
->Link
, &Node
->Link
)
386 ; Node
= (EFI_SHELL_FILE_INFO
*)GetNextNode(&FileList
->Link
, &Node
->Link
)
388 if (ShellGetExecutionBreakFlag()) {
391 ASSERT(Node
->FileName
!= NULL
);
392 ASSERT(Node
->FullName
!= NULL
);
395 // skip the directory traversing stuff...
397 if (StrCmp(Node
->FileName
, L
".") == 0 || StrCmp(Node
->FileName
, L
"..") == 0) {
401 if (FileList
->Link
.ForwardLink
== FileList
->Link
.BackLink
// 1 item
402 && EFI_ERROR(ShellIsDirectory(DestDir
)) // not an existing directory
404 if (StrStr(DestDir
, L
":") == NULL
) {
406 // simple copy of a single file
408 StrCpy(DestPath
, Cwd
);
409 if (DestPath
[StrLen(DestPath
)-1] != L
'\\' && DestDir
[0] != L
'\\') {
410 StrCat(DestPath
, L
"\\");
411 } else if (DestPath
[StrLen(DestPath
)-1] == L
'\\' && DestDir
[0] == L
'\\') {
412 ((CHAR16
*)DestPath
)[StrLen(DestPath
)-1] = CHAR_NULL
;
414 StrCat(DestPath
, DestDir
);
416 StrCpy(DestPath
, DestDir
);
420 // we have multiple files or a directory in the DestDir
424 // Check for leading slash
426 if (DestDir
[0] == L
'\\') {
428 // Copy to the root of CWD
430 StrCpy(DestPath
, Cwd
);
431 while (PathRemoveLastItem(DestPath
));
432 StrCat(DestPath
, DestDir
+1);
433 StrCat(DestPath
, Node
->FileName
);
434 } else if (StrStr(DestDir
, L
":") == NULL
) {
435 StrCpy(DestPath
, Cwd
);
436 if (DestPath
[StrLen(DestPath
)-1] != L
'\\' && DestDir
[0] != L
'\\') {
437 StrCat(DestPath
, L
"\\");
438 } else if (DestPath
[StrLen(DestPath
)-1] == L
'\\' && DestDir
[0] == L
'\\') {
439 ((CHAR16
*)DestPath
)[StrLen(DestPath
)-1] = CHAR_NULL
;
441 StrCat(DestPath
, DestDir
);
442 if (DestDir
[StrLen(DestDir
)-1] != L
'\\' && Node
->FileName
[0] != L
'\\') {
443 StrCat(DestPath
, L
"\\");
444 } else if (DestDir
[StrLen(DestDir
)-1] == L
'\\' && Node
->FileName
[0] == L
'\\') {
445 ((CHAR16
*)DestPath
)[StrLen(DestPath
)-1] = CHAR_NULL
;
447 StrCat(DestPath
, Node
->FileName
);
450 StrCpy(DestPath
, DestDir
);
451 if (DestDir
[StrLen(DestDir
)-1] != L
'\\' && Node
->FileName
[0] != L
'\\') {
452 StrCat(DestPath
, L
"\\");
453 } else if (DestDir
[StrLen(DestDir
)-1] == L
'\\' && Node
->FileName
[0] == L
'\\') {
454 ((CHAR16
*)DestDir
)[StrLen(DestDir
)-1] = CHAR_NULL
;
456 StrCat(DestPath
, Node
->FileName
);
461 // Make sure the path exists
463 if (EFI_ERROR(VerifyIntermediateDirectories(DestPath
))) {
464 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_DIR_WNF
), gShellLevel2HiiHandle
);
465 ShellStatus
= SHELL_DEVICE_ERROR
;
469 if ( !EFI_ERROR(ShellIsDirectory(Node
->FullName
))
470 && !EFI_ERROR(ShellIsDirectory(DestPath
))
471 && StrniCmp(Node
->FullName
, DestPath
, StrLen(DestPath
)) == NULL
473 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_SD_PARENT
), gShellLevel2HiiHandle
);
474 ShellStatus
= SHELL_INVALID_PARAMETER
;
477 if (StringNoCaseCompare(&Node
->FullName
, &DestPath
) == 0) {
478 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_SD_SAME
), gShellLevel2HiiHandle
);
479 ShellStatus
= SHELL_INVALID_PARAMETER
;
483 if ((TempLocation
= StrniCmp(Node
->FullName
, DestPath
, StrLen(Node
->FullName
))) == 0
484 && (DestPath
[StrLen(Node
->FullName
)] == CHAR_NULL
|| DestPath
[StrLen(Node
->FullName
)] == L
'\\')
486 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_SD_SAME
), gShellLevel2HiiHandle
);
487 ShellStatus
= SHELL_INVALID_PARAMETER
;
491 PathCleanUpDirectories(DestPath
);
493 ShellPrintEx(-1, -1, HiiOutput
, Node
->FullName
, DestPath
);
496 // copy single file...
498 ShellStatus
= CopySingleFile(Node
->FullName
, DestPath
, &Response
, SilentMode
);
499 if (ShellStatus
!= SHELL_SUCCESS
) {
503 if (ShellStatus
== SHELL_SUCCESS
&& Resp
== NULL
) {
504 ShellPrintEx(-1, -1, L
"%s", HiiResultOk
);
507 SHELL_FREE_NON_NULL(DestPath
);
508 SHELL_FREE_NON_NULL(HiiOutput
);
509 SHELL_FREE_NON_NULL(HiiResultOk
);
511 SHELL_FREE_NON_NULL(Response
);
514 return (ShellStatus
);
519 Validate and if successful copy all the files from the list into
520 destination directory.
522 @param[in] FileList The list of files to copy.
523 @param[in] DestDir The directory to copy files to.
524 @param[in] SilentMode TRUE to eliminate screen output.
525 @param[in] RecursiveMode TRUE to copy directories.
527 @retval SHELL_INVALID_PARAMETER A parameter was invalid.
528 @retval SHELL_SUCCESS The operation was successful.
532 ProcessValidateAndCopyFiles(
533 IN EFI_SHELL_FILE_INFO
*FileList
,
534 IN CONST CHAR16
*DestDir
,
535 IN BOOLEAN SilentMode
,
536 IN BOOLEAN RecursiveMode
539 SHELL_STATUS ShellStatus
;
540 EFI_SHELL_FILE_INFO
*List
;
541 EFI_FILE_INFO
*FileInfo
;
545 ShellOpenFileMetaArg((CHAR16
*)DestDir
, EFI_FILE_MODE_READ
, &List
);
546 if (List
!= NULL
&& List
->Link
.ForwardLink
!= List
->Link
.BackLink
) {
547 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_MARG_ERROR
), gShellLevel2HiiHandle
, DestDir
);
548 ShellStatus
= SHELL_INVALID_PARAMETER
;
549 ShellCloseFileMetaArg(&List
);
550 } else if (List
!= NULL
) {
551 ASSERT(((EFI_SHELL_FILE_INFO
*)List
->Link
.ForwardLink
) != NULL
);
552 ASSERT(((EFI_SHELL_FILE_INFO
*)List
->Link
.ForwardLink
)->FullName
!= NULL
);
554 FileInfo
= gEfiShellProtocol
->GetFileInfo(((EFI_SHELL_FILE_INFO
*)List
->Link
.ForwardLink
)->Handle
);
555 ASSERT(FileInfo
!= NULL
);
556 if ((FileInfo
->Attribute
& EFI_FILE_READ_ONLY
) == 0) {
557 ShellStatus
= ValidateAndCopyFiles(FileList
, ((EFI_SHELL_FILE_INFO
*)List
->Link
.ForwardLink
)->FullName
, SilentMode
, RecursiveMode
, NULL
);
559 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_DEST_ERROR
), gShellLevel2HiiHandle
);
560 ShellStatus
= SHELL_ACCESS_DENIED
;
562 SHELL_FREE_NON_NULL(FileInfo
);
563 ShellCloseFileMetaArg(&List
);
565 ShellStatus
= ValidateAndCopyFiles(FileList
, DestDir
, SilentMode
, RecursiveMode
, NULL
);
568 return (ShellStatus
);
571 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
578 Function for 'cp' command.
580 @param[in] ImageHandle Handle to the Image (NULL if Internal).
581 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
586 IN EFI_HANDLE ImageHandle
,
587 IN EFI_SYSTEM_TABLE
*SystemTable
592 CHAR16
*ProblemParam
;
593 SHELL_STATUS ShellStatus
;
596 EFI_SHELL_FILE_INFO
*FileList
;
598 BOOLEAN RecursiveMode
;
602 ShellStatus
= SHELL_SUCCESS
;
607 // initialize the shell lib (we must be in non-auto-init...)
609 Status
= ShellInitialize();
610 ASSERT_EFI_ERROR(Status
);
612 Status
= CommandInit();
613 ASSERT_EFI_ERROR(Status
);
616 // parse the command line
618 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
619 if (EFI_ERROR(Status
)) {
620 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
621 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, ProblemParam
);
622 FreePool(ProblemParam
);
623 ShellStatus
= SHELL_INVALID_PARAMETER
;
631 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
636 // Initialize SilentMode and RecursiveMode
638 if (gEfiShellProtocol
->BatchIsActive()) {
641 SilentMode
= ShellCommandLineGetFlag(Package
, L
"-q");
643 RecursiveMode
= ShellCommandLineGetFlag(Package
, L
"-r");
645 switch (ParamCount
= ShellCommandLineGetCount(Package
)) {
649 // we have insufficient parameters
651 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellLevel2HiiHandle
);
652 ShellStatus
= SHELL_INVALID_PARAMETER
;
656 // must have valid CWD for single parameter...
658 Cwd
= ShellGetCurrentDir(NULL
);
660 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_CWD
), gShellLevel2HiiHandle
);
661 ShellStatus
= SHELL_INVALID_PARAMETER
;
663 Status
= ShellOpenFileMetaArg((CHAR16
*)ShellCommandLineGetRawValue(Package
, 1), EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_READ
, &FileList
);
664 if (FileList
== NULL
|| IsListEmpty(&FileList
->Link
) || EFI_ERROR(Status
)) {
665 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_FILE_NF
), gShellLevel2HiiHandle
, ShellCommandLineGetRawValue(Package
, 1));
666 ShellStatus
= SHELL_NOT_FOUND
;
668 ShellStatus
= ProcessValidateAndCopyFiles(FileList
, Cwd
, SilentMode
, RecursiveMode
);
675 // Make a big list of all the files...
677 for (ParamCount
--, LoopCounter
= 1 ; LoopCounter
< ParamCount
&& ShellStatus
== SHELL_SUCCESS
; LoopCounter
++) {
678 if (ShellGetExecutionBreakFlag()) {
681 Status
= ShellOpenFileMetaArg((CHAR16
*)ShellCommandLineGetRawValue(Package
, LoopCounter
), EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_READ
, &FileList
);
682 if (EFI_ERROR(Status
) || FileList
== NULL
|| IsListEmpty(&FileList
->Link
)) {
683 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_FILE_NF
), gShellLevel2HiiHandle
, ShellCommandLineGetRawValue(Package
, LoopCounter
));
684 ShellStatus
= SHELL_NOT_FOUND
;
687 if (ShellStatus
!= SHELL_SUCCESS
) {
688 Status
= ShellCloseFileMetaArg(&FileList
);
691 // now copy them all...
693 if (FileList
!= NULL
&& !IsListEmpty(&FileList
->Link
)) {
694 ShellStatus
= ProcessValidateAndCopyFiles(FileList
, PathCleanUpDirectories((CHAR16
*)ShellCommandLineGetRawValue(Package
, ParamCount
)), SilentMode
, RecursiveMode
);
695 Status
= ShellCloseFileMetaArg(&FileList
);
696 if (EFI_ERROR(Status
) && ShellStatus
== SHELL_SUCCESS
) {
697 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_FILE
), gShellLevel2HiiHandle
, ShellCommandLineGetRawValue(Package
, ParamCount
), ShellStatus
|MAX_BIT
);
698 ShellStatus
= SHELL_ACCESS_DENIED
;
703 } // switch on parameter count
705 if (FileList
!= NULL
) {
706 ShellCloseFileMetaArg(&FileList
);
710 // free the command line package
712 ShellCommandLineFreeVarList (Package
);
715 if (ShellGetExecutionBreakFlag()) {
716 return (SHELL_ABORTED
);
719 return (ShellStatus
);