13UINTN mDayOfMonth[] = { 31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31, 30 };
27 CHAR16 *DirectoryName;
30 SHELL_FILE_HANDLE ShellFileHandle;
45 if (DirectoryName ==
NULL) {
46 return (EFI_OUT_OF_RESOURCES);
52 Status = gEfiShellProtocol->OpenFileByName (
67 Status = EfiFpHandle->GetInfo (
69 &gEfiFileSystemInfoGuid,
74 if (Status == EFI_BUFFER_TOO_SMALL) {
76 if (SysInfo ==
NULL) {
77 gEfiShellProtocol->CloseFile (ShellFileHandle);
78 return (EFI_OUT_OF_RESOURCES);
81 Status = EfiFpHandle->GetInfo (
83 &gEfiFileSystemInfoGuid,
91 gEfiShellProtocol->CloseFile (ShellFileHandle);
99 Status = EfiFpHandle->GetInfo (
101 &gEfiFileSystemInfoGuid,
106 if (Status == EFI_BUFFER_TOO_SMALL) {
108 if (SysInfo ==
NULL) {
109 return (EFI_OUT_OF_RESOURCES);
112 Status = EfiFpHandle->GetInfo (
114 &gEfiFileSystemInfoGuid,
128 gShellLevel2HiiHandle,
134 ASSERT (SysInfo !=
NULL);
140 gShellLevel2HiiHandle,
143 SysInfo->
ReadOnly ? L
"TRUE" : L
"FALSE",
148 SHELL_FREE_NON_NULL (SysInfo);
172 ASSERT (Files !=
NULL);
173 ASSERT (Size !=
NULL);
174 ASSERT (Dirs !=
NULL);
175 ASSERT (TheNode !=
NULL);
186 gShellLevel2HiiHandle,
188 TheNode->Info->FileSize,
189 TheNode->Info->PhysicalSize,
190 (TheNode->Info->Attribute & EFI_FILE_ARCHIVE) != 0 ? L
"a" : L
"",
191 (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) != 0 ? L
"d" : L
"",
192 (TheNode->Info->Attribute & EFI_FILE_HIDDEN) != 0 ? L
"h" : L
"",
193 (TheNode->Info->Attribute & EFI_FILE_READ_ONLY) != 0 ? L
"r" : L
"",
194 (TheNode->Info->Attribute & EFI_FILE_SYSTEM) != 0 ? L
"s" : L
"",
195 TheNode->Info->CreateTime.Hour,
196 TheNode->Info->CreateTime.Minute,
197 TheNode->Info->CreateTime.Second,
198 TheNode->Info->CreateTime.Day,
199 TheNode->Info->CreateTime.Month,
200 TheNode->Info->CreateTime.Year,
201 TheNode->Info->LastAccessTime.Hour,
202 TheNode->Info->LastAccessTime.Minute,
203 TheNode->Info->LastAccessTime.Second,
204 TheNode->Info->LastAccessTime.Day,
205 TheNode->Info->LastAccessTime.Month,
206 TheNode->Info->LastAccessTime.Year,
207 TheNode->Info->ModificationTime.Hour,
208 TheNode->Info->ModificationTime.Minute,
209 TheNode->Info->ModificationTime.Second,
210 TheNode->Info->ModificationTime.Day,
211 TheNode->Info->ModificationTime.Month,
212 TheNode->Info->ModificationTime.Year
224 gShellLevel2HiiHandle,
225 &TheNode->Info->ModificationTime,
226 (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) != 0 ? L
"<DIR>" : L
"",
227 (TheNode->Info->Attribute & EFI_FILE_READ_ONLY) != 0 ? L
'r' : L
' ',
228 TheNode->Info->FileSize
230 if (TheNode->Info->Attribute & EFI_FILE_DIRECTORY) {
237 gShellLevel2HiiHandle,
242 (*Size) += TheNode->Info->FileSize;
243 if ( (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)L
".nsh", (CHAR16 *)&(TheNode->FileName[
StrLen (TheNode->FileName) - 4])) == 0)
244 || (gUnicodeCollation->StriColl (gUnicodeCollation, (CHAR16 *)L
".efi", (CHAR16 *)&(TheNode->FileName[
StrLen (TheNode->FileName) - 4])) == 0)
252 gShellLevel2HiiHandle,
261 gShellLevel2HiiHandle,
279 CHAR16 *DirectoryName;
286 if (DirectoryName !=
NULL) {
295 gShellLevel2HiiHandle,
299 SHELL_FREE_NON_NULL (DirectoryName);
325 gShellLevel2HiiHandle,
341 IN INT16 LocalTimeZone
346 INTN HourNumberOfTempMinute;
348 INTN DayNumberOfTempHour;
350 INTN MonthNumberOfTempDay;
352 INTN YearNumberOfTempMonth;
355 ASSERT ((Time->TimeZone >= -1440) && (Time->TimeZone <= 1440));
356 ASSERT ((LocalTimeZone >= -1440) && (LocalTimeZone <= 1440));
357 ASSERT ((Time->Month >= 1) && (Time->Month <= 12));
359 if (Time->TimeZone == LocalTimeZone) {
366 if (((Time->Year % 4 == 0) && (Time->Year / 100 != 0)) || (Time->Year % 400 == 0)) {
373 MinuteDiff = Time->TimeZone - LocalTimeZone;
374 TempMinute = Time->Minute + MinuteDiff;
380 HourNumberOfTempMinute = TempMinute / 60;
381 if (TempMinute < 0) {
382 HourNumberOfTempMinute--;
385 TempHour = Time->Hour + HourNumberOfTempMinute;
386 Time->Minute = (UINT8)(TempMinute - 60 * HourNumberOfTempMinute);
392 DayNumberOfTempHour = TempHour / 24;
394 DayNumberOfTempHour--;
397 TempDay = Time->Day + DayNumberOfTempHour;
398 Time->Hour = (UINT8)(TempHour - 24 * DayNumberOfTempHour);
404 MonthNumberOfTempDay = (TempDay - 1) / (
INTN)mDayOfMonth[Time->Month - 1];
405 MonthRecord = (
INTN)(Time->Month);
406 if (TempDay - 1 < 0) {
407 MonthNumberOfTempDay--;
411 TempMonth = Time->Month + MonthNumberOfTempDay;
412 Time->Day = (UINT8)(TempDay - (
INTN)mDayOfMonth[(MonthRecord - 1 + 12) % 12] * MonthNumberOfTempDay);
417 YearNumberOfTempMonth = (TempMonth - 1) / 12;
418 if (TempMonth - 1 < 0) {
419 YearNumberOfTempMonth--;
422 Time->Month = (UINT8)(TempMonth - 12 * (YearNumberOfTempMonth));
423 Time->Year = (UINT16)(Time->Year + YearNumberOfTempMonth);
454 IN CONST BOOLEAN ListUnfiltered
465 CHAR16 *CorrectedPath;
467 BOOLEAN HeaderPrinted;
470 HeaderPrinted =
FALSE;
477 CorrectedPath =
NULL;
485 CorrectedPath =
StrnCatGrow (&CorrectedPath, &LongestPath, RootPath, 0);
486 if (CorrectedPath ==
NULL) {
490 if ( (CorrectedPath[
StrLen (CorrectedPath)-1] != L
'\\')
491 && (CorrectedPath[
StrLen (CorrectedPath)-1] != L
'/'))
493 CorrectedPath =
StrnCatGrow (&CorrectedPath, &LongestPath, L
"\\", 0);
496 CorrectedPath =
StrnCatGrow (&CorrectedPath, &LongestPath, SearchString, 0);
497 if (CorrectedPath ==
NULL) {
504 if (!EFI_ERROR (Status)) {
506 SHELL_FREE_NON_NULL (CorrectedPath);
510 if (Sfo && (Found ==
NULL)) {
524 ShellSortFileListByFileName
538 ASSERT (Node !=
NULL);
543 Status =
gRT->GetTime (&LocalTime,
NULL);
583 }
else if ((Attribs != EFI_FILE_VALID_ATTR) ||
598 if (!Sfo && !HeaderPrinted) {
605 HeaderPrinted =
TRUE;
608 if (!Sfo && (ShellStatus !=
SHELL_ABORTED) && HeaderPrinted) {
618 CorrectedPath[0] = CHAR_NULL;
619 CorrectedPath =
StrnCatGrow (&CorrectedPath, &LongestPath, RootPath, 0);
620 if (CorrectedPath ==
NULL) {
624 if ( (CorrectedPath[
StrLen (CorrectedPath)-1] != L
'\\')
625 && (CorrectedPath[
StrLen (CorrectedPath)-1] != L
'/'))
627 CorrectedPath =
StrnCatGrow (&CorrectedPath, &LongestPath, L
"\\", 0);
630 CorrectedPath =
StrnCatGrow (&CorrectedPath, &LongestPath, L
"*", 0);
631 if (CorrectedPath ==
NULL) {
637 if (!EFI_ERROR (Status)) {
651 if ( ((Node->
Info->
Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY)
679 SHELL_FREE_NON_NULL (CorrectedPath);
682 if ((Found ==
NULL) && !FoundOne) {
683 if (ListUnfiltered) {
704 return (ShellStatus);
729 CHAR16 *ProblemParam;
730 CONST CHAR16 *Attribs;
732 UINT64 RequiredAttributes;
733 CONST CHAR16 *PathName;
734 CONST CHAR16 *CurDir;
739 CHAR16 *SearchString;
740 BOOLEAN ListUnfiltered;
747 RequiredAttributes = 0;
752 ListUnfiltered =
FALSE;
770 if (EFI_ERROR (Status)) {
771 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam !=
NULL)) {
802 RequiredAttributes |= EFI_FILE_ARCHIVE;
807 RequiredAttributes |= EFI_FILE_SYSTEM;
812 RequiredAttributes |= EFI_FILE_HIDDEN;
817 RequiredAttributes |= EFI_FILE_READ_ONLY;
822 RequiredAttributes |= EFI_FILE_DIRECTORY;
835 if (RequiredAttributes == 0) {
836 RequiredAttributes = EFI_FILE_VALID_ATTR;
842 if (PathName ==
NULL) {
846 CurDir = gEfiShellProtocol->GetCurDir (
NULL);
847 if (CurDir ==
NULL) {
852 ListUnfiltered =
TRUE;
856 ASSERT (SearchString ==
NULL);
857 ASSERT (FullPath ==
NULL);
863 if ((
StrStr (PathName, L
":") ==
NULL) && (gEfiShellProtocol->GetCurDir (
NULL) ==
NULL)) {
873 ASSERT ((FullPath ==
NULL && Size == 0) || (FullPath !=
NULL));
875 StrnCatGrow (&FullPath, &Size, gEfiShellProtocol->GetCurDir (
NULL), 0);
876 if (FullPath ==
NULL) {
886 if (FullPath ==
NULL) {
895 ListUnfiltered =
TRUE;
902 if (SearchString ==
NULL) {
914 Status =
gRT->GetTime (&TheTime,
NULL);
915 if (EFI_ERROR (Status)) {
951 SHELL_FREE_NON_NULL (SearchString);
952 SHELL_FREE_NON_NULL (FullPath);
955 return (ShellStatus);
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
CHAR16 *EFIAPI PathCleanUpDirectories(IN CHAR16 *Path)
BOOLEAN EFIAPI PathRemoveLastItem(IN OUT CHAR16 *Path)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR16 *EFIAPI StrStr(IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS PrintSfoVolumeInfoTableEntry(IN CONST EFI_SHELL_FILE_INFO *TheList)
VOID FileTimeToLocalTime(IN EFI_TIME *Time, IN INT16 LocalTimeZone)
VOID PrintNonSfoHeader(IN CONST CHAR16 *Path)
VOID PrintNonSfoFooter(IN UINT64 Files, IN UINT64 Size, IN UINT64 Dirs)
SHELL_STATUS PrintLsOutput(IN CONST BOOLEAN Rec, IN CONST UINT64 Attribs, IN CONST BOOLEAN Sfo, IN CONST CHAR16 *RootPath, IN CONST CHAR16 *SearchString, IN BOOLEAN *Found, IN CONST UINTN Count, IN CONST INT16 TimeZone, IN CONST BOOLEAN ListUnfiltered)
VOID PrintFileInformation(IN CONST BOOLEAN Sfo, IN CONST EFI_SHELL_FILE_INFO *TheNode, IN UINT64 *Files, IN UINT64 *Size, IN UINT64 *Dirs)
SHELL_STATUS EFIAPI ShellCommandRunLs(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_RUNTIME_SERVICES * gRT
#define ASSERT_EFI_ERROR(StatusParameter)
@ SHELL_INVALID_PARAMETER
EFI_STATUS EFIAPI CommandInit(VOID)
EFI_FILE_PROTOCOL *EFIAPI ConvertShellHandleToEfiFileProtocol(IN CONST SHELL_FILE_HANDLE Handle)
EFI_STATUS EFIAPI ShellSortFileList(IN OUT EFI_SHELL_FILE_INFO **FileList, OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL, IN SHELL_SORT_FILE_LIST Order)
CONST CHAR16 *EFIAPI ShellCommandLineGetValue(IN CONST LIST_ENTRY *CheckPackage, IN CHAR16 *KeyString)
BOOLEAN EFIAPI ShellGetExecutionBreakFlag(VOID)
EFI_STATUS EFIAPI ShellCloseFileMetaArg(IN OUT EFI_SHELL_FILE_INFO **ListHead)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeStart
A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc....
@ TypeFlag
A flag that is present or not present only (IE "-a").
CHAR16 *EFIAPI StrnCatGrow(IN OUT CHAR16 **Destination, IN OUT UINTN *CurrentSize, IN CONST CHAR16 *Source, IN UINTN Count)
EFI_STATUS EFIAPI ShellOpenFileMetaArg(IN CHAR16 *Arg, IN UINT64 OpenMode, IN OUT EFI_SHELL_FILE_INFO **ListHead)
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
EFI_STATUS EFIAPI ShellIsDirectory(IN CONST CHAR16 *DirName)
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
CHAR16 * GetFullyQualifiedPath(IN CONST CHAR16 *Path)
#define EFI_UNSPECIFIED_TIMEZONE
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
EFI_TIME ModificationTime
LIST_ENTRY Link
Linked list members.
SHELL_FILE_HANDLE Handle
Handle for interacting with the opened file or NULL if closed.
EFI_FILE_INFO * Info
Pointer to the FileInfo struct for this file or NULL.
CONST CHAR16 * FullName
Fully qualified filename.
CONST CHAR16 * FileName
name of this file.
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut