2 Main file for mv shell level 2 function.
4 (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<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
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.
16 #include "UefiShellLevel2CommandsLib.h"
19 function to determine if a move is between file systems.
21 @param FullName [in] The name of the file to move.
22 @param Cwd [in] The current working directory
23 @param DestPath [in] The target location to move to
25 @retval TRUE The move is across file system.
26 @retval FALSE The move is within a file system.
31 IN CONST CHAR16
*FullName
,
33 IN CONST CHAR16
*DestPath
40 Test
= StrStr(FullName
, L
":");
41 if (Test
== NULL
&& Cwd
!= NULL
) {
42 Test
= StrStr(Cwd
, L
":");
44 Test1
= StrStr(DestPath
, L
":");
45 if (Test1
== NULL
&& Cwd
!= NULL
) {
46 Test1
= StrStr(Cwd
, L
":");
48 if (Test1
!= NULL
&& Test
!= NULL
) {
51 Result
= StringNoCaseCompare(&FullName
, &DestPath
);
62 Function to validate that moving a specific file (FileName) to a specific
63 location (DestPath) is valid.
65 This function will verify that the destination is not a subdirectory of
66 FullName, that the Current working Directory is not being moved, and that
67 the directory is not read only.
69 if the move is invalid this function will report the error to StdOut.
71 @param SourcePath [in] The name of the file to move.
72 @param Cwd [in] The current working directory
73 @param DestPath [in] The target location to move to
74 @param Attribute [in] The Attribute of the file
75 @param DestAttr [in] The Attribute of the destination
76 @param FileStatus [in] The Status of the file when opened
78 @retval TRUE The move is valid
79 @retval FALSE The move is not
84 IN CONST CHAR16
*SourcePath
,
86 IN CONST CHAR16
*DestPath
,
87 IN CONST UINT64 Attribute
,
88 IN CONST UINT64 DestAttr
,
89 IN CONST EFI_STATUS FileStatus
93 CHAR16
*DestPathWalker
;
95 if (Cwd
!= NULL
&& StrCmp(SourcePath
, Cwd
) == 0) {
99 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MV_INV_CWD
), gShellLevel2HiiHandle
);
104 // invalid to move read only or move to a read only destination
106 if (((Attribute
& EFI_FILE_READ_ONLY
) != 0)
107 || (FileStatus
== EFI_WRITE_PROTECTED
)
108 || ((DestAttr
& EFI_FILE_READ_ONLY
) != 0)
110 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MV_INV_RO
), gShellLevel2HiiHandle
, SourcePath
);
114 DestPathCopy
= AllocateCopyPool(StrSize(DestPath
), DestPath
);
115 if (DestPathCopy
== NULL
) {
119 for (DestPathWalker
= DestPathCopy
; *DestPathWalker
== L
'\\'; DestPathWalker
++) ;
121 while(DestPathWalker
!= NULL
&& DestPathWalker
[StrLen(DestPathWalker
)-1] == L
'\\') {
122 DestPathWalker
[StrLen(DestPathWalker
)-1] = CHAR_NULL
;
125 ASSERT(DestPathWalker
!= NULL
);
126 ASSERT(SourcePath
!= NULL
);
129 // If they're the same, or if source is "above" dest on file path tree
131 if ( StringNoCaseCompare (&DestPathWalker
, &SourcePath
) == 0
132 || StrStr(DestPathWalker
, SourcePath
) == DestPathWalker
134 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_MV_INV_SUB
), gShellLevel2HiiHandle
);
135 FreePool(DestPathCopy
);
138 FreePool(DestPathCopy
);
144 Function to take a destination path that might contain wildcards and verify
145 that there is only a single possible target (IE we cant have wildcards that
146 have 2 possible destination).
148 if the result is sucessful the caller must free *DestPathPointer.
150 @param[in] DestParameter The original path to the destination.
151 @param[in, out] DestPathPointer A pointer to the callee allocated final path.
152 @param[in] Cwd A pointer to the current working directory.
153 @param[in] SingleSource TRUE to have only one source file.
154 @param[in, out] DestAttr A pointer to the destination information attribute.
156 @retval SHELL_INVALID_PARAMETER The DestParameter could not be resolved to a location.
157 @retval SHELL_INVALID_PARAMETER The DestParameter could be resolved to more than 1 location.
158 @retval SHELL_INVALID_PARAMETER Cwd is required and is NULL.
159 @retval SHELL_SUCCESS The operation was sucessful.
163 GetDestinationLocation(
164 IN CONST CHAR16
*DestParameter
,
165 IN OUT CHAR16
**DestPathPointer
,
166 IN CONST CHAR16
*Cwd
,
167 IN CONST BOOLEAN SingleSource
,
168 IN OUT UINT64
*DestAttr
171 EFI_SHELL_FILE_INFO
*DestList
;
172 EFI_SHELL_FILE_INFO
*Node
;
180 ASSERT(DestAttr
!= NULL
);
182 if (StrStr(DestParameter
, L
"\\") == DestParameter
) {
184 return SHELL_INVALID_PARAMETER
;
186 DestPath
= AllocateZeroPool(StrSize(Cwd
));
187 if (DestPath
== NULL
) {
188 return (SHELL_OUT_OF_RESOURCES
);
190 StrCpy(DestPath
, Cwd
);
191 while (PathRemoveLastItem(DestPath
)) ;
194 // Append DestParameter beyond '\' which may be present
196 CurrentSize
= StrSize(DestPath
);
197 StrnCatGrow(&DestPath
, &CurrentSize
, &DestParameter
[1], 0);
199 *DestPathPointer
= DestPath
;
200 return (SHELL_SUCCESS
);
203 // get the destination path
205 ShellOpenFileMetaArg((CHAR16
*)DestParameter
, EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_READ
|EFI_FILE_MODE_CREATE
, &DestList
);
206 if (DestList
== NULL
|| IsListEmpty(&DestList
->Link
)) {
208 // Not existing... must be renaming
210 if (StrStr(DestParameter
, L
":") == NULL
) {
212 ShellCloseFileMetaArg(&DestList
);
213 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_CWD
), gShellLevel2HiiHandle
);
214 return (SHELL_INVALID_PARAMETER
);
216 NewSize
= StrSize(Cwd
);
217 NewSize
+= StrSize(DestParameter
);
218 DestPath
= AllocateZeroPool(NewSize
);
219 if (DestPath
== NULL
) {
220 ShellCloseFileMetaArg(&DestList
);
221 return (SHELL_OUT_OF_RESOURCES
);
223 StrCpy(DestPath
, Cwd
);
224 if (DestPath
[StrLen(DestPath
)-1] != L
'\\' && DestParameter
[0] != L
'\\') {
225 StrCat(DestPath
, L
"\\");
226 } else if (DestPath
[StrLen(DestPath
)-1] == L
'\\' && DestParameter
[0] == L
'\\') {
227 ((CHAR16
*)DestPath
)[StrLen(DestPath
)-1] = CHAR_NULL
;
229 StrCat(DestPath
, DestParameter
);
231 ASSERT(DestPath
== NULL
);
232 DestPath
= StrnCatGrow(&DestPath
, NULL
, DestParameter
, 0);
233 if (DestPath
== NULL
) {
234 ShellCloseFileMetaArg(&DestList
);
235 return (SHELL_OUT_OF_RESOURCES
);
239 Node
= (EFI_SHELL_FILE_INFO
*)GetFirstNode(&DestList
->Link
);
240 *DestAttr
= Node
->Info
->Attribute
;
242 // Make sure there is only 1 node in the list.
244 if (!IsNodeAtEnd(&DestList
->Link
, &Node
->Link
)) {
245 ShellCloseFileMetaArg(&DestList
);
246 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_MARG_ERROR
), gShellLevel2HiiHandle
, L
"mv", DestParameter
);
247 return (SHELL_INVALID_PARAMETER
);
251 // If we are a directory or a single file, then one node is fine.
253 if (ShellIsDirectory(Node
->FullName
)==EFI_SUCCESS
|| SingleSource
) {
254 DestPath
= AllocateZeroPool(StrSize(Node
->FullName
)+sizeof(CHAR16
));
255 if (DestPath
== NULL
) {
256 ShellCloseFileMetaArg(&DestList
);
257 return (SHELL_OUT_OF_RESOURCES
);
259 StrCpy(DestPath
, Node
->FullName
);
260 StrCat(DestPath
, L
"\\");
263 // cant move multiple files onto a single file.
265 ShellCloseFileMetaArg(&DestList
);
266 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_FILE_ERROR
), gShellLevel2HiiHandle
, L
"mv", DestParameter
);
267 return (SHELL_INVALID_PARAMETER
);
271 *DestPathPointer
= DestPath
;
272 ShellCloseFileMetaArg(&DestList
);
274 return (SHELL_SUCCESS
);
278 Function to do a move across file systems.
280 @param[in] Node A pointer to the file to be removed.
281 @param[in] DestPath A pointer to the destination file path.
282 @param[out] Resp A pointer to response from question. Pass back on looped calling
284 @retval SHELL_SUCCESS The source file was moved to the destination.
288 MoveBetweenFileSystems(
289 IN EFI_SHELL_FILE_INFO
*Node
,
290 IN CONST CHAR16
*DestPath
,
294 SHELL_STATUS ShellStatus
;
297 // First we copy the file
299 ShellStatus
= CopySingleFile (Node
->FullName
, DestPath
, Resp
, TRUE
, L
"mv");
304 if (ShellStatus
== SHELL_SUCCESS
) {
306 // The copy was successful. delete the source file.
308 CascadeDelete(Node
, TRUE
);
310 } else if (ShellStatus
== SHELL_ABORTED
) {
312 } else if (ShellStatus
== SHELL_ACCESS_DENIED
) {
313 return EFI_ACCESS_DENIED
;
314 } else if (ShellStatus
== SHELL_VOLUME_FULL
) {
315 return EFI_VOLUME_FULL
;
317 return EFI_UNSUPPORTED
;
320 return (EFI_SUCCESS
);
324 Function to take the destination path and target file name to generate the full destination path.
326 @param[in] DestPath A pointer to the destination file path string.
327 @param[out] FullDestPath A pointer to the full destination path string.
328 @param[in] FileName Name string of the targe file.
330 @retval SHELL_SUCCESS the files were all moved.
331 @retval SHELL_INVALID_PARAMETER a parameter was invalid
332 @retval SHELL_OUT_OF_RESOURCES a memory allocation failed
337 IN CONST CHAR16
**DestPath
,
338 OUT CHAR16
**FullDestPath
,
339 IN CONST CHAR16
*FileName
343 if (FullDestPath
== NULL
|| FileName
== NULL
|| DestPath
== NULL
|| *DestPath
== NULL
){
344 return (EFI_INVALID_PARAMETER
);
347 Size
= StrSize(*DestPath
) + StrSize(FileName
);
349 *FullDestPath
= AllocateZeroPool(Size
);
350 if (*FullDestPath
== NULL
){
351 return (EFI_OUT_OF_RESOURCES
);
354 StrnCpy(*FullDestPath
, *DestPath
, Size
/ sizeof(CHAR16
) - 1);
355 if ((*FullDestPath
)[StrLen(*FullDestPath
)-1] != L
'\\' && FileName
[0] != L
'\\') {
356 StrnCat(*FullDestPath
, L
"\\",Size
/ sizeof(CHAR16
) - 1 - StrLen(*FullDestPath
));
358 StrnCat(*FullDestPath
, FileName
, Size
/ sizeof(CHAR16
) - 1 - StrLen(*FullDestPath
));
360 return (EFI_SUCCESS
);
364 Function to do a move within a file system.
366 @param[in] Node A pointer to the file to be removed.
367 @param[in] DestPath A pointer to the destination file path.
368 @param[out] Resp A pointer to response from question. Pass back on looped calling.
370 @retval SHELL_SUCCESS The source file was moved to the destination.
371 @retval SHELL_OUT_OF_RESOURCES A memory allocation failed.
375 MoveWithinFileSystems(
376 IN EFI_SHELL_FILE_INFO
*Node
,
381 EFI_FILE_INFO
*NewFileInfo
;
382 CHAR16
*TempLocation
;
388 // Chop off map info from DestPath
390 if ((TempLocation
= StrStr(DestPath
, L
":")) != NULL
) {
391 CopyMem(DestPath
, TempLocation
+1, StrSize(TempLocation
+1));
395 // construct the new file info block
397 NewSize
= StrSize(DestPath
);
398 NewSize
+= StrSize(Node
->FileName
) + SIZE_OF_EFI_FILE_INFO
+ sizeof(CHAR16
);
399 NewFileInfo
= AllocateZeroPool(NewSize
);
400 if (NewFileInfo
== NULL
) {
401 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_MEM
), gShellLevel2HiiHandle
);
402 Status
= EFI_OUT_OF_RESOURCES
;
404 CopyMem(NewFileInfo
, Node
->Info
, SIZE_OF_EFI_FILE_INFO
);
405 if (DestPath
[0] != L
'\\') {
406 StrCpy(NewFileInfo
->FileName
, L
"\\");
407 StrCat(NewFileInfo
->FileName
, DestPath
);
409 StrCpy(NewFileInfo
->FileName
, DestPath
);
411 Length
= StrLen(NewFileInfo
->FileName
);
415 if (NewFileInfo
->FileName
[Length
] == L
'\\') {
416 if (Node
->FileName
[0] == L
'\\') {
418 // Don't allow for double slashes. Eliminate one of them.
420 NewFileInfo
->FileName
[Length
] = CHAR_NULL
;
422 StrCat(NewFileInfo
->FileName
, Node
->FileName
);
424 NewFileInfo
->Size
= SIZE_OF_EFI_FILE_INFO
+ StrSize(NewFileInfo
->FileName
);
427 // Perform the move operation
429 Status
= ShellSetFileInfo(Node
->Handle
, NewFileInfo
);
432 // Free the info object we used...
434 FreePool(NewFileInfo
);
440 function to take a list of files to move and a destination location and do
441 the verification and moving of those files to that location. This function
442 will report any errors to the user and continue to move the rest of the files.
444 @param[in] FileList A LIST_ENTRY* based list of files to move
445 @param[out] Resp pointer to response from question. Pass back on looped calling
446 @param[in] DestParameter the originally specified destination location
448 @retval SHELL_SUCCESS the files were all moved.
449 @retval SHELL_INVALID_PARAMETER a parameter was invalid
450 @retval SHELL_SECURITY_VIOLATION a security violation ocurred
451 @retval SHELL_WRITE_PROTECTED the destination was write protected
452 @retval SHELL_OUT_OF_RESOURCES a memory allocation failed
456 ValidateAndMoveFiles(
457 IN EFI_SHELL_FILE_INFO
*FileList
,
459 IN CONST CHAR16
*DestParameter
466 CHAR16
*FullDestPath
;
468 SHELL_STATUS ShellStatus
;
469 EFI_SHELL_FILE_INFO
*Node
;
472 CHAR16
*CleanFilePathStr
;
474 ASSERT(FileList
!= NULL
);
475 ASSERT(DestParameter
!= NULL
);
479 Cwd
= ShellGetCurrentDir(NULL
);
482 CleanFilePathStr
= NULL
;
484 Status
= ShellLevel2StripQuotes (DestParameter
, &CleanFilePathStr
);
485 if (EFI_ERROR (Status
)) {
486 if (Status
== EFI_OUT_OF_RESOURCES
) {
487 return SHELL_OUT_OF_RESOURCES
;
489 return SHELL_INVALID_PARAMETER
;
493 ASSERT (CleanFilePathStr
!= NULL
);
496 // Get and validate the destination location
498 ShellStatus
= GetDestinationLocation(CleanFilePathStr
, &DestPath
, Cwd
, (BOOLEAN
)(FileList
->Link
.ForwardLink
== FileList
->Link
.BackLink
), &Attr
);
499 FreePool (CleanFilePathStr
);
501 if (ShellStatus
!= SHELL_SUCCESS
) {
502 return (ShellStatus
);
504 DestPath
= PathCleanUpDirectories(DestPath
);
505 if (DestPath
== NULL
) {
506 return (SHELL_OUT_OF_RESOURCES
);
509 HiiOutput
= HiiGetString (gShellLevel2HiiHandle
, STRING_TOKEN (STR_MV_OUTPUT
), NULL
);
510 HiiResultOk
= HiiGetString (gShellLevel2HiiHandle
, STRING_TOKEN (STR_GEN_RES_OK
), NULL
);
511 if (HiiOutput
== NULL
|| HiiResultOk
== NULL
) {
512 SHELL_FREE_NON_NULL(DestPath
);
513 SHELL_FREE_NON_NULL(HiiOutput
);
514 SHELL_FREE_NON_NULL(HiiResultOk
);
515 return (SHELL_OUT_OF_RESOURCES
);
519 // Go through the list of files and directories to move...
521 for (Node
= (EFI_SHELL_FILE_INFO
*)GetFirstNode(&FileList
->Link
)
522 ; !IsNull(&FileList
->Link
, &Node
->Link
)
523 ; Node
= (EFI_SHELL_FILE_INFO
*)GetNextNode(&FileList
->Link
, &Node
->Link
)
525 if (ShellGetExecutionBreakFlag()) {
530 // These should never be NULL
532 ASSERT(Node
->FileName
!= NULL
);
533 ASSERT(Node
->FullName
!= NULL
);
534 ASSERT(Node
->Info
!= NULL
);
537 // skip the directory traversing stuff...
539 if (StrCmp(Node
->FileName
, L
".") == 0 || StrCmp(Node
->FileName
, L
"..") == 0) {
543 SHELL_FREE_NON_NULL(FullDestPath
);
545 if (ShellIsDirectory(DestPath
)==EFI_SUCCESS
) {
546 CreateFullDestPath((CONST CHAR16
**)&DestPath
, &FullDestPath
, Node
->FileName
);
550 // Validate that the move is valid
552 if (!IsValidMove(Node
->FullName
, Cwd
, FullDestPath
!=NULL
? FullDestPath
:DestPath
, Node
->Info
->Attribute
, Attr
, Node
->Status
)) {
553 ShellStatus
= SHELL_INVALID_PARAMETER
;
557 ShellPrintEx(-1, -1, HiiOutput
, Node
->FullName
, FullDestPath
!=NULL
? FullDestPath
:DestPath
);
560 // See if destination exists
562 if (!EFI_ERROR(ShellFileExists(FullDestPath
!=NULL
? FullDestPath
:DestPath
))) {
563 if (Response
== NULL
) {
564 ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel
, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR
), gShellLevel2HiiHandle
, &Response
);
566 switch (*(SHELL_PROMPT_RESPONSE
*)Response
) {
567 case ShellPromptResponseNo
:
571 case ShellPromptResponseCancel
:
574 // indicate to stop everything
576 return (SHELL_ABORTED
);
577 case ShellPromptResponseAll
:
580 case ShellPromptResponseYes
:
586 return SHELL_ABORTED
;
588 Status
= ShellDeleteFileByName(FullDestPath
!=NULL
? FullDestPath
:DestPath
);
591 if (IsBetweenFileSystem(Node
->FullName
, Cwd
, DestPath
)) {
592 while (FullDestPath
== NULL
&& DestPath
!= NULL
&& DestPath
[0] != CHAR_NULL
&& DestPath
[StrLen(DestPath
) - 1] == L
'\\') {
593 DestPath
[StrLen(DestPath
) - 1] = CHAR_NULL
;
595 Status
= MoveBetweenFileSystems(Node
, FullDestPath
!=NULL
? FullDestPath
:DestPath
, &Response
);
597 Status
= MoveWithinFileSystems(Node
, DestPath
, &Response
);
599 // Display error status
601 if (EFI_ERROR(Status
)) {
602 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_UK
), gShellLevel2HiiHandle
, L
"mv", Status
);
609 if (EFI_ERROR(Status
)) {
610 ShellStatus
= SHELL_INVALID_PARAMETER
;
611 if (Status
== EFI_SECURITY_VIOLATION
) {
612 ShellStatus
= SHELL_SECURITY_VIOLATION
;
613 } else if (Status
== EFI_WRITE_PROTECTED
) {
614 ShellStatus
= SHELL_WRITE_PROTECTED
;
615 } else if (Status
== EFI_OUT_OF_RESOURCES
) {
616 ShellStatus
= SHELL_OUT_OF_RESOURCES
;
617 } else if (Status
== EFI_DEVICE_ERROR
) {
618 ShellStatus
= SHELL_DEVICE_ERROR
;
619 } else if (Status
== EFI_ACCESS_DENIED
) {
620 ShellStatus
= SHELL_ACCESS_DENIED
;
623 ShellPrintEx(-1, -1, L
"%s", HiiResultOk
);
628 SHELL_FREE_NON_NULL(FullDestPath
);
629 SHELL_FREE_NON_NULL(DestPath
);
630 SHELL_FREE_NON_NULL(HiiOutput
);
631 SHELL_FREE_NON_NULL(HiiResultOk
);
632 return (ShellStatus
);
636 Function for 'mv' command.
638 @param[in] ImageHandle Handle to the Image (NULL if Internal).
639 @param[in] SystemTable Pointer to the System Table (NULL if Internal).
644 IN EFI_HANDLE ImageHandle
,
645 IN EFI_SYSTEM_TABLE
*SystemTable
650 CHAR16
*ProblemParam
;
651 SHELL_STATUS ShellStatus
;
654 EFI_SHELL_FILE_INFO
*FileList
;
658 ShellStatus
= SHELL_SUCCESS
;
664 // initialize the shell lib (we must be in non-auto-init...)
666 Status
= ShellInitialize();
667 ASSERT_EFI_ERROR(Status
);
670 // parse the command line
672 Status
= ShellCommandLineParse (EmptyParamList
, &Package
, &ProblemParam
, TRUE
);
673 if (EFI_ERROR(Status
)) {
674 if (Status
== EFI_VOLUME_CORRUPTED
&& ProblemParam
!= NULL
) {
675 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_PROBLEM
), gShellLevel2HiiHandle
, L
"mv", ProblemParam
);
676 FreePool(ProblemParam
);
677 ShellStatus
= SHELL_INVALID_PARAMETER
;
685 if (ShellCommandLineGetFlag(Package
, L
"-?")) {
689 switch (ParamCount
= ShellCommandLineGetCount(Package
)) {
693 // we have insufficient parameters
695 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_TOO_FEW
), gShellLevel2HiiHandle
, L
"mv");
696 ShellStatus
= SHELL_INVALID_PARAMETER
;
700 // must have valid CWD for single parameter...
702 if (ShellGetCurrentDir(NULL
) == NULL
){
703 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_NO_CWD
), gShellLevel2HiiHandle
, L
"mv");
704 ShellStatus
= SHELL_INVALID_PARAMETER
;
706 Status
= ShellOpenFileMetaArg((CHAR16
*)ShellCommandLineGetRawValue(Package
, 1), EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_READ
, &FileList
);
707 if (FileList
== NULL
|| IsListEmpty(&FileList
->Link
) || EFI_ERROR(Status
)) {
708 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_FILE_NF
), gShellLevel2HiiHandle
, L
"mv", ShellCommandLineGetRawValue(Package
, 1));
709 ShellStatus
= SHELL_NOT_FOUND
;
712 // ValidateAndMoveFiles will report errors to the screen itself
714 ShellStatus
= ValidateAndMoveFiles(FileList
, &Response
, ShellGetCurrentDir(NULL
));
720 ///@todo make sure this works with error half way through and continues...
721 for (ParamCount
--, LoopCounter
= 1 ; LoopCounter
< ParamCount
; LoopCounter
++) {
722 if (ShellGetExecutionBreakFlag()) {
725 Status
= ShellOpenFileMetaArg((CHAR16
*)ShellCommandLineGetRawValue(Package
, LoopCounter
), EFI_FILE_MODE_WRITE
|EFI_FILE_MODE_READ
, &FileList
);
726 if (FileList
== NULL
|| IsListEmpty(&FileList
->Link
) || EFI_ERROR(Status
)) {
727 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_FILE_NF
), gShellLevel2HiiHandle
, L
"mv", ShellCommandLineGetRawValue(Package
, LoopCounter
));
728 ShellStatus
= SHELL_NOT_FOUND
;
731 // ValidateAndMoveFiles will report errors to the screen itself
732 // Only change ShellStatus if it's sucessful
734 if (ShellStatus
== SHELL_SUCCESS
) {
735 ShellStatus
= ValidateAndMoveFiles(FileList
, &Response
, ShellCommandLineGetRawValue(Package
, ParamCount
));
737 ValidateAndMoveFiles(FileList
, &Response
, ShellCommandLineGetRawValue(Package
, ParamCount
));
740 if (FileList
!= NULL
&& !IsListEmpty(&FileList
->Link
)) {
741 Status
= ShellCloseFileMetaArg(&FileList
);
742 if (EFI_ERROR(Status
) && ShellStatus
== SHELL_SUCCESS
) {
743 ShellStatus
= SHELL_ACCESS_DENIED
;
744 ShellPrintHiiEx(-1, -1, NULL
, STRING_TOKEN (STR_GEN_ERR_FILE
), gShellLevel2HiiHandle
, L
"mv", ShellCommandLineGetRawValue(Package
, 1), ShellStatus
|MAX_BIT
);
749 } // switch on parameter count
751 if (FileList
!= NULL
) {
752 ShellCloseFileMetaArg(&FileList
);
756 // free the command line package
758 ShellCommandLineFreeVarList (Package
);
761 SHELL_FREE_NON_NULL(Response
);
763 if (ShellGetExecutionBreakFlag()) {
764 return (SHELL_ABORTED
);
767 return (ShellStatus
);