/** @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) 2013 - 2015, Hewlett-Packard Development Company, L.P.<BR>\r
Copyright (c) 2009 - 2014, 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
@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
\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
@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
//\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
// 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
return (Status);\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
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
@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
//\r
// Get and validate the destination location\r
//\r
- ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd, FileList->Link.ForwardLink == FileList->Link.BackLink, &Attr);\r
+ ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);\r
FreePool (CleanFilePathStr);\r
\r
if (ShellStatus != SHELL_SUCCESS) {\r
SHELL_FREE_NON_NULL(FullDestPath);\r
FullDestPath = NULL;\r
if (ShellIsDirectory(DestPath)==EFI_SUCCESS) {\r
- CreateFullDestPath(&DestPath, &FullDestPath, Node->FileName);\r
+ CreateFullDestPath((CONST CHAR16 **)&DestPath, &FullDestPath, Node->FileName);\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, Cwd, 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
FreePool(Response);\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
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
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
}\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