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
= PcdGet32(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
== PcdGet32(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 // If we are trying to copy multiple files... make sure we got a directory for the target...
320 if (EFI_ERROR(ShellIsDirectory(DestDir
)) && FileList
->Link
.ForwardLink
!= FileList
->Link
.BackLink
) {
322 // Error for destination not a directory
324 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NOT_DIR
), gShellLevel2HiiHandle
, DestDir
);
325 return (SHELL_INVALID_PARAMETER
);
327 for (Node
= (EFI_SHELL_FILE_INFO
*)GetFirstNode(&FileList
->Link
)
328 ; !IsNull(&FileList
->Link
, &Node
->Link
)
329 ; Node
= (EFI_SHELL_FILE_INFO
*)GetNextNode(&FileList
->Link
, &Node
->Link
)
332 // skip the directory traversing stuff...
334 if (StrCmp(Node
->FileName
, L
".") == 0 || StrCmp(Node
->FileName
, L
"..") == 0) {
338 NewSize
= StrSize(DestDir
);
339 NewSize
+= StrSize(Node
->FullName
);
340 NewSize
+= (Cwd
== NULL
)? 0 : StrSize(Cwd
);
341 if (NewSize
> PathLen
) {
346 // Make sure got -r if required
348 if (!RecursiveMode
&& !EFI_ERROR(ShellIsDirectory(Node
->FullName
))) {
349 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_DIR_REQ
), gShellLevel2HiiHandle
);
350 return (SHELL_INVALID_PARAMETER
);
354 // make sure got dest as dir if needed
356 if (!EFI_ERROR(ShellIsDirectory(Node
->FullName
)) && EFI_ERROR(ShellIsDirectory(DestDir
))) {
358 // Error for destination not a directory
360 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NOT_DIR
), gShellLevel2HiiHandle
, DestDir
);
361 return (SHELL_INVALID_PARAMETER
);
365 HiiOutput
= HiiGetString (gShellLevel2HiiHandle
, STRING_TOKEN (STR_CP_OUTPUT
), NULL
);
366 HiiResultOk
= HiiGetString (gShellLevel2HiiHandle
, STRING_TOKEN (STR_GEN_RES_OK
), NULL
);
367 DestPath
= AllocateZeroPool(PathLen
);
369 if (DestPath
== NULL
|| HiiOutput
== NULL
|| HiiResultOk
== NULL
) {
370 SHELL_FREE_NON_NULL(DestPath
);
371 SHELL_FREE_NON_NULL(HiiOutput
);
372 SHELL_FREE_NON_NULL(HiiResultOk
);
373 return (SHELL_OUT_OF_RESOURCES
);
377 // Go through the list of files to copy...
379 for (Node
= (EFI_SHELL_FILE_INFO
*)GetFirstNode(&FileList
->Link
)
380 ; !IsNull(&FileList
->Link
, &Node
->Link
)
381 ; Node
= (EFI_SHELL_FILE_INFO
*)GetNextNode(&FileList
->Link
, &Node
->Link
)
383 if (ShellGetExecutionBreakFlag()) {
386 ASSERT(Node
->FileName
!= NULL
);
387 ASSERT(Node
->FullName
!= NULL
);
390 // skip the directory traversing stuff...
392 if (StrCmp(Node
->FileName
, L
".") == 0 || StrCmp(Node
->FileName
, L
"..") == 0) {
396 if (FileList
->Link
.ForwardLink
== FileList
->Link
.BackLink
// 1 item
397 && EFI_ERROR(ShellIsDirectory(DestDir
)) // not an existing directory
399 if (StrStr(DestDir
, L
":") == NULL
) {
401 // simple copy of a single file
404 StrCpy(DestPath
, Cwd
);
406 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_DIR_NF
), gShellLevel2HiiHandle
, DestDir
);
407 return (SHELL_INVALID_PARAMETER
);
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
431 StrCpy(DestPath
, Cwd
);
433 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_DIR_NF
), gShellLevel2HiiHandle
, DestDir
);
434 return (SHELL_INVALID_PARAMETER
);
436 while (PathRemoveLastItem(DestPath
));
437 StrCat(DestPath
, DestDir
+1);
438 StrCat(DestPath
, Node
->FileName
);
439 } else if (StrStr(DestDir
, L
":") == NULL
) {
441 StrCpy(DestPath
, Cwd
);
443 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_DIR_NF
), gShellLevel2HiiHandle
, DestDir
);
444 return (SHELL_INVALID_PARAMETER
);
446 if (DestPath
[StrLen(DestPath
)-1] != L
'\\' && DestDir
[0] != L
'\\') {
447 StrCat(DestPath
, L
"\\");
448 } else if (DestPath
[StrLen(DestPath
)-1] == L
'\\' && DestDir
[0] == L
'\\') {
449 ((CHAR16
*)DestPath
)[StrLen(DestPath
)-1] = CHAR_NULL
;
451 StrCat(DestPath
, DestDir
);
452 if (DestDir
[StrLen(DestDir
)-1] != L
'\\' && Node
->FileName
[0] != L
'\\') {
453 StrCat(DestPath
, L
"\\");
454 } else if (DestDir
[StrLen(DestDir
)-1] == L
'\\' && Node
->FileName
[0] == L
'\\') {
455 ((CHAR16
*)DestPath
)[StrLen(DestPath
)-1] = CHAR_NULL
;
457 StrCat(DestPath
, Node
->FileName
);
460 StrCpy(DestPath
, DestDir
);
461 if (DestDir
[StrLen(DestDir
)-1] != L
'\\' && Node
->FileName
[0] != L
'\\') {
462 StrCat(DestPath
, L
"\\");
463 } else if (DestDir
[StrLen(DestDir
)-1] == L
'\\' && Node
->FileName
[0] == L
'\\') {
464 ((CHAR16
*)DestDir
)[StrLen(DestDir
)-1] = CHAR_NULL
;
466 StrCat(DestPath
, Node
->FileName
);
471 // Make sure the path exists
473 if (EFI_ERROR(VerifyIntermediateDirectories(DestPath
))) {
474 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_DIR_WNF
), gShellLevel2HiiHandle
);
475 ShellStatus
= SHELL_DEVICE_ERROR
;
479 if ( !EFI_ERROR(ShellIsDirectory(Node
->FullName
))
480 && !EFI_ERROR(ShellIsDirectory(DestPath
))
481 && StrniCmp(Node
->FullName
, DestPath
, StrLen(DestPath
)) == NULL
483 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_SD_PARENT
), gShellLevel2HiiHandle
);
484 ShellStatus
= SHELL_INVALID_PARAMETER
;
487 if (StringNoCaseCompare(&Node
->FullName
, &DestPath
) == 0) {
488 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_SD_SAME
), gShellLevel2HiiHandle
);
489 ShellStatus
= SHELL_INVALID_PARAMETER
;
493 if ((TempLocation
= StrniCmp(Node
->FullName
, DestPath
, StrLen(Node
->FullName
))) == 0
494 && (DestPath
[StrLen(Node
->FullName
)] == CHAR_NULL
|| DestPath
[StrLen(Node
->FullName
)] == L
'\\')
496 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_SD_SAME
), gShellLevel2HiiHandle
);
497 ShellStatus
= SHELL_INVALID_PARAMETER
;
501 PathCleanUpDirectories(DestPath
);
503 ShellPrintEx(-1, -1, HiiOutput
, Node
->FullName
, DestPath
);
506 // copy single file...
508 ShellStatus
= CopySingleFile(Node
->FullName
, DestPath
, &Response
, SilentMode
);
509 if (ShellStatus
!= SHELL_SUCCESS
) {
513 if (ShellStatus
== SHELL_SUCCESS
&& Resp
== NULL
) {
514 ShellPrintEx(-1, -1, L
"%s", HiiResultOk
);
517 SHELL_FREE_NON_NULL(DestPath
);
518 SHELL_FREE_NON_NULL(HiiOutput
);
519 SHELL_FREE_NON_NULL(HiiResultOk
);
521 SHELL_FREE_NON_NULL(Response
);
524 return (ShellStatus
);
529 Validate and if successful copy all the files from the list into
530 destination directory.
532 @param[in] FileList The list of files to copy.
533 @param[in] DestDir The directory to copy files to.
534 @param[in] SilentMode TRUE to eliminate screen output.
535 @param[in] RecursiveMode TRUE to copy directories.
537 @retval SHELL_INVALID_PARAMETER A parameter was invalid.
538 @retval SHELL_SUCCESS The operation was successful.
542 ProcessValidateAndCopyFiles(
543 IN EFI_SHELL_FILE_INFO
*FileList
,
544 IN CONST CHAR16
*DestDir
,
545 IN BOOLEAN SilentMode
,
546 IN BOOLEAN RecursiveMode
549 SHELL_STATUS ShellStatus
;
550 EFI_SHELL_FILE_INFO
*List
;
551 EFI_FILE_INFO
*FileInfo
;
555 ShellOpenFileMetaArg((CHAR16
*)DestDir
, EFI_FILE_MODE_READ
, &List
);
556 if (List
!= NULL
&& List
->Link
.ForwardLink
!= List
->Link
.BackLink
) {
557 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_MARG_ERROR
), gShellLevel2HiiHandle
, DestDir
);
558 ShellStatus
= SHELL_INVALID_PARAMETER
;
559 ShellCloseFileMetaArg(&List
);
560 } else if (List
!= NULL
) {
561 ASSERT(((EFI_SHELL_FILE_INFO
*)List
->Link
.ForwardLink
) != NULL
);
562 ASSERT(((EFI_SHELL_FILE_INFO
*)List
->Link
.ForwardLink
)->FullName
!= NULL
);
564 FileInfo
= gEfiShellProtocol
->GetFileInfo(((EFI_SHELL_FILE_INFO
*)List
->Link
.ForwardLink
)->Handle
);
565 ASSERT(FileInfo
!= NULL
);
566 if ((FileInfo
->Attribute
& EFI_FILE_READ_ONLY
) == 0) {
567 ShellStatus
= ValidateAndCopyFiles(FileList
, ((EFI_SHELL_FILE_INFO
*)List
->Link
.ForwardLink
)->FullName
, SilentMode
, RecursiveMode
, NULL
);
569 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_CP_DEST_ERROR
), gShellLevel2HiiHandle
);
570 ShellStatus
= SHELL_ACCESS_DENIED
;
572 SHELL_FREE_NON_NULL(FileInfo
);
573 ShellCloseFileMetaArg(&List
);
575 ShellStatus
= ValidateAndCopyFiles(FileList
, DestDir
, SilentMode
, RecursiveMode
, NULL
);
578 return (ShellStatus
);
581 STATIC CONST SHELL_PARAM_ITEM ParamList
[] = {
588 Function for 'cp' command.
590 @param[in] ImageHandle Handle to the Image (NULL if Internal).
591 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
596 IN EFI_HANDLE ImageHandle
,
597 IN EFI_SYSTEM_TABLE
*SystemTable
602 CHAR16
*ProblemParam
;
603 SHELL_STATUS ShellStatus
;
606 EFI_SHELL_FILE_INFO
*FileList
;
608 BOOLEAN RecursiveMode
;
612 ShellStatus
= SHELL_SUCCESS
;
617 // initialize the shell lib (we must be in non-auto-init...)
619 Status
= ShellInitialize();
620 ASSERT_EFI_ERROR(Status
);
622 Status
= CommandInit();
623 ASSERT_EFI_ERROR(Status
);
626 // parse the command line
628 Status
= ShellCommandLineParse (ParamList
, &Package
, &ProblemParam
, TRUE
);
629 if (EFI_ERROR(Status
)) {
630 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
631 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, ProblemParam
);
632 FreePool(ProblemParam
);
633 ShellStatus
= SHELL_INVALID_PARAMETER
;
641 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
646 // Initialize SilentMode and RecursiveMode
648 if (gEfiShellProtocol
->BatchIsActive()) {
651 SilentMode
= ShellCommandLineGetFlag(Package
, L
"-q");
653 RecursiveMode
= ShellCommandLineGetFlag(Package
, L
"-r");
655 switch (ParamCount
= ShellCommandLineGetCount(Package
)) {
659 // we have insufficient parameters
661 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellLevel2HiiHandle
);
662 ShellStatus
= SHELL_INVALID_PARAMETER
;
666 // must have valid CWD for single parameter...
668 Cwd
= ShellGetCurrentDir(NULL
);
670 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_CWD
), gShellLevel2HiiHandle
);
671 ShellStatus
= SHELL_INVALID_PARAMETER
;
673 Status
= ShellOpenFileMetaArg((CHAR16
*)ShellCommandLineGetRawValue(Package
, 1), EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_READ
, &FileList
);
674 if (FileList
== NULL
|| IsListEmpty(&FileList
->Link
) || EFI_ERROR(Status
)) {
675 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_FILE_NF
), gShellLevel2HiiHandle
, ShellCommandLineGetRawValue(Package
, 1));
676 ShellStatus
= SHELL_NOT_FOUND
;
678 ShellStatus
= ProcessValidateAndCopyFiles(FileList
, Cwd
, SilentMode
, RecursiveMode
);
685 // Make a big list of all the files...
687 for (ParamCount
--, LoopCounter
= 1 ; LoopCounter
< ParamCount
&& ShellStatus
== SHELL_SUCCESS
; LoopCounter
++) {
688 if (ShellGetExecutionBreakFlag()) {
691 Status
= ShellOpenFileMetaArg((CHAR16
*)ShellCommandLineGetRawValue(Package
, LoopCounter
), EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_READ
, &FileList
);
692 if (EFI_ERROR(Status
) || FileList
== NULL
|| IsListEmpty(&FileList
->Link
)) {
693 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_FILE_NF
), gShellLevel2HiiHandle
, ShellCommandLineGetRawValue(Package
, LoopCounter
));
694 ShellStatus
= SHELL_NOT_FOUND
;
697 if (ShellStatus
!= SHELL_SUCCESS
) {
698 Status
= ShellCloseFileMetaArg(&FileList
);
701 // now copy them all...
703 if (FileList
!= NULL
&& !IsListEmpty(&FileList
->Link
)) {
704 ShellStatus
= ProcessValidateAndCopyFiles(FileList
, PathCleanUpDirectories((CHAR16
*)ShellCommandLineGetRawValue(Package
, ParamCount
)), SilentMode
, RecursiveMode
);
705 Status
= ShellCloseFileMetaArg(&FileList
);
706 if (EFI_ERROR(Status
) && ShellStatus
== SHELL_SUCCESS
) {
707 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_FILE
), gShellLevel2HiiHandle
, ShellCommandLineGetRawValue(Package
, ParamCount
), ShellStatus
|MAX_BIT
);
708 ShellStatus
= SHELL_ACCESS_DENIED
;
713 } // switch on parameter count
715 if (FileList
!= NULL
) {
716 ShellCloseFileMetaArg(&FileList
);
720 // free the command line package
722 ShellCommandLineFreeVarList (Package
);
725 if (ShellGetExecutionBreakFlag()) {
726 return (SHELL_ABORTED
);
729 return (ShellStatus
);