mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcFileLib: Provide slow path for getting file size
This commit is contained in:
parent
7a569d7d7a
commit
2b7ed55cf2
@ -124,11 +124,24 @@ GetFileSize (
|
||||
OUT UINT32 *Size
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINT64 Position;
|
||||
EFI_STATUS Status;
|
||||
UINT64 Position;
|
||||
EFI_FILE_INFO *FileInfo;
|
||||
|
||||
Status = File->SetPosition (File, 0xFFFFFFFFFFFFFFFFULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
// Some drivers, like EfiFs, return EFI_UNSUPPORTED when trying to seek
|
||||
// past the file size. Use slow method via attributes for them.
|
||||
//
|
||||
FileInfo = GetFileInfo (File, &gEfiFileInfoGuid, sizeof (*FileInfo), NULL);
|
||||
if (FileInfo != NULL) {
|
||||
if ((UINT32) FileInfo->FileSize == FileInfo->FileSize) {
|
||||
*Size = (UINT32) FileInfo->FileSize;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
FreePool (FileInfo);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user