]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Mv.c
ShellPkg: Update "ls" command to better handle "-r" parameter
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Mv.c
index 11abee07664b12d2a114c835a395fa856e2b2e32..65e83ccc0f4336130f150df627acb0fec860a577 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Main file for mv shell level 2 function.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2013, Hewlett-Packard Development Company, L.P.\r
+  Copyright (c) 2009 - 2013, 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
@@ -136,8 +137,8 @@ GetDestinationLocation(
   EFI_SHELL_FILE_INFO       *DestList;\r
   EFI_SHELL_FILE_INFO       *Node;\r
   CHAR16                    *DestPath;\r
-  CHAR16                    *TempLocation;\r
   UINTN                     NewSize;\r
+  UINTN                     CurrentSize;\r
 \r
   DestList = NULL;\r
   DestPath = NULL;\r
@@ -152,6 +153,13 @@ GetDestinationLocation(
     }\r
     StrCpy(DestPath, Cwd);\r
     while (PathRemoveLastItem(DestPath)) ;\r
+\r
+    //\r
+    // Append DestDir beyond '\' which may be present\r
+    //\r
+    CurrentSize = StrSize(DestPath);\r
+    StrnCatGrow(&DestPath, &CurrentSize, &DestDir[1], 0);\r
+\r
     *DestPathPointer =  DestPath;\r
     return (SHELL_SUCCESS);\r
   }\r
@@ -163,7 +171,7 @@ GetDestinationLocation(
     //\r
     // Not existing... must be renaming\r
     //\r
-    if ((TempLocation = StrStr(DestDir, L":")) == NULL) {\r
+    if (StrStr(DestDir, L":") == NULL) {\r
       if (Cwd == NULL) {\r
         ShellCloseFileMetaArg(&DestList);\r
         return (SHELL_INVALID_PARAMETER);\r
@@ -404,23 +412,18 @@ ValidateAndMoveFiles(
       //\r
       if (EFI_ERROR(Status)) {\r
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_UK), gShellLevel2HiiHandle, Status);\r
-        //\r
-        // move failed\r
-        //\r
-        switch(Status){\r
-          default:\r
-            ShellStatus = SHELL_INVALID_PARAMETER;\r
-          case EFI_SECURITY_VIOLATION:\r
-            ShellStatus = SHELL_SECURITY_VIOLATION;\r
-          case EFI_WRITE_PROTECTED:\r
-            ShellStatus = SHELL_WRITE_PROTECTED;\r
-          case EFI_OUT_OF_RESOURCES:\r
-            ShellStatus = SHELL_OUT_OF_RESOURCES;\r
-          case EFI_DEVICE_ERROR:\r
-            ShellStatus = SHELL_DEVICE_ERROR;\r
-          case EFI_ACCESS_DENIED:\r
-            ShellStatus = SHELL_ACCESS_DENIED;\r
-        } // switch\r
+        ShellStatus = SHELL_INVALID_PARAMETER;\r
+        if (Status == EFI_SECURITY_VIOLATION) {\r
+          ShellStatus = SHELL_SECURITY_VIOLATION;\r
+        } else if (Status == EFI_WRITE_PROTECTED) {\r
+          ShellStatus = SHELL_WRITE_PROTECTED;\r
+        } else if (Status == EFI_OUT_OF_RESOURCES) {\r
+          ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+        } else if (Status == EFI_DEVICE_ERROR) {\r
+          ShellStatus = SHELL_DEVICE_ERROR;\r
+        } else if (Status == EFI_ACCESS_DENIED) {\r
+          ShellStatus = SHELL_ACCESS_DENIED;\r
+        }\r
       } else {\r
         ShellPrintEx(-1, -1, L"%s", HiiResultOk);\r
       }\r