Member functions of EFI_SHELL_PROTOCOL and functions for creation,\r
manipulation, and initialization of EFI_SHELL_PROTOCOL.\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
**/\r
\r
#include "Shell.h"\r
-#include <Library/FileHandleLib.h>\r
\r
/**\r
Close an open file handle.\r
This function converts a file system style name to a device path, by replacing any\r
mapping references to the associated device path.\r
\r
- @param Path the pointer to the path\r
+ @param[in] Path The pointer to the path.\r
\r
- @return all The pointer of the file path. The file path is callee\r
+ @return The pointer of the file path. The file path is callee\r
allocated and should be freed by the caller.\r
+ @retval NULL The path could not be found.\r
+ @retval NULL There was not enough available memory.\r
**/\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
Size = StrSize(Cwd);\r
Size += StrSize(Path);\r
NewPath = AllocateZeroPool(Size);\r
- ASSERT(NewPath != NULL);\r
+ if (NewPath == NULL) {\r
+ return (NULL);\r
+ }\r
StrCpy(NewPath, Cwd);\r
if (*Path == L'\\') {\r
Path++;\r
//\r
ASSERT((MapName == NULL && Size == 0) || (MapName != NULL));\r
MapName = StrnCatGrow(&MapName, &Size, Path, (StrStr(Path, L":")-Path+1));\r
- if (MapName[StrLen(MapName)-1] != L':') {\r
- ASSERT(FALSE);\r
+ if (MapName == NULL || MapName[StrLen(MapName)-1] != L':') {\r
return (NULL);\r
}\r
\r
//\r
DevicePathCopyForFree = DevicePathCopy = DuplicateDevicePath(DevicePath);\r
if (DevicePathCopy == NULL) {\r
- ASSERT(FALSE);\r
FreePool(MapName);\r
return (NULL);\r
}\r
if (*(Path+StrLen(MapName)+1) == CHAR_NULL) {\r
DevicePathForReturn = FileDevicePath(Handle, L"\\");\r
} else {\r
- DevicePathForReturn = FileDevicePath(Handle, Path+StrLen(MapName)+1);\r
+ DevicePathForReturn = FileDevicePath(Handle, Path+StrLen(MapName));\r
}\r
\r
FreePool(MapName);\r
SHELL_FILE_HANDLE ShellHandle;\r
EFI_FILE_PROTOCOL *Handle1;\r
EFI_FILE_PROTOCOL *Handle2;\r
- EFI_DEVICE_PATH_PROTOCOL *DpCopy;\r
FILEPATH_DEVICE_PATH *AlignedNode;\r
\r
if (FileHandle == NULL) {\r
Handle1 = NULL;\r
Handle2 = NULL;\r
Handle = NULL;\r
- DpCopy = DevicePath;\r
ShellHandle = NULL;\r
FilePathNode = NULL;\r
AlignedNode = NULL;\r
if (ShellFileListItem == NULL) {\r
return (NULL);\r
}\r
- if (Info != NULL) {\r
+ if (Info != NULL && Info->Size != 0) {\r
ShellFileListItem->Info = AllocateZeroPool((UINTN)Info->Size);\r
if (ShellFileListItem->Info == NULL) {\r
FreePool(ShellFileListItem);\r
TempString = NULL;\r
Size = 0;\r
TempString = StrnCatGrow(&TempString, &Size, ShellFileHandleGetPath(FileDirHandle), 0);\r
+ if (TempString == NULL) {\r
+ return (EFI_OUT_OF_RESOURCES);\r
+ }\r
TempSpot = StrStr(TempString, L";");\r
\r
if (TempSpot != NULL) {\r
}\r
\r
TempString = StrnCatGrow(&TempString, &Size, BasePath, 0);\r
+ if (TempString == NULL) {\r
+ return (EFI_OUT_OF_RESOURCES);\r
+ }\r
BasePath = TempString;\r
}\r
\r
\r
ASSERT(MapName == NULL);\r
MapName = StrnCatGrow(&MapName, NULL, PatternCopy, Count);\r
-\r
- if (!EFI_ERROR(Status)) {\r
+ if (MapName == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ } else {\r
RootDevicePath = EfiShellGetDevicePathFromFilePath(PatternCopy);\r
if (RootDevicePath == NULL) {\r
Status = EFI_INVALID_PARAMETER;\r
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);\r
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);\r
- if (MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {\r
+ if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {\r
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);\r
}\r
UINTN NameSize;\r
CHAR16 *RetVal;\r
UINTN RetSize;\r
- CHAR16 *Alias;\r
\r
Status = gRT->QueryVariableInfo(EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, &MaxStorSize, &RemStorSize, &MaxVarSize);\r
ASSERT_EFI_ERROR(Status);\r
break;\r
}\r
if (CompareGuid(&Guid, &gShellAliasGuid)){\r
- Alias = GetVariable(VariableName, &gShellAliasGuid);\r
ASSERT((RetVal == NULL && RetSize == 0) || (RetVal != NULL));\r
RetVal = StrnCatGrow(&RetVal, &RetSize, VariableName, 0);\r
RetVal = StrnCatGrow(&RetVal, &RetSize, L";", 0);\r
IN EFI_KEY_DATA *KeyData\r
)\r
{\r
-// ShellPrintEx(-1,-1,L" <Notify> ");\r
- if ((KeyData->Key.UnicodeChar == L'c' || KeyData->Key.UnicodeChar == 3) &&\r
- (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))\r
+ EFI_INPUT_KEY Key;\r
+ if ( ((KeyData->Key.UnicodeChar == L'c') &&\r
+ (KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))) ||\r
+ (KeyData->Key.UnicodeChar == 3)\r
){ \r
if (ShellInfoObject.NewEfiShellProtocol->ExecutionBreak == NULL) {\r
return (EFI_UNSUPPORTED);\r
(KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_LEFT_CONTROL_PRESSED) || KeyData->KeyState.KeyShiftState == (EFI_SHIFT_STATE_VALID|EFI_RIGHT_CONTROL_PRESSED))\r
){ \r
ShellInfoObject.HaltOutput = TRUE;\r
+\r
+ //\r
+ // Make sure that there are no pending keystrokes to pervent the pause.\r
+ //\r
+ gST->ConIn->Reset(gST->ConIn, FALSE);\r
+ while (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key)==EFI_SUCCESS);\r
}\r
return (EFI_SUCCESS);\r
}\r