EFI_FILE_PROTOCOL wrappers for other items (Like Environment Variables,\r
StdIn, StdOut, StdErr, etc...).\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ (C) Copyright 2013 Hewlett-Packard Development Company, L.P.<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
File style interface for console (GetInfo).\r
\r
- @param[in] This Ignored.\r
- @param[in] InformationType Ignored.\r
- @param[in,out] BufferSize Ignored.\r
- @param[out] Buffer Ignored.\r
+ @param[in] This Ignored.\r
+ @param[in] InformationType Ignored.\r
+ @param[in, out] BufferSize Ignored.\r
+ @param[out] Buffer Ignored.\r
\r
@retval EFI_UNSUPPORTED\r
**/\r
\r
Writes data to the screen.\r
\r
- @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
- @param[in,out] BufferSize Size in bytes of Buffer.\r
- @param[in] Buffer The pointer to the buffer to write.\r
+ @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
+ @param[in, out] BufferSize Size in bytes of Buffer.\r
+ @param[in] Buffer The pointer to the buffer to write.\r
\r
@retval EFI_UNSUPPORTED No output console is supported.\r
@return A return value from gST->ConOut->OutputString.\r
/**\r
File style interface for StdIn (Write).\r
\r
- @param[in] This Ignored.\r
- @param[in] BufferSize Ignored.\r
- @param[in] Buffer Ignored.\r
+ @param[in] This Ignored.\r
+ @param[in, out] BufferSize Ignored.\r
+ @param[in] Buffer Ignored.\r
\r
@retval EFI_UNSUPPORTED\r
**/\r
EFI_STATUS\r
EFIAPI\r
FileInterfaceStdInWrite(\r
- IN EFI_FILE_PROTOCOL *This,\r
- IN OUT UINTN *BufferSize,\r
- IN VOID *Buffer\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ IN OUT UINTN *BufferSize,\r
+ IN VOID *Buffer\r
)\r
{\r
return (EFI_UNSUPPORTED);\r
\r
Writes error to the error output.\r
\r
- @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
- @param[in,out] BufferSize Size in bytes of Buffer.\r
- @param[in] Buffer The pointer to the buffer to write.\r
+ @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
+ @param[in, out] BufferSize Size in bytes of Buffer.\r
+ @param[in] Buffer The pointer to the buffer to write.\r
\r
@return A return value from gST->StdErr->OutputString.\r
**/\r
/**\r
File style interface for console StdOut (Read).\r
\r
- @param[in] This Ignored.\r
- @param[in,out] BufferSize Ignored.\r
- @param[out] Buffer Ignored.\r
+ @param[in] This Ignored.\r
+ @param[in, out] BufferSize Ignored.\r
+ @param[out] Buffer Ignored.\r
\r
@retval EFI_UNSUPPORTED\r
**/\r
/**\r
File style interface for console StdErr (Read).\r
\r
- @param[in] This Ignored.\r
- @param[in,out] BufferSize Ignored.\r
- @param[out] Buffer Ignored.\r
+ @param[in] This Ignored.\r
+ @param[in, out] BufferSize Ignored.\r
+ @param[out] Buffer Ignored.\r
\r
- @retval EFI_UNSUPPORTED\r
+ @retval EFI_UNSUPPORTED Always.\r
**/\r
EFI_STATUS\r
EFIAPI\r
/**\r
File style interface for NUL file (Read).\r
\r
- @param[in] This Ignored.\r
- @param[in,out] BufferSize Ignored.\r
- @param[in] Buffer Ignored.\r
+ @param[in] This Ignored.\r
+ @param[in, out] BufferSize Poiner to 0 upon return.\r
+ @param[out] Buffer Ignored.\r
\r
- @retval EFI_SUCCESS\r
+ @retval EFI_SUCCESS Always.\r
**/\r
EFI_STATUS\r
EFIAPI\r
FileInterfaceNulRead(\r
- IN EFI_FILE_PROTOCOL *This,\r
- IN OUT UINTN *BufferSize,\r
- OUT VOID *Buffer\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT VOID *Buffer\r
)\r
{\r
+ *BufferSize = 0;\r
return (EFI_SUCCESS);\r
}\r
\r
/**\r
File style interface for NUL file (Write).\r
\r
- @param[in] This Ignored.\r
- @param[in,out] BufferSize Ignored.\r
- @param[in] Buffer Ignored.\r
+ @param[in] This Ignored.\r
+ @param[in, out] BufferSize Ignored.\r
+ @param[in] Buffer Ignored.\r
\r
@retval EFI_SUCCESS\r
**/\r
gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
if (EFI_ERROR (Status)) {\r
- continue;\r
+ break;\r
}\r
\r
//\r
if (StrStr(CurrentString + TabPos, L":") == NULL) {\r
Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir(NULL);\r
if (Cwd != NULL) {\r
- StrCpy(TabStr, Cwd);\r
+ StrnCpy(TabStr, Cwd, (*BufferSize)/sizeof(CHAR16) - 1);\r
if (TabStr[StrLen(TabStr)-1] == L'\\' && *(CurrentString + TabPos) == L'\\' ) {\r
TabStr[StrLen(TabStr)-1] = CHAR_NULL;\r
}\r
StrnCat(TabStr, CurrentString + TabPos, (StringLen - TabPos) * sizeof (CHAR16));\r
} else {\r
- StrCpy(TabStr, L"");\r
+ *TabStr = CHAR_NULL;\r
StrnCat(TabStr, CurrentString + TabPos, (StringLen - TabPos) * sizeof (CHAR16));\r
}\r
} else {\r
- StrCpy(TabStr, CurrentString + TabPos);\r
+ StrnCpy(TabStr, CurrentString + TabPos, (*BufferSize)/sizeof(CHAR16) - 1);\r
}\r
- StrCat(TabStr, L"*");\r
+ StrnCat(TabStr, L"*", (*BufferSize)/sizeof(CHAR16) - 1 - StrLen(TabStr));\r
FoundFileList = NULL;\r
-// TabStr = CleanPath(TabStr);\r
Status = ShellInfoObject.NewEfiShellProtocol->FindFiles(TabStr, &FoundFileList);\r
for ( TempStr = CurrentString\r
; *TempStr == L' '\r
//\r
ASSERT(FoundFileList == NULL);\r
\r
- return EFI_SUCCESS;\r
+ return Status;\r
}\r
\r
//\r
IN EFI_FILE_PROTOCOL *This\r
)\r
{\r
+ VOID* NewBuffer;\r
+ UINTN NewSize;\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Most if not all UEFI commands will have an '\r\n' at the end of any output. \r
+ // Since the output was redirected to a variable, it does not make sense to \r
+ // keep this. So, before closing, strip the trailing '\r\n' from the variable\r
+ // if it exists.\r
+ //\r
+ NewBuffer = NULL;\r
+ NewSize = 0;\r
+\r
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);\r
+ if (Status == EFI_BUFFER_TOO_SMALL) {\r
+ NewBuffer = AllocateZeroPool(NewSize + sizeof(CHAR16));\r
+ if (NewBuffer == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ } \r
+ Status = SHELL_GET_ENVIRONMENT_VARIABLE(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, &NewSize, NewBuffer);\r
+ }\r
+ \r
+ if (!EFI_ERROR(Status) && NewBuffer != NULL) {\r
+ \r
+ if (StrSize(NewBuffer) > 6)\r
+ {\r
+ if ((((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 2] == CHAR_LINEFEED) \r
+ && (((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 3] == CHAR_CARRIAGE_RETURN)) {\r
+ ((CHAR16*)NewBuffer)[(StrSize(NewBuffer)/2) - 3] = CHAR_NULL; \r
+ }\r
+ \r
+ if (IsVolatileEnv(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name)) {\r
+ Status = SHELL_SET_ENVIRONMENT_VARIABLE_V(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, StrSize(NewBuffer), NewBuffer);\r
+ } else {\r
+ Status = SHELL_SET_ENVIRONMENT_VARIABLE_NV(((EFI_FILE_PROTOCOL_ENVIRONMENT*)This)->Name, StrSize(NewBuffer), NewBuffer);\r
+ }\r
+ }\r
+ } \r
+ \r
+ SHELL_FREE_NON_NULL(NewBuffer);\r
FreePool((EFI_FILE_PROTOCOL_ENVIRONMENT*)This);\r
- return (EFI_SUCCESS);\r
+ return (Status);\r
}\r
\r
/**\r
/**\r
File style interface for Environment Variable (Read).\r
\r
- @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
- @param[in,out] BufferSize Size in bytes of Buffer.\r
- @param[out] Buffer The pointer to the buffer to fill.\r
+ @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
+ @param[in, out] BufferSize Size in bytes of Buffer.\r
+ @param[out] Buffer The pointer to the buffer to fill.\r
\r
@retval EFI_SUCCESS The data was read.\r
**/\r
/**\r
File style interface for Volatile Environment Variable (Write).\r
\r
- @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
- @param[in,out] BufferSize Size in bytes of Buffer.\r
- @param[in] Buffer The pointer to the buffer to write.\r
+ @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
+ @param[in, out] BufferSize Size in bytes of Buffer.\r
+ @param[in] Buffer The pointer to the buffer to write.\r
\r
@retval EFI_SUCCESS The data was read.\r
**/\r
/**\r
File style interface for Non Volatile Environment Variable (Write).\r
\r
- @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
- @param[in,out] BufferSize Size in bytes of Buffer.\r
- @param[in] Buffer The pointer to the buffer to write.\r
+ @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
+ @param[in, out] BufferSize Size in bytes of Buffer.\r
+ @param[in] Buffer The pointer to the buffer to write.\r
\r
@retval EFI_SUCCESS The data was read.\r
**/\r
)\r
{\r
EFI_FILE_PROTOCOL_ENVIRONMENT *EnvFileInterface;\r
+ UINTN EnvNameSize;\r
\r
if (EnvName == NULL) {\r
return (NULL);\r
//\r
// Get some memory\r
//\r
- EnvFileInterface = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_ENVIRONMENT)+StrSize(EnvName));\r
+ EnvNameSize = StrSize(EnvName);\r
+ EnvFileInterface = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_ENVIRONMENT)+EnvNameSize);\r
if (EnvFileInterface == NULL){\r
return (NULL);\r
}\r
EnvFileInterface->Flush = FileInterfaceNopGeneric;\r
EnvFileInterface->Delete = FileInterfaceEnvDelete;\r
EnvFileInterface->Read = FileInterfaceEnvRead;\r
-\r
- StrCpy(EnvFileInterface->Name, EnvName);\r
+ \r
+ CopyMem(EnvFileInterface->Name, EnvName, EnvNameSize);\r
\r
//\r
// Assign the different members for Volatile and Non-Volatile variables\r
Move the cursor position one character backward.\r
\r
@param[in] LineLength Length of a line. Get it by calling QueryMode\r
- @param[in,out] Column Current column of the cursor position\r
- @param[in,out] Row Current row of the cursor position\r
+ @param[in, out] Column Current column of the cursor position\r
+ @param[in, out] Row Current row of the cursor position\r
**/\r
VOID\r
EFIAPI\r
\r
@param[in] LineLength Length of a line.\r
@param[in] TotalRow Total row of a screen\r
- @param[in,out] Column Current column of the cursor position\r
- @param[in,out] Row Current row of the cursor position\r
+ @param[in, out] Column Current column of the cursor position\r
+ @param[in, out] Row Current row of the cursor position\r
**/\r
VOID\r
EFIAPI\r
/**\r
File style interface for Mem (Write).\r
\r
- @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
- @param[in,out] BufferSize Size in bytes of Buffer.\r
- @param[in] Buffer The pointer to the buffer to write.\r
+ @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
+ @param[in, out] BufferSize Size in bytes of Buffer.\r
+ @param[in] Buffer The pointer to the buffer to write.\r
\r
- @retval EFI_SUCCESS The data was written.\r
+ @retval EFI_OUT_OF_RESOURCES The operation failed due to lack of resources.\r
+ @retval EFI_SUCCESS The data was written.\r
**/\r
EFI_STATUS\r
EFIAPI\r
//\r
// Ascii\r
//\r
- AsciiBuffer = AllocatePool(*BufferSize);\r
+ AsciiBuffer = AllocateZeroPool(*BufferSize);\r
+ if (AsciiBuffer == NULL) {\r
+ return (EFI_OUT_OF_RESOURCES);\r
+ }\r
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);\r
if ((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->Position + AsciiStrSize(AsciiBuffer)) > (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize)) {\r
((EFI_FILE_PROTOCOL_MEM*)This)->Buffer = ReallocatePool((UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize), (UINTN)(((EFI_FILE_PROTOCOL_MEM*)This)->BufferSize) + AsciiStrSize(AsciiBuffer) + 10, ((EFI_FILE_PROTOCOL_MEM*)This)->Buffer);\r
/**\r
File style interface for Mem (Read).\r
\r
- @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
- @param[in,out] BufferSize Size in bytes of Buffer.\r
- @param[in] Buffer The pointer to the buffer to fill.\r
+ @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
+ @param[in, out] BufferSize Size in bytes of Buffer.\r
+ @param[in] Buffer The pointer to the buffer to fill.\r
\r
@retval EFI_SUCCESS The data was read.\r
**/\r
)\r
{\r
SHELL_FREE_NON_NULL(((EFI_FILE_PROTOCOL_MEM*)This)->Buffer);\r
- SHELL_FREE_NON_NULL((EFI_FILE_PROTOCOL_MEM*)This);\r
+ SHELL_FREE_NON_NULL(This);\r
return (EFI_SUCCESS);\r
}\r
\r
EFI_FILE_PROTOCOL *Orig;\r
} EFI_FILE_PROTOCOL_FILE;\r
\r
+/**\r
+ Set a files current position\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Position Byte position from the start of the file.\r
+ \r
+ @retval EFI_SUCCESS Data was written.\r
+ @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileInterfaceFileSetPosition(\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ IN UINT64 Position\r
+ )\r
+{\r
+ return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->SetPosition(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, Position);\r
+}\r
+\r
+/**\r
+ Get a file's current position\r
+\r
+ @param This Protocol instance pointer.\r
+ @param Position Byte position from the start of the file.\r
+ \r
+ @retval EFI_SUCCESS Data was written.\r
+ @retval EFI_UNSUPPORTED Seek request for non-zero is not valid on open..\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileInterfaceFileGetPosition(\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ OUT UINT64 *Position\r
+ )\r
+{\r
+ return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->GetPosition(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, Position);\r
+}\r
+\r
+/**\r
+ Get information about a file.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param InformationType Type of information to return in Buffer.\r
+ @param BufferSize On input size of buffer, on output amount of data in buffer.\r
+ @param Buffer The buffer to return data.\r
+\r
+ @retval EFI_SUCCESS Data was returned.\r
+ @retval EFI_UNSUPPORT InformationType is not supported.\r
+ @retval EFI_NO_MEDIA The device has no media.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_WRITE_PROTECTED The device is write protected.\r
+ @retval EFI_ACCESS_DENIED The file was open for read only.\r
+ @retval EFI_BUFFER_TOO_SMALL Buffer was too small; required size returned in BufferSize.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileInterfaceFileGetInfo(\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ IN EFI_GUID *InformationType,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT VOID *Buffer\r
+ )\r
+{\r
+ return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->GetInfo(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, InformationType, BufferSize, Buffer);\r
+}\r
+\r
+/**\r
+ Set information about a file\r
+\r
+ @param This Protocol instance pointer.\r
+ @param InformationType Type of information in Buffer.\r
+ @param BufferSize Size of buffer.\r
+ @param Buffer The data to write.\r
+\r
+ @retval EFI_SUCCESS Data was returned.\r
+ @retval EFI_UNSUPPORT InformationType is not supported.\r
+ @retval EFI_NO_MEDIA The device has no media.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_WRITE_PROTECTED The device is write protected.\r
+ @retval EFI_ACCESS_DENIED The file was open for read only.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileInterfaceFileSetInfo(\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ IN EFI_GUID *InformationType,\r
+ IN UINTN BufferSize,\r
+ IN VOID *Buffer\r
+ )\r
+{\r
+ return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->SetInfo(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, InformationType, BufferSize, Buffer);\r
+}\r
+\r
+/**\r
+ Flush data back for the file handle.\r
+\r
+ @param This Protocol instance pointer.\r
+\r
+ @retval EFI_SUCCESS Data was written.\r
+ @retval EFI_UNSUPPORT Writes to Open directory are not supported.\r
+ @retval EFI_NO_MEDIA The device has no media.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_WRITE_PROTECTED The device is write protected.\r
+ @retval EFI_ACCESS_DENIED The file was open for read only.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileInterfaceFileFlush(\r
+ IN EFI_FILE_PROTOCOL *This\r
+ )\r
+{\r
+ return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Flush(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);\r
+}\r
+\r
+/**\r
+ Read data from the file.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param BufferSize On input size of buffer, on output amount of data in buffer.\r
+ @param Buffer The buffer in which data is read.\r
+\r
+ @retval EFI_SUCCESS Data was read.\r
+ @retval EFI_NO_MEDIA The device has no media.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_BUFFER_TO_SMALL BufferSize is too small. BufferSize contains required size.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileInterfaceFileRead(\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ IN OUT UINTN *BufferSize,\r
+ OUT VOID *Buffer\r
+ )\r
+{\r
+ CHAR8 *AsciiBuffer;\r
+ UINTN Size;\r
+ EFI_STATUS Status;\r
+ if (((EFI_FILE_PROTOCOL_FILE*)This)->Unicode) {\r
+ //\r
+ // Unicode\r
+ //\r
+ return (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Read(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, BufferSize, Buffer));\r
+ } else {\r
+ //\r
+ // Ascii\r
+ //\r
+ AsciiBuffer = AllocateZeroPool((Size = *BufferSize));\r
+ Status = (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Read(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, &Size, AsciiBuffer));\r
+ UnicodeSPrint(Buffer, *BufferSize, L"%a", AsciiBuffer);\r
+ FreePool(AsciiBuffer);\r
+ return (Status);\r
+ }\r
+}\r
+\r
+/**\r
+ Opens a new file relative to the source file's location.\r
+\r
+ @param[in] This The protocol instance pointer.\r
+ @param[out] NewHandle Returns File Handle for FileName.\r
+ @param[in] FileName Null terminated string. "\", ".", and ".." are supported.\r
+ @param[in] OpenMode Open mode for file.\r
+ @param[in] Attributes Only used for EFI_FILE_MODE_CREATE.\r
+\r
+ @retval EFI_SUCCESS The device was opened.\r
+ @retval EFI_NOT_FOUND The specified file could not be found on the device.\r
+ @retval EFI_NO_MEDIA The device has no media.\r
+ @retval EFI_MEDIA_CHANGED The media has changed.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_ACCESS_DENIED The service denied access to the file.\r
+ @retval EFI_OUT_OF_RESOURCES The volume was not opened due to lack of resources.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileInterfaceFileOpen (\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ OUT EFI_FILE_PROTOCOL **NewHandle,\r
+ IN CHAR16 *FileName,\r
+ IN UINT64 OpenMode,\r
+ IN UINT64 Attributes\r
+ )\r
+{\r
+ return ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Open(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, NewHandle, FileName, OpenMode, Attributes);\r
+}\r
+\r
+/**\r
+ Close and delete the file handle.\r
+\r
+ @param This Protocol instance pointer.\r
+ \r
+ @retval EFI_SUCCESS The device was opened.\r
+ @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileInterfaceFileDelete(\r
+ IN EFI_FILE_PROTOCOL *This\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ Status = ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Delete(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);\r
+ FreePool(This);\r
+ return (Status);\r
+}\r
+\r
/**\r
File style interface for File (Close).\r
\r
IN EFI_FILE_PROTOCOL *This\r
)\r
{\r
- ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Close(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);\r
+ EFI_STATUS Status;\r
+ Status = ((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Close(((EFI_FILE_PROTOCOL_FILE*)This)->Orig);\r
FreePool(This);\r
- return (EFI_SUCCESS);\r
+ return (Status);\r
}\r
\r
/**\r
If the file was opened with ASCII mode the data will be processed through \r
AsciiSPrint before writing.\r
\r
- @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
- @param[in] BufferSize Size in bytes of Buffer.\r
- @param[in] Buffer The pointer to the buffer to write.\r
+ @param[in] This The pointer to the EFI_FILE_PROTOCOL object.\r
+ @param[in, out] BufferSize Size in bytes of Buffer.\r
+ @param[in] Buffer The pointer to the buffer to write.\r
\r
@retval EFI_SUCCESS The data was written.\r
**/\r
EFI_STATUS\r
EFIAPI\r
FileInterfaceFileWrite(\r
- IN EFI_FILE_PROTOCOL *This,\r
- IN OUT UINTN *BufferSize,\r
- IN VOID *Buffer\r
+ IN EFI_FILE_PROTOCOL *This,\r
+ IN OUT UINTN *BufferSize,\r
+ IN VOID *Buffer\r
)\r
{\r
CHAR8 *AsciiBuffer;\r
//\r
// Ascii\r
//\r
- AsciiBuffer = AllocatePool(*BufferSize);\r
+ AsciiBuffer = AllocateZeroPool(*BufferSize);\r
AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer);\r
Size = AsciiStrSize(AsciiBuffer) - 1; // (we dont need the null terminator)\r
Status = (((EFI_FILE_PROTOCOL_FILE*)This)->Orig->Write(((EFI_FILE_PROTOCOL_FILE*)This)->Orig, &Size, AsciiBuffer));\r
{\r
EFI_FILE_PROTOCOL_FILE *NewOne;\r
\r
- NewOne = AllocatePool(sizeof(EFI_FILE_PROTOCOL_FILE));\r
+ NewOne = AllocateZeroPool(sizeof(EFI_FILE_PROTOCOL_FILE));\r
+ if (NewOne == NULL) {\r
+ return (NULL);\r
+ }\r
CopyMem(NewOne, Template, sizeof(EFI_FILE_PROTOCOL_FILE));\r
- NewOne->Orig = (EFI_FILE_PROTOCOL *)Template;\r
- NewOne->Unicode = Unicode;\r
- NewOne->Close = FileInterfaceFileClose;\r
- NewOne->Write = FileInterfaceFileWrite;\r
+ NewOne->Orig = (EFI_FILE_PROTOCOL *)Template;\r
+ NewOne->Unicode = Unicode;\r
+ NewOne->Open = FileInterfaceFileOpen;\r
+ NewOne->Close = FileInterfaceFileClose;\r
+ NewOne->Delete = FileInterfaceFileDelete;\r
+ NewOne->Read = FileInterfaceFileRead;\r
+ NewOne->Write = FileInterfaceFileWrite;\r
+ NewOne->GetPosition = FileInterfaceFileGetPosition;\r
+ NewOne->SetPosition = FileInterfaceFileSetPosition;\r
+ NewOne->GetInfo = FileInterfaceFileGetInfo;\r
+ NewOne->SetInfo = FileInterfaceFileSetInfo;\r
+ NewOne->Flush = FileInterfaceFileFlush;\r
\r
return ((EFI_FILE_PROTOCOL *)NewOne);\r
}\r