/** @file\r
Main file for mv shell level 2 function.\r
\r
- (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.\r
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
/**\r
function to determine if a move is between file systems.\r
- \r
+\r
@param FullName [in] The name of the file to move.\r
@param Cwd [in] The current working directory\r
@param DestPath [in] The target location to move to\r
@retval TRUE The move is across file system.\r
@retval FALSE The move is within a file system.\r
**/\r
-STATIC\r
BOOLEAN\r
-EFIAPI\r
IsBetweenFileSystem(\r
IN CONST CHAR16 *FullName,\r
IN CONST CHAR16 *Cwd,\r
return (FALSE);\r
}\r
\r
+/**\r
+ function to determine if SrcPath is valid to mv.\r
+\r
+ if SrcPath equal CWD then it's invalid.\r
+ if SrcPath is the parent path of CWD then it's invalid.\r
+ is SrcPath is NULL return FALSE.\r
+\r
+ if CwdPath is NULL then ASSERT()\r
+\r
+ @param SrcPath [in] The source path.\r
+ @param CwdPath [in] The current working directory.\r
+\r
+ @retval TRUE The source path is valid.\r
+ @retval FALSE The source path is invalid.\r
+**/\r
+BOOLEAN\r
+IsSoucePathValid(\r
+ IN CONST CHAR16* SrcPath,\r
+ IN CONST CHAR16* CwdPath\r
+ )\r
+{\r
+ CHAR16* SrcPathBuffer;\r
+ CHAR16* CwdPathBuffer;\r
+ BOOLEAN Ret;\r
+\r
+ ASSERT (CwdPath != NULL);\r
+ if (SrcPath == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
+ Ret = TRUE;\r
+\r
+ SrcPathBuffer = AllocateCopyPool (StrSize (SrcPath), SrcPath);\r
+ if (SrcPathBuffer == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
+ CwdPathBuffer = AllocateCopyPool (StrSize (CwdPath), CwdPath);\r
+ if (CwdPathBuffer == NULL) {\r
+ FreePool(SrcPathBuffer);\r
+ return FALSE;\r
+ }\r
+\r
+ gUnicodeCollation->StrUpr (gUnicodeCollation, SrcPathBuffer);\r
+ gUnicodeCollation->StrUpr (gUnicodeCollation, CwdPathBuffer);\r
+\r
+ if (SrcPathBuffer[StrLen (SrcPathBuffer) -1 ] == L'\\') {\r
+ SrcPathBuffer[StrLen (SrcPathBuffer) - 1] = CHAR_NULL;\r
+ }\r
+\r
+ if (CwdPathBuffer[StrLen (CwdPathBuffer) - 1] == L'\\') {\r
+ CwdPathBuffer[StrLen (CwdPathBuffer) - 1] = CHAR_NULL;\r
+ }\r
+\r
+ if (StrCmp (CwdPathBuffer, SrcPathBuffer) == 0 ||\r
+ ((StrStr (CwdPathBuffer, SrcPathBuffer) == CwdPathBuffer) &&\r
+ (CwdPathBuffer[StrLen (SrcPathBuffer)] == L'\\'))\r
+ ) {\r
+ Ret = FALSE;\r
+ }\r
+\r
+ FreePool (SrcPathBuffer);\r
+ FreePool (CwdPathBuffer);\r
+\r
+ return Ret;\r
+}\r
+\r
/**\r
Function to validate that moving a specific file (FileName) to a specific\r
location (DestPath) is valid.\r
\r
if the move is invalid this function will report the error to StdOut.\r
\r
- @param FullName [in] The name of the file to move.\r
- @param Cwd [in] The current working directory\r
- @param DestPath [in] The target location to move to\r
- @param Attribute[in] The Attribute of the file\r
- @param DestAttr [in] The Attribute of the destination\r
- @param FileStatus[in] The Status of the file when opened\r
+ @param SourcePath [in] The name of the file to move.\r
+ @param Cwd [in] The current working directory\r
+ @param DestPath [in] The target location to move to\r
+ @param Attribute [in] The Attribute of the file\r
+ @param DestAttr [in] The Attribute of the destination\r
+ @param FileStatus [in] The Status of the file when opened\r
\r
@retval TRUE The move is valid\r
@retval FALSE The move is not\r
**/\r
-STATIC\r
BOOLEAN\r
-EFIAPI\r
IsValidMove(\r
IN CONST CHAR16 *SourcePath,\r
IN CONST CHAR16 *Cwd,\r
CHAR16 *DestPathCopy;\r
CHAR16 *DestPathWalker;\r
\r
- if (Cwd != NULL && StrCmp(SourcePath, Cwd) == 0) {\r
- //\r
- // Invalid move\r
- //\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_CWD), gShellLevel2HiiHandle);\r
- return (FALSE);\r
+ if ((Cwd != NULL) && ((Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY)) {\r
+ if (!IsSoucePathValid (SourcePath, Cwd)) {\r
+ //\r
+ // Invalid move\r
+ //\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_MV_INV_CWD), gShellLevel2HiiHandle);\r
+ return FALSE;\r
+ }\r
}\r
\r
//\r
// invalid to move read only or move to a read only destination\r
//\r
- if (((Attribute & EFI_FILE_READ_ONLY) != 0) \r
+ if (((Attribute & EFI_FILE_READ_ONLY) != 0)\r
|| (FileStatus == EFI_WRITE_PROTECTED)\r
|| ((DestAttr & EFI_FILE_READ_ONLY) != 0)\r
) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_RO), gShellLevel2HiiHandle, SourcePath);\r
return (FALSE);\r
- } \r
- \r
+ }\r
+\r
DestPathCopy = AllocateCopyPool(StrSize(DestPath), DestPath);\r
if (DestPathCopy == NULL) {\r
return (FALSE);\r
//\r
// If they're the same, or if source is "above" dest on file path tree\r
//\r
- if ( StrCmp(DestPathWalker, SourcePath) == 0 \r
- || StrStr(DestPathWalker, SourcePath) == DestPathWalker \r
- ) {\r
+ if ( StringNoCaseCompare (&DestPathWalker, &SourcePath) == 0 ||\r
+ ((StrStr(DestPathWalker, SourcePath) == DestPathWalker) &&\r
+ (DestPathWalker[StrLen(SourcePath)] == '\\')\r
+ )\r
+ ) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_SUB), gShellLevel2HiiHandle);\r
FreePool(DestPathCopy);\r
return (FALSE);\r
@param[in] DestParameter The original path to the destination.\r
@param[in, out] DestPathPointer A pointer to the callee allocated final path.\r
@param[in] Cwd A pointer to the current working directory.\r
+ @param[in] SingleSource TRUE to have only one source file.\r
+ @param[in, out] DestAttr A pointer to the destination information attribute.\r
\r
@retval SHELL_INVALID_PARAMETER The DestParameter could not be resolved to a location.\r
@retval SHELL_INVALID_PARAMETER The DestParameter could be resolved to more than 1 location.\r
@retval SHELL_INVALID_PARAMETER Cwd is required and is NULL.\r
@retval SHELL_SUCCESS The operation was sucessful.\r
**/\r
-STATIC\r
SHELL_STATUS\r
-EFIAPI\r
GetDestinationLocation(\r
IN CONST CHAR16 *DestParameter,\r
IN OUT CHAR16 **DestPathPointer,\r
if (DestPath == NULL) {\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
- StrCpy(DestPath, Cwd);\r
+ StrCpyS(DestPath, StrSize(Cwd) / sizeof(CHAR16), Cwd);\r
while (PathRemoveLastItem(DestPath)) ;\r
\r
//\r
ShellCloseFileMetaArg(&DestList);\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
- StrCpy(DestPath, Cwd);\r
+ StrCpyS(DestPath, NewSize / sizeof(CHAR16), Cwd);\r
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestParameter[0] != L'\\') {\r
- StrCat(DestPath, L"\\");\r
+ StrCatS(DestPath, NewSize / sizeof(CHAR16), L"\\");\r
} else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestParameter[0] == L'\\') {\r
((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL;\r
}\r
- StrCat(DestPath, DestParameter);\r
+ StrCatS(DestPath, NewSize / sizeof(CHAR16), DestParameter);\r
} else {\r
ASSERT(DestPath == NULL);\r
DestPath = StrnCatGrow(&DestPath, NULL, DestParameter, 0);\r
//\r
if (!IsNodeAtEnd(&DestList->Link, &Node->Link)) {\r
ShellCloseFileMetaArg(&DestList);\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, DestParameter);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
\r
ShellCloseFileMetaArg(&DestList);\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
- StrCpy(DestPath, Node->FullName);\r
- StrCat(DestPath, L"\\");\r
+ StrCpyS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), Node->FullName);\r
+ StrCatS(DestPath, (StrSize(Node->FullName)+sizeof(CHAR16)) / sizeof(CHAR16), L"\\");\r
} else {\r
//\r
// cant move multiple files onto a single file.\r
//\r
ShellCloseFileMetaArg(&DestList);\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_ERROR), gShellLevel2HiiHandle, DestParameter);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_ERROR), gShellLevel2HiiHandle, L"mv", DestParameter);\r
return (SHELL_INVALID_PARAMETER);\r
}\r
}\r
return (SHELL_SUCCESS);\r
}\r
\r
+/**\r
+ Function to do a move across file systems.\r
+\r
+ @param[in] Node A pointer to the file to be removed.\r
+ @param[in] DestPath A pointer to the destination file path.\r
+ @param[out] Resp A pointer to response from question. Pass back on looped calling\r
+\r
+ @retval SHELL_SUCCESS The source file was moved to the destination.\r
+**/\r
EFI_STATUS\r
-EFIAPI\r
MoveBetweenFileSystems(\r
IN EFI_SHELL_FILE_INFO *Node,\r
IN CONST CHAR16 *DestPath,\r
OUT VOID **Resp\r
)\r
{\r
- EFI_STATUS Status;\r
+ SHELL_STATUS ShellStatus;\r
\r
//\r
// First we copy the file\r
//\r
- Status = CopySingleFile(Node->FullName, DestPath, Resp, TRUE);\r
+ ShellStatus = CopySingleFile (Node->FullName, DestPath, Resp, TRUE, L"mv");\r
\r
//\r
// Check our result\r
//\r
- if (!EFI_ERROR(Status)) {\r
+ if (ShellStatus == SHELL_SUCCESS) {\r
//\r
// The copy was successful. delete the source file.\r
//\r
CascadeDelete(Node, TRUE);\r
Node->Handle = NULL;\r
+ } else if (ShellStatus == SHELL_ABORTED) {\r
+ return EFI_ABORTED;\r
+ } else if (ShellStatus == SHELL_ACCESS_DENIED) {\r
+ return EFI_ACCESS_DENIED;\r
+ } else if (ShellStatus == SHELL_VOLUME_FULL) {\r
+ return EFI_VOLUME_FULL;\r
+ } else {\r
+ return EFI_UNSUPPORTED;\r
}\r
\r
- return (Status);\r
+ return (EFI_SUCCESS);\r
}\r
\r
+/**\r
+ Function to take the destination path and target file name to generate the full destination path.\r
+\r
+ @param[in] DestPath A pointer to the destination file path string.\r
+ @param[out] FullDestPath A pointer to the full destination path string.\r
+ @param[in] FileName Name string of the targe file.\r
+\r
+ @retval SHELL_SUCCESS the files were all moved.\r
+ @retval SHELL_INVALID_PARAMETER a parameter was invalid\r
+ @retval SHELL_OUT_OF_RESOURCES a memory allocation failed\r
+**/\r
EFI_STATUS\r
-EFIAPI\r
CreateFullDestPath(\r
IN CONST CHAR16 **DestPath,\r
- OUT CHAR16 **FullDestPath, \r
+ OUT CHAR16 **FullDestPath,\r
IN CONST CHAR16 *FileName\r
)\r
{\r
return (EFI_OUT_OF_RESOURCES);\r
}\r
\r
- StrnCpy(*FullDestPath, *DestPath, Size / sizeof(CHAR16) - 1);\r
+ StrCpyS(*FullDestPath, Size / sizeof(CHAR16), *DestPath);\r
if ((*FullDestPath)[StrLen(*FullDestPath)-1] != L'\\' && FileName[0] != L'\\') {\r
- StrnCat(*FullDestPath, L"\\",Size / sizeof(CHAR16) - 1 - StrLen(*FullDestPath));\r
+ StrCatS(*FullDestPath, Size / sizeof(CHAR16), L"\\");\r
}\r
- StrnCat(*FullDestPath, FileName, Size / sizeof(CHAR16) - 1 - StrLen(*FullDestPath));\r
+ StrCatS(*FullDestPath, Size / sizeof(CHAR16), FileName);\r
\r
return (EFI_SUCCESS);\r
}\r
\r
+/**\r
+ Function to do a move within a file system.\r
+\r
+ @param[in] Node A pointer to the file to be removed.\r
+ @param[in] DestPath A pointer to the destination file path.\r
+ @param[out] Resp A pointer to response from question. Pass back on looped calling.\r
+\r
+ @retval SHELL_SUCCESS The source file was moved to the destination.\r
+ @retval SHELL_OUT_OF_RESOURCES A memory allocation failed.\r
+**/\r
EFI_STATUS\r
-EFIAPI\r
MoveWithinFileSystems(\r
IN EFI_SHELL_FILE_INFO *Node,\r
IN CHAR16 *DestPath,\r
} else {\r
CopyMem(NewFileInfo, Node->Info, SIZE_OF_EFI_FILE_INFO);\r
if (DestPath[0] != L'\\') {\r
- StrCpy(NewFileInfo->FileName, L"\\");\r
- StrCat(NewFileInfo->FileName, DestPath);\r
+ StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), L"\\");\r
+ StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);\r
} else {\r
- StrCpy(NewFileInfo->FileName, DestPath);\r
+ StrCpyS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), DestPath);\r
}\r
Length = StrLen(NewFileInfo->FileName);\r
if (Length > 0) {\r
//\r
NewFileInfo->FileName[Length] = CHAR_NULL;\r
}\r
- StrCat(NewFileInfo->FileName, Node->FileName);\r
+ StrCatS(NewFileInfo->FileName, (NewSize - SIZE_OF_EFI_FILE_INFO) / sizeof(CHAR16), Node->FileName);\r
}\r
NewFileInfo->Size = SIZE_OF_EFI_FILE_INFO + StrSize(NewFileInfo->FileName);\r
\r
@retval SHELL_WRITE_PROTECTED the destination was write protected\r
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed\r
**/\r
-STATIC\r
SHELL_STATUS\r
-EFIAPI\r
ValidateAndMoveFiles(\r
IN EFI_SHELL_FILE_INFO *FileList,\r
OUT VOID **Resp,\r
CHAR16 *DestPath;\r
CHAR16 *FullDestPath;\r
CONST CHAR16 *Cwd;\r
+ CHAR16 *FullCwd;\r
SHELL_STATUS ShellStatus;\r
EFI_SHELL_FILE_INFO *Node;\r
VOID *Response;\r
Response = *Resp;\r
Attr = 0;\r
CleanFilePathStr = NULL;\r
+ FullCwd = NULL;\r
+\r
+ if (Cwd != NULL) {\r
+ FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));\r
+ if (FullCwd == NULL) {\r
+ return SHELL_OUT_OF_RESOURCES;\r
+ } else {\r
+ StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);\r
+ StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\");\r
+ }\r
+ }\r
\r
Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);\r
if (EFI_ERROR (Status)) {\r
+ SHELL_FREE_NON_NULL(FullCwd);\r
if (Status == EFI_OUT_OF_RESOURCES) {\r
return SHELL_OUT_OF_RESOURCES;\r
} else {\r
//\r
// Get and validate the destination location\r
//\r
- ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);\r
+ ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, FullCwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);\r
FreePool (CleanFilePathStr);\r
\r
if (ShellStatus != SHELL_SUCCESS) {\r
+ SHELL_FREE_NON_NULL (FullCwd);\r
return (ShellStatus);\r
}\r
DestPath = PathCleanUpDirectories(DestPath);\r
if (DestPath == NULL) {\r
+ FreePool (FullCwd);\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
\r
SHELL_FREE_NON_NULL(DestPath);\r
SHELL_FREE_NON_NULL(HiiOutput);\r
SHELL_FREE_NON_NULL(HiiResultOk);\r
+ SHELL_FREE_NON_NULL(FullCwd);\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
\r
//\r
// Validate that the move is valid\r
//\r
- if (!IsValidMove(Node->FullName, Cwd, FullDestPath?FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {\r
+ if (!IsValidMove(Node->FullName, FullCwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
continue;\r
}\r
\r
- ShellPrintEx(-1, -1, HiiOutput, Node->FullName, FullDestPath?FullDestPath:DestPath);\r
+ ShellPrintEx(-1, -1, HiiOutput, Node->FullName, FullDestPath!=NULL? FullDestPath:DestPath);\r
\r
//\r
// See if destination exists\r
//\r
- if (!EFI_ERROR(ShellFileExists(FullDestPath?FullDestPath:DestPath))) {\r
+ if (!EFI_ERROR(ShellFileExists(FullDestPath!=NULL? FullDestPath:DestPath))) {\r
if (Response == NULL) {\r
ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);\r
}\r
//\r
// indicate to stop everything\r
//\r
+ SHELL_FREE_NON_NULL(FullCwd);\r
return (SHELL_ABORTED);\r
case ShellPromptResponseAll:\r
*Resp = Response;\r
break;\r
default:\r
FreePool(Response);\r
+ SHELL_FREE_NON_NULL(FullCwd);\r
return SHELL_ABORTED;\r
}\r
- Status = ShellDeleteFileByName(FullDestPath?FullDestPath:DestPath);\r
+ Status = ShellDeleteFileByName(FullDestPath!=NULL? FullDestPath:DestPath);\r
}\r
\r
- if (IsBetweenFileSystem(Node->FullName, Cwd, DestPath)) {\r
+ if (IsBetweenFileSystem(Node->FullName, FullCwd, DestPath)) {\r
while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {\r
DestPath[StrLen(DestPath) - 1] = CHAR_NULL;\r
}\r
- Status = MoveBetweenFileSystems(Node, FullDestPath?FullDestPath:DestPath, &Response);\r
+ Status = MoveBetweenFileSystems(Node, FullDestPath!=NULL? FullDestPath:DestPath, &Response);\r
} else {\r
Status = MoveWithinFileSystems(Node, DestPath, &Response);\r
+ //\r
+ // Display error status\r
+ //\r
+ if (EFI_ERROR(Status)) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, L"mv", Status);\r
+ }\r
}\r
\r
//\r
// Check our result\r
//\r
if (EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, Status);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
if (Status == EFI_SECURITY_VIOLATION) {\r
ShellStatus = SHELL_SECURITY_VIOLATION;\r
SHELL_FREE_NON_NULL(DestPath);\r
SHELL_FREE_NON_NULL(HiiOutput);\r
SHELL_FREE_NON_NULL(HiiResultOk);\r
+ SHELL_FREE_NON_NULL(FullCwd);\r
return (ShellStatus);\r
}\r
\r
EFI_STATUS Status;\r
LIST_ENTRY *Package;\r
CHAR16 *ProblemParam;\r
+ CHAR16 *Cwd;\r
+ UINTN CwdSize;\r
SHELL_STATUS ShellStatus;\r
UINTN ParamCount;\r
UINTN LoopCounter;\r
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);\r
if (EFI_ERROR(Status)) {\r
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, ProblemParam);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mv", ProblemParam);\r
FreePool(ProblemParam);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
//\r
// we have insufficient parameters\r
//\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mv");\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
break;\r
case 2:\r
// must have valid CWD for single parameter...\r
//\r
if (ShellGetCurrentDir(NULL) == NULL){\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"mv");\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);\r
if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, 1));\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1));\r
ShellStatus = SHELL_NOT_FOUND;\r
} else {\r
//\r
// ValidateAndMoveFiles will report errors to the screen itself\r
//\r
- ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellGetCurrentDir(NULL));\r
+ CwdSize = StrSize(ShellGetCurrentDir(NULL)) + sizeof(CHAR16);\r
+ Cwd = AllocateZeroPool(CwdSize);\r
+ if (Cwd == NULL) {\r
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"mv");\r
+ ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+ } else {\r
+ StrCpyS (Cwd, CwdSize / sizeof (CHAR16), ShellGetCurrentDir (NULL));\r
+ StrCatS (Cwd, CwdSize / sizeof (CHAR16), L"\\");\r
+ ShellStatus = ValidateAndMoveFiles (FileList, &Response, Cwd);\r
+ FreePool (Cwd);\r
+ }\r
}\r
}\r
\r
}\r
Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);\r
if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, LoopCounter));\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, LoopCounter));\r
ShellStatus = SHELL_NOT_FOUND;\r
} else {\r
//\r
Status = ShellCloseFileMetaArg(&FileList);\r
if (EFI_ERROR(Status) && ShellStatus == SHELL_SUCCESS) {\r
ShellStatus = SHELL_ACCESS_DENIED;\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, ShellCommandLineGetRawValue(Package, 1), ShellStatus|MAX_BIT);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"mv", ShellCommandLineGetRawValue(Package, 1), ShellStatus|MAX_BIT);\r
}\r
}\r
}\r