]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
ShellPkg: remove high bit to change a EFI_STATUS to a SHELL_STATUS
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Ls.c
index a93b54c4293d58f1855df611e4ee4e9992bcc0c0..55267a467a02ee42cca9398c228d83d26e7d9c1d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for ls shell level 2 function.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, 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
@@ -66,14 +66,22 @@ PrintLsOutput(
   CorrectedPath = NULL;\r
 \r
   CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);\r
-  ASSERT(CorrectedPath != NULL);\r
+  if (CorrectedPath == NULL) {\r
+    return (SHELL_OUT_OF_RESOURCES);\r
+  }\r
+\r
   PathCleanUpDirectories(CorrectedPath);\r
 \r
   Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);\r
   if (EFI_ERROR(Status)) {\r
+    SHELL_FREE_NON_NULL(CorrectedPath);\r
+    if(Status == EFI_NOT_FOUND){\r
+      return (SHELL_NOT_FOUND);\r
+    }\r
     return (SHELL_DEVICE_ERROR);\r
   }\r
   if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {\r
+    SHELL_FREE_NON_NULL(CorrectedPath);\r
     //\r
     // On the first one only we expect to find something...\r
     // do we find the . and .. directories otherwise?\r
@@ -354,9 +362,14 @@ PrintLsOutput(
       ShellStatus = SHELL_OUT_OF_RESOURCES;\r
     } else {\r
       for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)\r
-          ; !IsNull(&ListHead->Link, &Node->Link)\r
+          ; !IsNull(&ListHead->Link, &Node->Link) && ShellStatus == SHELL_SUCCESS\r
           ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)\r
          ){\r
+        if (ShellGetExecutionBreakFlag ()) {\r
+          ShellStatus = SHELL_ABORTED;\r
+          break;\r
+        }\r
+\r
         //\r
         // recurse on any directory except the traversing ones...\r
         //\r
@@ -366,7 +379,7 @@ PrintLsOutput(
          ){\r
           StrCpy(DirectoryName, Node->FullName);\r
           StrCat(DirectoryName, L"\\*");\r
-          PrintLsOutput(\r
+          ShellStatus = PrintLsOutput(\r
             Rec,\r
             Attribs,\r
             Sfo,\r
@@ -558,6 +571,10 @@ ShellCommandRunLs (
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_FILES), gShellLevel2HiiHandle);\r
           } else if (ShellStatus == SHELL_INVALID_PARAMETER) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle);\r
+          } else if (ShellStatus == SHELL_ABORTED) {\r
+            //\r
+            // Ignore aborting.\r
+            //\r
           } else if (ShellStatus != SHELL_SUCCESS) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle);\r
           }\r