/** @file\r
Main file for ls shell level 2 function.\r
\r
- Copyright (c) 2013 Hewlett-Packard Development Company, L.P.\r
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ (C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
+ Copyright (c) 2009 - 2017, 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
#include "UefiShellLevel2CommandsLib.h"\r
#include <Guid/FileSystemInfo.h>\r
\r
+UINTN mDayOfMonth[] = {31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30};\r
+\r
/**\r
print out the standard format output volume entry.\r
\r
@param[in] TheList a list of files from the volume.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
PrintSfoVolumeInfoTableEntry(\r
IN CONST EFI_SHELL_FILE_INFO *TheList\r
)\r
\r
**/\r
VOID\r
-EFIAPI\r
PrintFileInformation(\r
IN CONST BOOLEAN Sfo, \r
IN CONST EFI_SHELL_FILE_INFO *TheNode, \r
@param[in] Path String with starting path.\r
**/\r
VOID\r
-EFIAPI\r
PrintNonSfoHeader(\r
IN CONST CHAR16 *Path\r
)\r
/**\r
print out the footer when not using standard format output.\r
\r
- @param[in] Path String with starting path.\r
+ @param[in] Files The number of files.\r
+ @param[in] Size The size of files in bytes.\r
+ @param[in] Dirs The number of directories.\r
**/\r
VOID\r
-EFIAPI\r
PrintNonSfoFooter(\r
IN UINT64 Files, \r
IN UINT64 Size, \r
);\r
}\r
\r
+/**\r
+ Change the file time to local time based on the timezone.\r
+\r
+ @param[in] Time The file time.\r
+ @param[in] LocalTimeZone Local time zone.\r
+**/\r
+VOID\r
+FileTimeToLocalTime (\r
+ IN EFI_TIME *Time,\r
+ IN INT16 LocalTimeZone\r
+ )\r
+{\r
+ INTN MinuteDiff;\r
+ INTN TempMinute;\r
+ INTN HourNumberOfTempMinute;\r
+ INTN TempHour;\r
+ INTN DayNumberOfTempHour;\r
+ INTN TempDay;\r
+ INTN MonthNumberOfTempDay;\r
+ INTN TempMonth;\r
+ INTN YearNumberOfTempMonth;\r
+ INTN MonthRecord;\r
+\r
+ ASSERT ((Time->TimeZone >= -1440) && (Time->TimeZone <=1440));\r
+ ASSERT ((LocalTimeZone >= -1440) && (LocalTimeZone <=1440));\r
+ ASSERT ((Time->Month >= 1) && (Time->Month <= 12));\r
+\r
+ if(Time->TimeZone == LocalTimeZone) {\r
+ //\r
+ //if the file timezone is equal to the local timezone, there is no need to adjust the file time.\r
+ //\r
+ return;\r
+ }\r
+\r
+ if((Time->Year % 4 == 0 && Time->Year / 100 != 0)||(Time->Year % 400 == 0)) {\r
+ //\r
+ // Day in February of leap year is 29.\r
+ //\r
+ mDayOfMonth[1] = 29;\r
+ }\r
+\r
+ MinuteDiff = Time->TimeZone - LocalTimeZone;\r
+ TempMinute = Time->Minute + MinuteDiff;\r
+\r
+ //\r
+ // Calculate Time->Minute\r
+ // TempHour will be used to calculate Time->Hour\r
+ //\r
+ HourNumberOfTempMinute = TempMinute / 60;\r
+ if(TempMinute < 0) {\r
+ HourNumberOfTempMinute --; \r
+ }\r
+ TempHour = Time->Hour + HourNumberOfTempMinute;\r
+ Time->Minute = (UINT8)(TempMinute - 60 * HourNumberOfTempMinute);\r
+\r
+ //\r
+ // Calculate Time->Hour\r
+ // TempDay will be used to calculate Time->Day\r
+ //\r
+ DayNumberOfTempHour = TempHour / 24 ;\r
+ if(TempHour < 0){\r
+ DayNumberOfTempHour--;\r
+ }\r
+ TempDay = Time->Day + DayNumberOfTempHour;\r
+ Time->Hour = (UINT8)(TempHour - 24 * DayNumberOfTempHour);\r
+\r
+ //\r
+ // Calculate Time->Day\r
+ // TempMonth will be used to calculate Time->Month\r
+ //\r
+ MonthNumberOfTempDay = (TempDay - 1) / (INTN)mDayOfMonth[Time->Month - 1];\r
+ MonthRecord = (INTN)(Time->Month) ;\r
+ if(TempDay - 1 < 0){\r
+ MonthNumberOfTempDay -- ;\r
+ MonthRecord -- ;\r
+ }\r
+ TempMonth = Time->Month + MonthNumberOfTempDay;\r
+ Time->Day = (UINT8)(TempDay - (INTN)mDayOfMonth[(MonthRecord - 1 + 12) % 12] * MonthNumberOfTempDay);\r
+\r
+ //\r
+ // Calculate Time->Month, Time->Year\r
+ //\r
+ YearNumberOfTempMonth = (TempMonth - 1) / 12;\r
+ if(TempMonth - 1 < 0){\r
+ YearNumberOfTempMonth --;\r
+ }\r
+ Time->Month = (UINT8)(TempMonth - 12 * (YearNumberOfTempMonth));\r
+ Time->Year = (UINT16)(Time->Year + YearNumberOfTempMonth);\r
+}\r
+\r
/**\r
print out the list of files and directories from the LS command\r
\r
@param[in] Attribs List of required Attribute for display.\r
If 0 then all non-system and non-hidden files will be printed.\r
@param[in] Sfo TRUE to use Standard Format Output, FALSE otherwise\r
- @param[in] Path String with starting path.\r
- @param[in] First TRUE for the original and FALSE for any recursion spawned instances.\r
+ @param[in] RootPath String with starting path to search in.\r
+ @param[in] SearchString String with search string.\r
+ @param[in] Found Set to TRUE, if anyone were found.\r
@param[in] Count The count of bits enabled in Attribs.\r
@param[in] TimeZone The current time zone offset.\r
\r
@retval SHELL_SUCCESS the printing was sucessful.\r
**/\r
SHELL_STATUS\r
-EFIAPI\r
PrintLsOutput(\r
IN CONST BOOLEAN Rec,\r
IN CONST UINT64 Attribs,\r
IN CONST BOOLEAN Sfo,\r
- IN CONST CHAR16 *Path,\r
- IN CONST BOOLEAN First,\r
+ IN CONST CHAR16 *RootPath,\r
+ IN CONST CHAR16 *SearchString,\r
+ IN BOOLEAN *Found,\r
IN CONST UINTN Count,\r
IN CONST INT16 TimeZone\r
)\r
UINT64 FileCount;\r
UINT64 DirCount;\r
UINT64 FileSize;\r
- CHAR16 *DirectoryName;\r
UINTN LongestPath;\r
CHAR16 *CorrectedPath;\r
+ BOOLEAN FoundOne;\r
+ BOOLEAN HeaderPrinted;\r
+ EFI_TIME LocalTime;\r
\r
+ HeaderPrinted = FALSE;\r
FileCount = 0;\r
DirCount = 0;\r
FileSize = 0;\r
LongestPath = 0;\r
CorrectedPath = NULL;\r
\r
- CorrectedPath = StrnCatGrow(&CorrectedPath, NULL, Path, 0);\r
+ if (Found != NULL) {\r
+ FoundOne = *Found;\r
+ } else {\r
+ FoundOne = FALSE;\r
+ }\r
+\r
+ CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath, 0);\r
+ if (CorrectedPath == NULL) {\r
+ return SHELL_OUT_OF_RESOURCES;\r
+ }\r
+ if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\'\r
+ &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') {\r
+ CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\", 0);\r
+ }\r
+ CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, SearchString, 0);\r
if (CorrectedPath == NULL) {\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
\r
PathCleanUpDirectories(CorrectedPath);\r
\r
- if (!Sfo) {\r
- PrintNonSfoHeader(CorrectedPath);\r
- }\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
+ if (!EFI_ERROR(Status)) {\r
+ if (ListHead == NULL || IsListEmpty(&ListHead->Link)) {\r
+ SHELL_FREE_NON_NULL(CorrectedPath);\r
+ return (SHELL_SUCCESS);\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
- //\r
- if (First) {\r
- return (SHELL_NOT_FOUND);\r
+\r
+ if (Sfo && Found == NULL) {\r
+ PrintSfoVolumeInfoTableEntry(ListHead);\r
}\r
- return (SHELL_SUCCESS);\r
- }\r
\r
- if (Sfo && First) {\r
- PrintSfoVolumeInfoTableEntry(ListHead);\r
- }\r
+ for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link), LongestPath = 0\r
+ ; !IsNull(&ListHead->Link, &Node->Link)\r
+ ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)\r
+ ){\r
+ if (ShellGetExecutionBreakFlag ()) {\r
+ ShellStatus = SHELL_ABORTED;\r
+ break;\r
+ }\r
+ ASSERT(Node != NULL);\r
\r
- for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)\r
- ; !IsNull(&ListHead->Link, &Node->Link)\r
- ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)\r
- ){\r
- ASSERT(Node != NULL);\r
- if (LongestPath < StrSize(Node->FullName)) {\r
- LongestPath = StrSize(Node->FullName);\r
- }\r
- ASSERT(Node->Info != NULL);\r
- ASSERT((Node->Info->Attribute & EFI_FILE_VALID_ATTR) == Node->Info->Attribute);\r
- if (Attribs == 0) {\r
//\r
- // NOT system & NOT hidden\r
+ // Change the file time to local time.\r
//\r
- if ( (Node->Info->Attribute & EFI_FILE_SYSTEM)\r
- || (Node->Info->Attribute & EFI_FILE_HIDDEN)\r
- ){\r
- continue;\r
+ Status = gRT->GetTime(&LocalTime, NULL);\r
+ if (!EFI_ERROR (Status)) {\r
+ if ((Node->Info->CreateTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) &&\r
+ (Node->Info->CreateTime.Month >= 1 && Node->Info->CreateTime.Month <= 12)) {\r
+ //\r
+ // FileTimeToLocalTime () requires Month is in a valid range, other buffer out-of-band access happens.\r
+ //\r
+ FileTimeToLocalTime (&Node->Info->CreateTime, LocalTime.TimeZone);\r
+ }\r
+ if ((Node->Info->LastAccessTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) &&\r
+ (Node->Info->LastAccessTime.Month >= 1 && Node->Info->LastAccessTime.Month <= 12)) {\r
+ FileTimeToLocalTime (&Node->Info->LastAccessTime, LocalTime.TimeZone);\r
+ }\r
+ if ((Node->Info->ModificationTime.TimeZone != EFI_UNSPECIFIED_TIMEZONE) &&\r
+ (Node->Info->ModificationTime.Month >= 1 && Node->Info->ModificationTime.Month <= 12)) {\r
+ FileTimeToLocalTime (&Node->Info->ModificationTime, LocalTime.TimeZone);\r
+ }\r
}\r
- } else if ((Attribs != EFI_FILE_VALID_ATTR) ||\r
- (Count == 5)) {\r
- //\r
- // Only matches the bits which "Attribs" contains, not\r
- // all files/directories with any of the bits.\r
- // Count == 5 is used to tell the difference between a user\r
- // specifying all bits (EX: -arhsda) and just specifying\r
- // -a (means display all files with any attribute).\r
- //\r
- if ( (Node->Info->Attribute & Attribs) != Attribs) {\r
- continue;\r
+\r
+ if (LongestPath < StrSize(Node->FullName)) {\r
+ LongestPath = StrSize(Node->FullName);\r
+ }\r
+ ASSERT(Node->Info != NULL);\r
+ ASSERT((Node->Info->Attribute & EFI_FILE_VALID_ATTR) == Node->Info->Attribute);\r
+ if (Attribs == 0) {\r
+ //\r
+ // NOT system & NOT hidden\r
+ //\r
+ if ( (Node->Info->Attribute & EFI_FILE_SYSTEM)\r
+ || (Node->Info->Attribute & EFI_FILE_HIDDEN)\r
+ ){\r
+ continue;\r
+ }\r
+ } else if ((Attribs != EFI_FILE_VALID_ATTR) ||\r
+ (Count == 5)) {\r
+ //\r
+ // Only matches the bits which "Attribs" contains, not\r
+ // all files/directories with any of the bits.\r
+ // Count == 5 is used to tell the difference between a user\r
+ // specifying all bits (EX: -arhsda) and just specifying\r
+ // -a (means display all files with any attribute).\r
+ //\r
+ if ( (Node->Info->Attribute & Attribs) != Attribs) {\r
+ continue;\r
+ }\r
}\r
- }\r
\r
- PrintFileInformation(Sfo, Node, &FileCount, &FileSize, &DirCount);\r
- }\r
+ if (!Sfo && !HeaderPrinted) {\r
+ PathRemoveLastItem (CorrectedPath);\r
+ PrintNonSfoHeader(CorrectedPath);\r
+ }\r
+ PrintFileInformation(Sfo, Node, &FileCount, &FileSize, &DirCount);\r
+ FoundOne = TRUE;\r
+ HeaderPrinted = TRUE;\r
+ }\r
\r
- if (!Sfo) {\r
- PrintNonSfoFooter(FileCount, FileSize, DirCount);\r
+ if (!Sfo && ShellStatus != SHELL_ABORTED) {\r
+ PrintNonSfoFooter(FileCount, FileSize, DirCount);\r
+ }\r
}\r
\r
- if (Rec){\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
- } else {\r
+ if (Rec && ShellStatus != SHELL_ABORTED) {\r
+ //\r
+ // Re-Open all the files under the starting path for directories that didnt necessarily match our file filter\r
+ //\r
+ ShellCloseFileMetaArg(&ListHead);\r
+ CorrectedPath[0] = CHAR_NULL;\r
+ CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, RootPath, 0);\r
+ if (CorrectedPath == NULL) {\r
+ return SHELL_OUT_OF_RESOURCES;\r
+ }\r
+ if (CorrectedPath[StrLen(CorrectedPath)-1] != L'\\'\r
+ &&CorrectedPath[StrLen(CorrectedPath)-1] != L'/') {\r
+ CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"\\", 0);\r
+ }\r
+ CorrectedPath = StrnCatGrow(&CorrectedPath, &LongestPath, L"*", 0);\r
+ Status = ShellOpenFileMetaArg((CHAR16*)CorrectedPath, EFI_FILE_MODE_READ, &ListHead);\r
+ \r
+ if (!EFI_ERROR(Status)) {\r
for ( Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link)\r
; !IsNull(&ListHead->Link, &Node->Link) && ShellStatus == SHELL_SUCCESS\r
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&ListHead->Link, &Node->Link)\r
&& StrCmp(Node->FileName, L".") != 0\r
&& StrCmp(Node->FileName, L"..") != 0\r
){\r
- StrCpy(DirectoryName, Node->FullName);\r
- StrCat(DirectoryName, L"\\*");\r
ShellStatus = PrintLsOutput(\r
Rec,\r
Attribs,\r
Sfo,\r
- DirectoryName,\r
- FALSE,\r
+ Node->FullName,\r
+ SearchString,\r
+ &FoundOne,\r
Count,\r
TimeZone);\r
+ \r
+ //\r
+ // Since it's running recursively, we have to break immediately when returned SHELL_ABORTED\r
+ //\r
+ if (ShellStatus == SHELL_ABORTED) {\r
+ break;\r
+ }\r
}\r
}\r
- FreePool(DirectoryName);\r
}\r
}\r
\r
- FreePool(CorrectedPath);\r
+ SHELL_FREE_NON_NULL(CorrectedPath);\r
ShellCloseFileMetaArg(&ListHead);\r
+\r
+ if (Found == NULL && !FoundOne) {\r
+ return (SHELL_NOT_FOUND);\r
+ }\r
+\r
+ if (Found != NULL) {\r
+ *Found = FoundOne;\r
+ }\r
+\r
return (ShellStatus);\r
}\r
\r
CHAR16 *FullPath;\r
UINTN Size;\r
EFI_TIME TheTime;\r
- BOOLEAN SfoMode;\r
+ CHAR16 *SearchString;\r
\r
Size = 0;\r
FullPath = NULL;\r
ShellStatus = SHELL_SUCCESS;\r
RequiredAttributes = 0;\r
PathName = NULL;\r
+ SearchString = NULL;\r
CurDir = NULL;\r
Count = 0;\r
\r
Status = ShellCommandLineParse (LsParamList, &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"ls", ProblemParam); \r
FreePool(ProblemParam);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
}\r
\r
if (ShellCommandLineGetCount(Package) > 2) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"ls"); \r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
//\r
Count++;\r
continue;\r
default:\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ATTRIBUTE), gShellLevel2HiiHandle, ShellCommandLineGetValue(Package, L"-a"));\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ATTRIBUTE), gShellLevel2HiiHandle, L"ls", ShellCommandLineGetValue(Package, L"-a")); \r
ShellStatus = SHELL_INVALID_PARAMETER;\r
break;\r
} // switch\r
if (ShellStatus == SHELL_SUCCESS) {\r
PathName = ShellCommandLineGetRawValue(Package, 1);\r
if (PathName == NULL) {\r
+ //\r
+ // Nothing specified... must start from current directory\r
+ //\r
CurDir = gEfiShellProtocol->GetCurDir(NULL);\r
if (CurDir == NULL) {\r
ShellStatus = SHELL_NOT_FOUND;\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"ls"); \r
}\r
- }\r
- if (PathName != NULL) {\r
+ //\r
+ // Copy to the 2 strings for starting path and file search string\r
+ //\r
+ ASSERT(SearchString == NULL);\r
+ ASSERT(FullPath == NULL);\r
+ StrnCatGrow(&SearchString, NULL, L"*", 0);\r
+ StrnCatGrow(&FullPath, NULL, CurDir, 0);\r
+ Size = FullPath != NULL? StrSize(FullPath) : 0;\r
+ StrnCatGrow(&FullPath, &Size, L"\\", 0);\r
+ } else {\r
if (StrStr(PathName, L":") == NULL && gEfiShellProtocol->GetCurDir(NULL) == NULL) {\r
+ //\r
+ // If we got something and it doesnt have a fully qualified path, then we needed to have a CWD.\r
+ //\r
ShellStatus = SHELL_NOT_FOUND;\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"ls"); \r
} else {\r
+ //\r
+ // We got a valid fully qualified path or we have a CWD\r
+ //\r
ASSERT((FullPath == NULL && Size == 0) || (FullPath != NULL));\r
+ if (StrStr(PathName, L":") == NULL) {\r
+ StrnCatGrow(&FullPath, &Size, gEfiShellProtocol->GetCurDir(NULL), 0);\r
+ if (FullPath == NULL) {\r
+ ShellCommandLineFreeVarList (Package);\r
+ return SHELL_OUT_OF_RESOURCES;\r
+ }\r
+ Size = FullPath != NULL? StrSize(FullPath) : 0;\r
+ StrnCatGrow(&FullPath, &Size, L"\\", 0);\r
+ }\r
StrnCatGrow(&FullPath, &Size, PathName, 0);\r
+ if (FullPath == NULL) {\r
+ ShellCommandLineFreeVarList (Package);\r
+ return SHELL_OUT_OF_RESOURCES;\r
+ }\r
+ \r
if (ShellIsDirectory(PathName) == EFI_SUCCESS) {\r
- if (PathName[StrLen (PathName) - 1] == '\\') {\r
- //\r
- // For path ending with '\', just append '*'.\r
- //\r
- StrnCatGrow (&FullPath, &Size, L"*", 0);\r
- } else if (PathName[StrLen (PathName) - 1] == '*') {\r
- //\r
- // For path ending with '*', do nothing.\r
- //\r
- } else {\r
- //\r
- // Otherwise, append '\*' to directory name.\r
- //\r
- StrnCatGrow (&FullPath, &Size, L"\\*", 0);\r
+ //\r
+ // is listing ends with a directory, then we list all files in that directory\r
+ //\r
+ StrnCatGrow(&SearchString, NULL, L"*", 0);\r
+ } else {\r
+ //\r
+ // must split off the search part that applies to files from the end of the directory part\r
+ //\r
+ StrnCatGrow(&SearchString, NULL, FullPath, 0);\r
+ if (SearchString == NULL) {\r
+ FreePool (FullPath);\r
+ ShellCommandLineFreeVarList (Package);\r
+ return SHELL_OUT_OF_RESOURCES;\r
}\r
+ PathRemoveLastItem (FullPath);\r
+ CopyMem (SearchString, SearchString + StrLen (FullPath), StrSize (SearchString + StrLen (FullPath)));\r
}\r
}\r
- } else {\r
- ASSERT(FullPath == NULL);\r
- StrnCatGrow(&FullPath, NULL, L"*", 0);\r
}\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
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"ls", 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
ShellCommandLineGetFlag(Package, L"-r"),\r
RequiredAttributes,\r
- SfoMode,\r
+ ShellCommandLineGetFlag(Package, L"-sfo"),\r
FullPath,\r
- TRUE,\r
+ SearchString,\r
+ NULL,\r
Count,\r
- (INT16)(TheTime.TimeZone==EFI_UNSPECIFIED_TIMEZONE?0:TheTime.TimeZone)\r
+ TheTime.TimeZone\r
);\r
if (ShellStatus == SHELL_NOT_FOUND) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LS_FILE_NOT_FOUND), gShellLevel2HiiHandle);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_LS_FILE_NOT_FOUND), gShellLevel2HiiHandle, L"ls", FullPath); \r
} else if (ShellStatus == SHELL_INVALID_PARAMETER) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"ls", FullPath); \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
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel2HiiHandle, L"ls", FullPath); \r
}\r
}\r
}\r
}\r
}\r
\r
- if (FullPath != NULL) {\r
- FreePool(FullPath);\r
- }\r
//\r
- // free the command line package\r
+ // Free memory allocated\r
//\r
+ SHELL_FREE_NON_NULL(SearchString);\r
+ SHELL_FREE_NON_NULL(FullPath);\r
ShellCommandLineFreeVarList (Package);\r
\r
return (ShellStatus);\r