]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
ShellPkg: Standardized HP Copyright Message String
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Mv.c
index e3af4c8cb177e285b3644038a996393859379275..916020419509469f6c4f74defe8dc15bc3de7215 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for mv shell level 2 function.\r
 \r
-  (C) Copyright 2013-2014, Hewlett-Packard Development Company, L.P.\r
+  (C) Copyright 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
@@ -25,7 +25,6 @@
   @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
@@ -69,17 +68,16 @@ IsBetweenFileSystem(
 \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
@@ -152,13 +150,14 @@ IsValidMove(
   @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
@@ -244,7 +243,7 @@ GetDestinationLocation(
     //\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
@@ -264,7 +263,7 @@ GetDestinationLocation(
       // 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
@@ -275,6 +274,15 @@ GetDestinationLocation(
   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
@@ -304,6 +312,17 @@ MoveBetweenFileSystems(
   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
@@ -333,6 +352,16 @@ CreateFullDestPath(
   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
@@ -414,7 +443,6 @@ MoveWithinFileSystems(
   @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
@@ -459,7 +487,7 @@ ValidateAndMoveFiles(
   //\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
@@ -513,17 +541,17 @@ ValidateAndMoveFiles(
     //\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
@@ -549,14 +577,14 @@ ValidateAndMoveFiles(
           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
@@ -631,7 +659,7 @@ ShellCommandRunMv (
   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
@@ -651,7 +679,7 @@ ShellCommandRunMv (
         //\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
@@ -659,12 +687,12 @@ ShellCommandRunMv (
         // 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
@@ -683,7 +711,7 @@ ShellCommandRunMv (
           }\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
@@ -700,7 +728,7 @@ ShellCommandRunMv (
             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