Discussion:
[edk2] how to get the file length
KSilva
2015-06-01 13:31:48 UTC
Permalink
I am trying to get a file length, but I have not had success yet.

here is my code:


Status = gBS->HandleProtocol(Device,
&gSimpleFileProtocol,
(VOID**)&fileSystemProtocol
);

Print(L"Status HandleProtocol :%r\n", Status);

root = NULL;
AsciiStrToUnicodeStr("kdias", texto);

Status = fileSystemProtocol->OpenVolume(fileSystemProtocol,
&root);

Print(L"Status OpenVolume :%r\n", Status);


Status = root->Open(root,
&newHandle,
nameFile,
EFI_FILE_MODE_READ| EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);


Print(L"Status do Open : %r \n",Status);


Status = newHandle->GetInfo(newHandle,&gEfiFileInfoGuid,&BufferSize,(VOID
&fileInfo);
Print(L"Status GetInfo :%r \n",Status);



return EFI_SUCCESS;
}


------------------------------------------------------------------------------
A***@congatec.com
2015-06-01 16:35:02 UTC
Permalink
The GetInfo function of the EFI_FILE_PROTOCOL can be used to retrieve the
information about the file. You will need to use the EFI_FILE_PROTOCOL
instance from opening the specific file instance. for example, if you
wanted to open Info.txt in the root of the file system, you should use the
root->open for "Info.txt" and get the returned file handle. Then, using
the returned EFI_FILE_PROTOCOL, you should call EFI_FILE_GET_INFO and pass
the gEfiFileInfoGuid and a buffer and a buffersize. The EFI_FILE_GET_INFO
function may return EFI_BUFFER_TOO_SMALL, in which case, it will update
the buffer size pointer with the required size to fit the EFI_FILE_INFO
structure.

Best Regards,
Aaron



From: KSilva <>
To: edk2-***@lists.sourceforge.net,
Date: 06/01/2015 06:33 AM
Subject: [edk2] how to get the file length



I am trying to get a file length, but I have not had success yet.

here is my code:


Status = gBS->HandleProtocol(Device,
&gSimpleFileProtocol,
(VOID**)&fileSystemProtocol
);

Print(L"Status HandleProtocol :%r\n", Status);

root = NULL;
AsciiStrToUnicodeStr("kdias", texto);

Status =
fileSystemProtocol->OpenVolume(fileSystemProtocol,
&root);

Print(L"Status OpenVolume :%r\n", Status);


Status = root->Open(root,
&newHandle,
nameFile,
EFI_FILE_MODE_READ|
EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);


Print(L"Status do Open :
%r \n",Status);


Status =
newHandle->GetInfo(newHandle,&gEfiFileInfoGuid,&BufferSize,(VOID
&fileInfo);
Print(L"Status GetInfo
:%r \n",Status);



return EFI_SUCCESS;
}


------------------------------------------------------------------------------
Carsey, Jaben
2015-06-01 18:10:51 UTC
Permalink
What's happening with your code? That looks quite similar to what I would expect...

-Jaben

-----Original Message-----
From: KSilva [mailto:***@iatecam.org.br]
Sent: Monday, June 01, 2015 6:32 AM
To: edk2-***@lists.sourceforge.net
Subject: [edk2] how to get the file length

I am trying to get a file length, but I have not had success yet.

here is my code:


Status = gBS->HandleProtocol(Device,
&gSimpleFileProtocol,
(VOID**)&fileSystemProtocol
);

Print(L"Status HandleProtocol :%r\n", Status);

root = NULL;
AsciiStrToUnicodeStr("kdias", texto);

Status = fileSystemProtocol->OpenVolume(fileSystemProtocol,
&root);

Print(L"Status OpenVolume :%r\n", Status);


Status = root->Open(root,
&newHandle,
nameFile,
EFI_FILE_MODE_READ| EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);


Print(L"Status do Open : %r \n",Status);


Status = newHandle->GetInfo(newHandle,&gEfiFileInfoGuid,&BufferSize,(VOID
&fileInfo);
Print(L"Status GetInfo :%r \n",Status);



return EFI_SUCCESS;
}
KSilva
2015-06-01 19:25:43 UTC
Permalink
KSilva <kaleb.silva <at> iatecam.org.br> writes:


I got it, Thanks!


------------------------------------------------------------------------------
Loading...