26#define MAX_FILE_NAME_LEN 522
27#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)
53 if (FileHandle ==
NULL) {
62 Status = FileHandle->GetInfo (
68 if (Status == EFI_BUFFER_TOO_SMALL) {
77 Status = FileHandle->GetInfo (
86 if (EFI_ERROR (Status)) {
123 return (EFI_INVALID_PARAMETER);
129 return (FileHandle->SetInfo (
174 if (FileHandle ==
NULL) {
175 return (EFI_INVALID_PARAMETER);
181 return (FileHandle->Read (FileHandle, BufferSize, Buffer));
216 if (FileHandle ==
NULL) {
217 return (EFI_INVALID_PARAMETER);
223 return (FileHandle->Write (FileHandle, BufferSize, Buffer));
245 if (FileHandle ==
NULL) {
246 return (EFI_INVALID_PARAMETER);
252 Status = FileHandle->Close (FileHandle);
278 if (FileHandle ==
NULL) {
279 return (EFI_INVALID_PARAMETER);
285 Status = FileHandle->Delete (FileHandle);
315 if (FileHandle ==
NULL) {
316 return (EFI_INVALID_PARAMETER);
322 return (FileHandle->SetPosition (FileHandle, Position));
347 if ((Position ==
NULL) || (FileHandle ==
NULL)) {
348 return (EFI_INVALID_PARAMETER);
354 return (FileHandle->GetPosition (FileHandle, Position));
377 if (FileHandle ==
NULL) {
378 return (EFI_INVALID_PARAMETER);
384 return (FileHandle->Flush (FileHandle));
408 if (DirHandle ==
NULL) {
409 return (EFI_INVALID_PARAMETER);
420 if (DirInfo ==
NULL) {
424 return (EFI_INVALID_PARAMETER);
427 if ((DirInfo->
Attribute & EFI_FILE_DIRECTORY) == 0) {
432 return (EFI_NOT_FOUND);
474 if ((Buffer ==
NULL) || (DirHandle ==
NULL)) {
475 return (EFI_INVALID_PARAMETER);
482 if (EFI_ERROR (Status)) {
489 BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;
491 if (*Buffer ==
NULL) {
492 return (EFI_OUT_OF_RESOURCES);
499 if (EFI_ERROR (Status)) {
509 ASSERT (Status != EFI_BUFFER_TOO_SMALL);
510 if (EFI_ERROR (Status) || (BufferSize == 0)) {
513 if (BufferSize == 0) {
514 return (EFI_NOT_FOUND);
552 if ((DirHandle ==
NULL) || (Buffer ==
NULL) || (NoFile ==
NULL)) {
553 return (EFI_INVALID_PARAMETER);
559 BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;
565 ASSERT (Status != EFI_BUFFER_TOO_SMALL);
566 if (EFI_ERROR (Status)) {
573 if (BufferSize == 0) {
604 if ((FileHandle ==
NULL) || (Size ==
NULL)) {
605 return (EFI_INVALID_PARAMETER);
613 return (EFI_DEVICE_ERROR);
652 if (FileHandle ==
NULL) {
653 return (EFI_INVALID_PARAMETER);
661 return (EFI_DEVICE_ERROR);
713 IN OUT CHAR16 **Destination,
719 UINTN DestinationStartSize;
723 if (Destination ==
NULL) {
730 if (Source ==
NULL) {
731 return (*Destination);
737 if (*Destination !=
NULL) {
738 ASSERT (CurrentSize != 0);
739 DestinationStartSize =
StrSize (*Destination);
740 ASSERT (DestinationStartSize <= *CurrentSize);
742 DestinationStartSize = 0;
756 if (CurrentSize !=
NULL) {
757 NewSize = *CurrentSize;
758 while (NewSize < (DestinationStartSize + Count)) {
759 NewSize += 2 * Count;
762 *Destination =
ReallocatePool (*CurrentSize, NewSize, *Destination);
763 *CurrentSize = NewSize;
768 if (*Destination ==
NULL) {
772 CopySize =
StrSize (*Destination);
773 CopyMem ((*Destination)+((Count-2)/
sizeof (CHAR16)), *Destination, CopySize);
774 CopyMem (*Destination, Source, Count-2);
775 return (*Destination);
799 OUT CHAR16 **FullFileName
813 if ((FullFileName ==
NULL) || (Handle ==
NULL)) {
814 return (EFI_INVALID_PARAMETER);
817 *FullFileName =
NULL;
818 CurrentHandle =
NULL;
820 Status = Handle->Open (Handle, &CurrentHandle, L
".", EFI_FILE_MODE_READ, 0);
821 if (!EFI_ERROR (Status)) {
828 Status = EFI_OUT_OF_RESOURCES;
835 Status = CurrentHandle->Open (CurrentHandle, &NextHigherHandle, L
"..", EFI_FILE_MODE_READ, 0);
850 if (*FullFileName ==
NULL) {
851 ASSERT ((*FullFileName ==
NULL && Size == 0) || (*FullFileName !=
NULL));
858 if (*FullFileName ==
NULL) {
859 ASSERT ((*FullFileName ==
NULL && Size == 0) || (*FullFileName !=
NULL));
863 ASSERT ((*FullFileName ==
NULL && Size == 0) || (*FullFileName !=
NULL));
874 CurrentHandle = NextHigherHandle;
876 }
else if (Status == EFI_NOT_FOUND) {
878 ASSERT ((*FullFileName ==
NULL && Size == 0) || (*FullFileName !=
NULL));
882 if ((*FullFileName !=
NULL) &&
883 ((*FullFileName)[
StrLen (*FullFileName) - 1] == L
'\\') &&
884 (
StrLen (*FullFileName) > 1) &&
888 (*FullFileName)[
StrLen (*FullFileName) - 1] = CHAR_NULL;
891 if (CurrentHandle !=
NULL) {
892 CurrentHandle->Close (CurrentHandle);
895 if (EFI_ERROR (Status) && (*FullFileName !=
NULL)) {
920 IN OUT BOOLEAN *Ascii
931 if (Status == EFI_BUFFER_TOO_SMALL) {
934 if (RetVal ==
NULL) {
942 if (EFI_ERROR (Status) && (RetVal !=
NULL)) {
982 IN OUT CHAR16 *Buffer,
985 IN OUT BOOLEAN *Ascii
995 UINT64 OriginalFilePosition;
997 if ( (Handle ==
NULL)
999 || ((Buffer ==
NULL) && (*Size != 0))
1002 return (EFI_INVALID_PARAMETER);
1005 if ((Buffer !=
NULL) && (*Size != 0)) {
1006 *Buffer = CHAR_NULL;
1010 if (EFI_ERROR (Status)) {
1012 }
else if (FileSize == 0) {
1018 if (OriginalFilePosition == 0) {
1019 CharSize =
sizeof (CHAR16);
1031 for (CountSoFar = 0; ; CountSoFar++) {
1034 CharSize =
sizeof (CHAR8);
1036 CharSize =
sizeof (CHAR16);
1040 if ( EFI_ERROR (Status)
1042 || ((CharBuffer == L
'\n') && !(*Ascii))
1043 || ((CharBuffer ==
'\n') && *Ascii)
1048 ((CharBuffer == L
'\r') && !(*Ascii)) ||
1049 ((CharBuffer ==
'\r') && *Ascii)
1059 if ((CountSoFar+1-CrCount)*
sizeof (CHAR16) < *Size) {
1060 ASSERT (Buffer !=
NULL);
1061 ((CHAR16 *)Buffer)[CountSoFar-CrCount] = CharBuffer;
1062 ((CHAR16 *)Buffer)[CountSoFar+1-CrCount] = CHAR_NULL;
1069 if ((CountSoFar+1-CrCount)*
sizeof (CHAR16) > *Size) {
1071 *Size = (CountSoFar+1-CrCount)*
sizeof (CHAR16);
1073 if ((Buffer !=
NULL) && (OldSize != 0)) {
1078 return (EFI_BUFFER_TOO_SMALL);
1080 DEBUG ((DEBUG_WARN,
"The line was truncated in FileHandleReadLine"));
1122 UINT64 OriginalFilePosition;
1126 if (Buffer ==
NULL) {
1130 if (Handle ==
NULL) {
1131 return (EFI_INVALID_PARAMETER);
1138 if (EFI_ERROR (Status)) {
1143 if (EFI_ERROR (Status)) {
1148 if (EFI_ERROR (Status)) {
1152 if (FileSize == 0) {
1155 CharSize =
sizeof (CHAR16);
1166 if (EFI_ERROR (Status)) {
1171 Size = (
StrSize (Buffer) /
sizeof (CHAR16)) *
sizeof (CHAR8);
1173 if (AsciiBuffer ==
NULL) {
1174 return EFI_OUT_OF_RESOURCES;
1178 for (Index = 0; Index < Size; Index++) {
1179 if ((AsciiBuffer[Index] & BIT7) != 0) {
1181 return EFI_INVALID_PARAMETER;
1187 if (EFI_ERROR (Status)) {
1195 if (OriginalFilePosition == 0) {
1197 if (EFI_ERROR (Status)) {
1202 Size =
StrSize (Buffer) -
sizeof (CHAR16);
1204 if (EFI_ERROR (Status)) {
1208 Size =
StrSize (L
"\r\n") -
sizeof (CHAR16);
1212 if (AsciiBuffer !=
NULL) {
1247 if (Buffer ==
NULL) {
1248 return (EFI_OUT_OF_RESOURCES);
1292 if (Handle ==
NULL) {
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
RETURN_STATUS EFIAPI UnicodeStrToAsciiStrS(IN CONST CHAR16 *Source, OUT CHAR8 *Destination, IN UINTN DestMax)
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINTN EFIAPI UnicodeVSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString, IN VA_LIST Marker)
#define VA_START(Marker, Parameter)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet16(TokenName)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
EFI_STATUS EFIAPI FileHandleFlush(IN EFI_FILE_HANDLE FileHandle)
EFI_STATUS EFIAPI FileHandleGetFileName(IN CONST EFI_FILE_HANDLE Handle, OUT CHAR16 **FullFileName)
EFI_STATUS EFIAPI FileHandleWriteLine(IN EFI_FILE_HANDLE Handle, IN CHAR16 *Buffer)
EFI_STATUS EFIAPI FileHandlePrintLine(IN EFI_FILE_HANDLE Handle, IN CONST CHAR16 *Format,...)
EFI_STATUS EFIAPI FileHandleSetInfo(IN EFI_FILE_HANDLE FileHandle, IN CONST EFI_FILE_INFO *FileInfo)
CHAR16 *EFIAPI StrnCatGrowLeft(IN OUT CHAR16 **Destination, IN OUT UINTN *CurrentSize, IN CONST CHAR16 *Source, IN UINTN Count)
BOOLEAN EFIAPI FileHandleEof(IN EFI_FILE_HANDLE Handle)
EFI_STATUS EFIAPI FileHandleGetPosition(IN EFI_FILE_HANDLE FileHandle, OUT UINT64 *Position)
EFI_STATUS EFIAPI FileHandleReadLine(IN EFI_FILE_HANDLE Handle, IN OUT CHAR16 *Buffer, IN OUT UINTN *Size, IN BOOLEAN Truncate, IN OUT BOOLEAN *Ascii)
EFI_STATUS EFIAPI FileHandleSetPosition(IN EFI_FILE_HANDLE FileHandle, IN UINT64 Position)
EFI_FILE_INFO *EFIAPI FileHandleGetInfo(IN EFI_FILE_HANDLE FileHandle)
EFI_STATUS EFIAPI FileHandleIsDirectory(IN EFI_FILE_HANDLE DirHandle)
EFI_STATUS EFIAPI FileHandleSetSize(IN EFI_FILE_HANDLE FileHandle, IN UINT64 Size)
EFI_STATUS EFIAPI FileHandleFindNextFile(IN EFI_FILE_HANDLE DirHandle, OUT EFI_FILE_INFO *Buffer, OUT BOOLEAN *NoFile)
EFI_STATUS EFIAPI FileHandleClose(IN EFI_FILE_HANDLE FileHandle)
EFI_STATUS EFIAPI FileHandleGetSize(IN EFI_FILE_HANDLE FileHandle, OUT UINT64 *Size)
CHAR16 *EFIAPI FileHandleReturnLine(IN EFI_FILE_HANDLE Handle, IN OUT BOOLEAN *Ascii)
EFI_STATUS EFIAPI FileHandleDelete(IN EFI_FILE_HANDLE FileHandle)
EFI_STATUS EFIAPI FileHandleFindFirstFile(IN EFI_FILE_HANDLE DirHandle, OUT EFI_FILE_INFO **Buffer)
EFI_STATUS EFIAPI FileHandleWrite(IN EFI_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI FileHandleRead(IN EFI_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
CONST UINT16 gUnicodeFileTag
#define EFI_UNICODE_BYTE_ORDER_MARK