Ls.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Main file for ls shell level 2 function.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UefiShellLevel2CommandsLib.h"
#include <Guid/FileSystemInfo.h>
/**
print out the list of files and directories from the LS command
@param[in] Rec TRUE to automatically recurse into each found directory
FALSE to only list the specified directory.
@param[in] Attribs List of required Attribute for display.
If 0 then all non-system and non-hidden files will be printed.
@param[in] Sfo TRUE to use Standard Format Output, FALSE otherwise
@param[in] Path String with starting path.
@param[in] First TRUE for the original and FALSE for any recursion spawned instances.
@param[in] Count The count of bits enabled in Attribs.
@param[in] TimeZone The current time zone offset.
@retval SHELL_SUCCESS the printing was sucessful.
**/
)
{
FileCount = 0;
DirCount = 0;
FileSize = 0;
LongestPath = 0;
return (SHELL_DEVICE_ERROR);
}
//
// On the first one only we expect to find something...
// do we find the . and .. directories otherwise?
//
if (First) {
return (SHELL_NOT_FOUND);
}
return (SHELL_SUCCESS);
}
//
// Get the first valid handle (directories)
//
);
DirectoryName = GetFullyQualifiedPath(((EFI_SHELL_FILE_INFO *)GetFirstNode(&ListHead->Link))->FullName);
//
// We need to open something up to get system information
//
//
// Get the Volume Info from ShellFileHandle
//
SysInfoSize = 0;
SysInfo);
if (Status == EFI_BUFFER_TOO_SMALL) {
SysInfo);
}
} else {
//
// Get the Volume Info from Node->Handle
//
SysInfoSize = 0;
SysInfo);
if (Status == EFI_BUFFER_TOO_SMALL) {
SysInfo);
}
}
-1,
-1,
NULL,
L"ls");
//
// print VolumeInfo table
//
0,
NULL,
);
}
}
if (!Sfo) {
//
// get directory name from path...
//
//
// print header
//
0,
NULL,
);
}
){
}
if (Attribs == 0) {
//
// NOT system & NOT hidden
//
){
continue;
}
} else if (Attribs != EFI_FILE_VALID_ATTR) {
if (Count == 1) {
//
// the bit must match
//
continue;
}
} else {
//
// exact match on all bits
//
continue;
}
}
}
if (Sfo) {
//
// Print the FileInfo Table
//
0,
NULL,
);
} else {
//
// print this one out...
// first print the universal start, next print the type specific name format, last print the CRLF
//
-1,
-1,
NULL,
);
DirCount++;
-1,
-1,
NULL,
);
} else {
FileCount++;
if ( (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)L".nsh", (CHAR16*)&(Node->FileName[StrLen (Node->FileName) - 4])) == 0)
|| (gUnicodeCollation->StriColl(gUnicodeCollation, (CHAR16*)L".efi", (CHAR16*)&(Node->FileName[StrLen (Node->FileName) - 4])) == 0)
){
-1,
-1,
NULL,
);
} else {
-1,
-1,
NULL,
);
}
}
}
}
if (!Sfo) {
//
// print footer
//
-1,
-1,
NULL,
);
}
if (Rec){
if (DirectoryName == NULL) {
} else {
){
//
// recurse on any directory except the traversing ones...
//
){
Rec,
Sfo,
TimeZone);
}
}
}
}
return (ShellStatus);
}
{L"-r", TypeFlag},
{L"-a", TypeStart},
{L"-sfo", TypeFlag},
};
/**
Function for 'ls' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
)
{
Size = 0;
ProblemParam = NULL;
RequiredAttributes = 0;
Count = 0;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
//
// Fix local copies of the protocol pointers
//
Status = CommandInit();
//
// parse the command line
//
} else {
}
} else {
//
// check for "-?"
//
}
} else {
//
// check for -a
//
; Attribs++
){
switch (*Attribs) {
case L'a':
case L'A':
Count++;
continue;
case L's':
case L'S':
Count++;
continue;
case L'h':
case L'H':
Count++;
continue;
case L'r':
case L'R':
Count++;
continue;
case L'd':
case L'D':
Count++;
continue;
default:
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_ATTRIBUTE), gShellLevel2HiiHandle, ShellCommandLineGetValue(Package, L"-a"));
break;
} // switch
} // for loop
//
// if nothing is specified all are specified
//
if (RequiredAttributes == 0) {
}
} // if -a present
if (ShellStatus == SHELL_SUCCESS) {
}
}
} else {
}
}
} else {
}
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN), gShellLevel2HiiHandle, L"gRT->GetTime", Status);
}
if (ShellStatus == SHELL_SUCCESS) {
TRUE,
);
if (ShellStatus == SHELL_NOT_FOUND) {
} else if (ShellStatus == SHELL_INVALID_PARAMETER) {
} else if (ShellStatus != SHELL_SUCCESS) {
}
}
}
}
}
}
//
// free the command line package
//
return (ShellStatus);
}