]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellLevel2CommandsLib/Ls.c
This refactors 3 functions out of ShellCommandLib and puts them into a new library...
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel2CommandsLib / Ls.c
index 440d2450f5c068ef537564493fb66ab93f8841fe..a93b54c4293d58f1855df611e4ee4e9992bcc0c0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for ls shell level 2 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2011, 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
@@ -67,7 +67,7 @@ PrintLsOutput(
 \r
   CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);\r
   ASSERT(CorrectedPath != NULL);\r
-  ShellCommandCleanPath(CorrectedPath);\r
+  PathCleanUpDirectories(CorrectedPath);\r
 \r
   Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);\r
   if (EFI_ERROR(Status)) {\r
@@ -234,7 +234,7 @@ PrintLsOutput(
         //\r
         // exact match on all bits\r
         //\r
-        if ( Node->Info->Attribute != Attribs) {\r
+        if ( (Node->Info->Attribute|EFI_FILE_ARCHIVE) != (Attribs|EFI_FILE_ARCHIVE)) {\r
           continue;\r
         }\r
       }\r
@@ -348,7 +348,7 @@ PrintLsOutput(
   }\r
 \r
   if (Rec){\r
-    DirectoryName = AllocatePool(LongestPath + 2*sizeof(CHAR16));\r
+    DirectoryName = AllocateZeroPool(LongestPath + 2*sizeof(CHAR16));\r
     if (DirectoryName == NULL) {\r
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_MEM), gShellLevel2HiiHandle);\r
       ShellStatus = SHELL_OUT_OF_RESOURCES;\r
@@ -417,7 +417,7 @@ ShellCommandRunLs (
   UINTN         Count;\r
   CHAR16        *FullPath;\r
   UINTN         Size;\r
-  EFI_TIME      theTime;\r
+  EFI_TIME      TheTime;\r
   BOOLEAN       SfoMode;\r
 \r
   Size                = 0;\r
@@ -523,17 +523,26 @@ ShellCommandRunLs (
           }\r
         }\r
         if (PathName != NULL) {\r
-          ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));\r
-          StrnCatGrow(&FullPath, &Size, PathName, 0);\r
-          if  (ShellIsDirectory(PathName) == EFI_SUCCESS) {\r
-            StrnCatGrow(&FullPath, &Size, L"\\*", 0);\r
+          if (StrStr(PathName, L":") == NULL && gEfiShellProtocol->GetCurDir(NULL) == NULL) {\r
+            ShellStatus = SHELL_NOT_FOUND;\r
+            ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle);\r
+          } else {\r
+            ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));\r
+            StrnCatGrow(&FullPath, &Size, PathName, 0);\r
+            if  (ShellIsDirectory(PathName) == EFI_SUCCESS) {\r
+              StrnCatGrow(&FullPath, &Size, L"\\*", 0);\r
+            }\r
           }\r
         } else {\r
           ASSERT(FullPath == NULL);\r
           StrnCatGrow(&FullPath, NULL, L"*", 0);\r
         }\r
-        Status = gRT->GetTime(&theTime, NULL);\r
-        ASSERT_EFI_ERROR(Status);\r
+        Status = gRT->GetTime(&TheTime, NULL);\r
+        if (EFI_ERROR(Status)) {\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);\r
+          TheTime.TimeZone = EFI_UNSPECIFIED_TIMEZONE;\r
+        }\r
+\r
         SfoMode = ShellCommandLineGetFlag(Package, L"-sfo");\r
         if (ShellStatus == SHELL_SUCCESS) {\r
           ShellStatus = PrintLsOutput(\r
@@ -543,7 +552,7 @@ ShellCommandRunLs (
             FullPath,\r
             TRUE,\r
             Count,\r
-            (INT16)(theTime.TimeZone==2047?0:theTime.TimeZone)\r
+            (INT16)(TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:TheTime.TimeZone)\r
            );\r
           if (ShellStatus == SHELL_NOT_FOUND) {\r
             ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_FILES), gShellLevel2HiiHandle);\r