]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
ShellPkg/ls: Fix to support "ls fs0:File.txt"
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Ls.c
index 25bf8ca9e13a124a40ac33bf2293b45e27536f41..6d3cc95f4b9bfefe5a5305b3faedd61cad56468c 100644 (file)
@@ -2,7 +2,7 @@
   Main file for ls shell level 2 function.\r
 \r
   (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, 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
@@ -707,10 +707,9 @@ ShellCommandRunLs (
               //\r
               // must split off the search part that applies to files from the end of the directory part\r
               //\r
-              for (StrnCatGrow(&SearchString, NULL, PathName, 0)\r
-                ; SearchString != NULL && StrStr(SearchString, L"\\") != NULL\r
-                ; CopyMem(SearchString, StrStr(SearchString, L"\\") + 1, 1 + StrSize(StrStr(SearchString, L"\\") + 1))) ;\r
-              FullPath[StrLen(FullPath) - StrLen(SearchString)] = CHAR_NULL;\r
+              StrnCatGrow(&SearchString, NULL, FullPath, 0);\r
+              PathRemoveLastItem (FullPath);\r
+              CopyMem (SearchString, SearchString + StrLen (FullPath), StrSize (SearchString + StrLen (FullPath)));\r
             }\r
           }\r
         }\r