mirror of https://github.com/acidanthera/audk.git
renaming the BaseFileHandleLib to UefiFileHandleLib.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11421 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
77dcec128b
commit
4eb59be368
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Provides interface to EFI_FILE_HANDLE functionality.
|
Provides interface to EFI_FILE_HANDLE functionality.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved. <BR>
|
Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
|
|
||||||
#include <Protocol/SimpleFileSystem.h>
|
#include <Protocol/SimpleFileSystem.h>
|
||||||
|
#include <Protocol/UnicodeCollation.h>
|
||||||
|
|
||||||
#include <Guid/FileInfo.h>
|
#include <Guid/FileInfo.h>
|
||||||
|
|
||||||
|
@ -26,6 +27,8 @@
|
||||||
#include <Library/PcdLib.h>
|
#include <Library/PcdLib.h>
|
||||||
#include <Library/PrintLib.h>
|
#include <Library/PrintLib.h>
|
||||||
|
|
||||||
|
CONST UINT16 gUnicodeFileTag = EFI_UNICODE_BYTE_ORDER_MARK;
|
||||||
|
|
||||||
#define MAX_FILE_NAME_LEN 522 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
|
#define MAX_FILE_NAME_LEN 522 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)
|
||||||
#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)
|
#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)
|
||||||
|
|
||||||
|
@ -53,10 +56,9 @@ FileHandleGetInfo (
|
||||||
UINTN FileInfoSize;
|
UINTN FileInfoSize;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
//
|
if (FileHandle == NULL) {
|
||||||
// ASSERT if FileHandle is NULL
|
return (NULL);
|
||||||
//
|
}
|
||||||
ASSERT (FileHandle != NULL);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get the required size to allocate
|
// Get the required size to allocate
|
||||||
|
@ -66,26 +68,26 @@ FileHandleGetInfo (
|
||||||
Status = FileHandle->GetInfo(FileHandle,
|
Status = FileHandle->GetInfo(FileHandle,
|
||||||
&gEfiFileInfoGuid,
|
&gEfiFileInfoGuid,
|
||||||
&FileInfoSize,
|
&FileInfoSize,
|
||||||
FileInfo);
|
NULL);
|
||||||
//
|
if (Status == EFI_BUFFER_TOO_SMALL){
|
||||||
// error is expected. getting size to allocate
|
//
|
||||||
//
|
// error is expected. getting size to allocate
|
||||||
ASSERT (Status == EFI_BUFFER_TOO_SMALL);
|
//
|
||||||
FileInfo = AllocateZeroPool(FileInfoSize);
|
FileInfo = AllocateZeroPool(FileInfoSize);
|
||||||
ASSERT (FileInfo != NULL);
|
//
|
||||||
//
|
// now get the information
|
||||||
// now get the information
|
//
|
||||||
//
|
Status = FileHandle->GetInfo(FileHandle,
|
||||||
Status = FileHandle->GetInfo(FileHandle,
|
&gEfiFileInfoGuid,
|
||||||
&gEfiFileInfoGuid,
|
&FileInfoSize,
|
||||||
&FileInfoSize,
|
FileInfo);
|
||||||
FileInfo);
|
//
|
||||||
//
|
// if we got an error free the memory and return NULL
|
||||||
// if we got an error free the memory and return NULL
|
//
|
||||||
//
|
if (EFI_ERROR(Status)) {
|
||||||
if (EFI_ERROR(Status)) {
|
FreePool(FileInfo);
|
||||||
FreePool(FileInfo);
|
return NULL;
|
||||||
return NULL;
|
}
|
||||||
}
|
}
|
||||||
return (FileInfo);
|
return (FileInfo);
|
||||||
}
|
}
|
||||||
|
@ -467,11 +469,9 @@ FileHandleFindFirstFile (
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN BufferSize;
|
UINTN BufferSize;
|
||||||
|
|
||||||
//
|
if (Buffer == NULL || DirHandle == NULL) {
|
||||||
// ASSERTs
|
return (EFI_INVALID_PARAMETER);
|
||||||
//
|
}
|
||||||
ASSERT (DirHandle != NULL);
|
|
||||||
ASSERT (Buffer != NULL);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// verify that DirHandle is a directory
|
// verify that DirHandle is a directory
|
||||||
|
@ -481,20 +481,24 @@ FileHandleFindFirstFile (
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// reset to the begining of the directory
|
|
||||||
//
|
|
||||||
Status = FileHandleSetPosition(DirHandle, 0);
|
|
||||||
if (EFI_ERROR(Status)) {
|
|
||||||
return (Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allocate a buffer sized to struct size + enough for the string at the end
|
// Allocate a buffer sized to struct size + enough for the string at the end
|
||||||
//
|
//
|
||||||
BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;
|
BufferSize = FIND_XXXXX_FILE_BUFFER_SIZE;
|
||||||
*Buffer = AllocateZeroPool(BufferSize);
|
*Buffer = AllocateZeroPool(BufferSize);
|
||||||
ASSERT (*Buffer != NULL);
|
if (*Buffer == NULL){
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// reset to the begining of the directory
|
||||||
|
//
|
||||||
|
Status = FileHandleSetPosition(DirHandle, 0);
|
||||||
|
if (EFI_ERROR(Status)) {
|
||||||
|
FreePool(*Buffer);
|
||||||
|
*Buffer = NULL;
|
||||||
|
return (Status);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// read in the info about the first file
|
// read in the info about the first file
|
||||||
|
@ -898,7 +902,7 @@ FileHandleReturnLine(
|
||||||
|
|
||||||
Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);
|
Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
RetVal = AllocatePool(Size);
|
RetVal = AllocateZeroPool(Size);
|
||||||
Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);
|
Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);
|
||||||
}
|
}
|
||||||
ASSERT_EFI_ERROR(Status);
|
ASSERT_EFI_ERROR(Status);
|
||||||
|
@ -963,7 +967,7 @@ FileHandleReadLine(
|
||||||
CharSize = sizeof(CHAR16);
|
CharSize = sizeof(CHAR16);
|
||||||
Status = FileHandleRead(Handle, &CharSize, &CharBuffer);
|
Status = FileHandleRead(Handle, &CharSize, &CharBuffer);
|
||||||
ASSERT_EFI_ERROR(Status);
|
ASSERT_EFI_ERROR(Status);
|
||||||
if (CharBuffer == UnicodeFileTag) {
|
if (CharBuffer == gUnicodeFileTag) {
|
||||||
*Ascii = FALSE;
|
*Ascii = FALSE;
|
||||||
} else {
|
} else {
|
||||||
*Ascii = TRUE;
|
*Ascii = TRUE;
|
|
@ -26,7 +26,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
[Sources.common]
|
[Sources.common]
|
||||||
BaseFileHandleLib.c
|
UefiFileHandleLib.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
Loading…
Reference in New Issue