本文整理汇总了C++中EFI_FILE_HANDLE::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_FILE_HANDLE::Write方法的具体用法?C++ EFI_FILE_HANDLE::Write怎么用?C++ EFI_FILE_HANDLE::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EFI_FILE_HANDLE
的用法示例。
在下文中一共展示了EFI_FILE_HANDLE::Write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AllocateZeroPool
EFI_STATUS
EFIAPI
InstallAgent(
IN EFI_FILE_HANDLE CurDir,
IN CHAR16 * FileNameUser
)
{
EFI_STATUS Status = EFI_SUCCESS;
EFI_FILE_HANDLE FileHandle;
CHAR16* FileNameScout;
FileNameScout = AllocateZeroPool(260*sizeof(CHAR16));
StrCpy(FileNameScout,FileNameUser);
StrCat(FileNameScout, FILE_NAME_SCOUT);
StrCat(FileNameScout, g_NAME_SCOUT);
Status = CurDir->Open (CurDir, &FileHandle, FileNameScout, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
FreePool(FileNameScout);
if (EFI_ERROR(Status))
{
#ifdef FORCE_DEBUG
Print(L"Error Open Agent File\n");
#endif
return Status;
}
#ifdef FORCE_DEBUG
Print(L"FileHandle->Write ... VirtualSize=%x [0]=%x [1]=%x [2]=%x [3]=%x\n",VirtualSize,((UINT8*)pSectiondata)[0],((UINT8*)pSectiondata)[1] * 0x100 ,((UINT8*)pSectiondata)[2] * 0x10000,((UINT8*)pSectiondata)[3] * 0x1000000);
#endif
Status=FileHandle->Write(FileHandle,&VirtualSize,(UINT8*)(pSectiondata));
if( Status != EFI_SUCCESS )
{
#ifdef FORCE_DEBUG
Print(L"Write File Agent Failed\n");
#endif
return Status;
}
else
{
#ifdef FORCE_DEBUG
Print(L"InstallAgent OK\n");
#endif
}
Status=FileHandle->Close(FileHandle);
if( Status != EFI_SUCCESS )
{
#ifdef FORCE_DEBUG
Print(L"Closing File Agent Failed\n");
#endif
return Status;
}
return EFI_SUCCESS;
}
示例2: while
//.........这里部分代码省略.........
// Open volume for file system on device path
//
Status = Vol->OpenVolume (Vol, &RootDir);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Determine the existence of the file
//
Status = RootDir->Open (
RootDir,
&Handle,
FileName,
EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ,
0
);
if (Status == EFI_NOT_FOUND) {
//
// The file not exist, create it
//
Status = SctCreateFile (RootDir, FileName, &Handle);
if (EFI_ERROR (Status)) {
RootDir->Close (RootDir);
return Status;
}
//
// Write the head of Unicode text file
//
Buffer[0] = 0xff;
Buffer[1] = 0xfe;
BufSize = 2;
Status = Handle->Write (Handle, &BufSize, Buffer);
if (EFI_ERROR (Status)) {
Handle->Close (Handle);
return Status;
}
} else if (EFI_ERROR (Status)) {
RootDir->Close(RootDir);
return Status;
}
if (OverwriteFile) {
//
// Overwrite the file
//
//
// Delete the file
//
Status = Handle->Delete (Handle);
//
// EFI_FILE.Delete() return a warning status
//
if (Status != EFI_SUCCESS) {
RootDir->Close (RootDir);
return EFI_UNSUPPORTED;
}
//
// Recreate the file
//
Status = RootDir->Open (
RootDir,
示例3: GetMyVol
/**
Write a file.
@param[in] FileName The file to be written.
@param[in] BufferSize The file buffer size
@param[in] Buffer The file buffer
@retval EFI_SUCCESS Write file successfully
**/
EFI_STATUS
WriteFileFromBuffer (
IN CHAR16 *FileName,
IN UINTN BufferSize,
IN VOID *Buffer
)
{
EFI_STATUS Status;
EFI_FILE_HANDLE RootDir;
EFI_FILE_HANDLE Handle;
UINTN TempBufferSize;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
Vol = GetMyVol();
if (Vol == NULL) {
return EFI_NOT_FOUND;
}
//
// Open the root directory
//
Status = Vol->OpenVolume (Vol, &RootDir);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Open the file
//
Status = RootDir->Open (
RootDir,
&Handle,
FileName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE,
0
);
if (EFI_ERROR (Status)) {
RootDir->Close (RootDir);
return Status;
}
//
// Delete file
//
Status = Handle->Delete(Handle);
if (EFI_ERROR(Status)) {
return Status;
}
//
// Open the file again
//
Status = RootDir->Open (
RootDir,
&Handle,
FileName,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE,
0
);
if (EFI_ERROR (Status)) {
RootDir->Close (RootDir);
return Status;
}
RootDir->Close (RootDir);
//
// Write the file data from the buffer
//
TempBufferSize = BufferSize;
Status = Handle->Write (
Handle,
&TempBufferSize,
Buffer
);
if (EFI_ERROR (Status)) {
Handle->Close (Handle);
return Status;
}
Handle->Close (Handle);
return EFI_SUCCESS;
}
示例4: if
EFI_STATUS
EFIAPI
TrlWriteResetRecord (
IN EFI_TEST_RECOVERY_LIBRARY_PROTOCOL *This,
IN UINTN Size,
IN VOID *Buffer
)
/*++
Routine Description:
One interface function of the TestRecoveryLibrary to write reset record.
Arguments:
This - the protocol instance structure.
Size - the bytes to be write, it can't bigger than 1024Bytes.
Buffer - buffer contain the record to be written.
Returns:
EFI_SUCCESS - write the record successfully.
EFI_INVALID_PARAMETER - invalid parameters.
--*/
{
EFI_STATUS Status;
EFI_HANDLE DeviceHandle;
EFI_FILE_HANDLE RootDir;
EFI_FILE_HANDLE Handle;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
TEST_RECOVERY_PRIVATE_DATA *Private;
EFI_DEVICE_PATH_PROTOCOL *PreDevicePath;
Private = TEST_RECOVERY_PRIVATE_DATA_FROM_TRL (This);
//
// Determine device handle for fs protocol on specified device path
//
PreDevicePath = Private->DevicePath;
Status = gBS->LocateDevicePath (
&gEfiSimpleFileSystemProtocolGuid,
&PreDevicePath,
&DeviceHandle
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Determine volume for file system on device handle
//
Status = gBS->HandleProtocol (
DeviceHandle,
&gEfiSimpleFileSystemProtocolGuid,
(VOID*)&Vol
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Open volume for file system on device path
//
Status = Vol->OpenVolume (Vol, &RootDir);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Open file for read
//
Status = RootDir->Open (
RootDir,
&Handle,
Private->FileName,
EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE,
0
);
if (Status == EFI_NOT_FOUND) {
//
// The file not exist, create it
//
Status = RootDir->Open (
RootDir,
&Handle,
Private->FileName,
EFI_FILE_MODE_CREATE|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ,
0
);
if (EFI_ERROR (Status)) {
RootDir->Close (RootDir);
return Status;
}
} else if (Status == EFI_SUCCESS) {
//
// The file exist, delete it
//
Status = Handle->Delete (Handle);
//
//.........这里部分代码省略.........
示例5: GetFloppyDevicePath
/**
* Write a file to floppy disk.
*/
EFI_STATUS
WriteFloppyFile (
IN CHAR16 *FileName,
IN OUT UINT32 Length,
IN VOID *Buffer
)
{
EFI_STATUS Status;
EFI_HANDLE DeviceHandle;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Vol;
EFI_FILE_HANDLE RootDir;
EFI_FILE_HANDLE Handle;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINTN BufLen;
//
// Get floppy device path
//
Status = GetFloppyDevicePath (&DevicePath);
if (EFI_ERROR(Status)) {
return Status;
}
//
// Determine device handle for fs protocol on floppy device path
//
Status = gtBS->LocateDevicePath (
&gEfiSimpleFileSystemProtocolGuid,
&DevicePath,
&DeviceHandle
);
if (EFI_ERROR(Status) ) {
return Status;
}
//
// Determine volume for file system on device handle
//
Status = gtBS->HandleProtocol (
DeviceHandle,
&gEfiSimpleFileSystemProtocolGuid,
(VOID*)&Vol
);
if (EFI_ERROR(Status) ) {
return Status;
}
//
// Open volume for file system on device path
//
Status = Vol->OpenVolume (Vol, &RootDir);
if (Status == EFI_MEDIA_CHANGED) {
//
// Reopen the volume
//
Status = gtBS->HandleProtocol (
DeviceHandle,
&gEfiSimpleFileSystemProtocolGuid,
(VOID*)&Vol
);
if (EFI_ERROR(Status) ) {
return Status;
}
Status = Vol->OpenVolume (Vol, &RootDir);
}
if (EFI_ERROR(Status) ) {
return Status;
}
//
// Determine the existence of the file
//
Status = RootDir->Open (
RootDir,
&Handle,
FileName,
EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE,
0
);
if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_FOUND)) {
RootDir->Close (RootDir);
return Status;
}
if (Status == EFI_SUCCESS) {
//
// Delete the existent file
//
Status = Handle->Delete (Handle);
if (Status != EFI_SUCCESS) {
Handle->Close (Handle);
RootDir->Close (RootDir);
return Status;
}
}
//
//.........这里部分代码省略.........
示例6: SctReportConfig
//.........这里部分代码省略.........
EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Get report infor - %r", Status));
BS->FreePool (ConfigBuffer);
UnloadGuidDatabase ();
UnloadReportInfor ();
return Status;
}
UnloadGuidDatabase ();
UnloadReportInfor ();
//
// Convert the buffer to ASCII buffer
//
AsciiBufferSize = StrLen(Buffer) + 1;
Status = BS->AllocatePool (
EfiBootServicesData,
AsciiBufferSize,
&AsciiBuffer
);
if (EFI_ERROR (Status)) {
EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Allocate pool - %r", Status));
BS->FreePool (ConfigBuffer);
BS->FreePool (Buffer);
return Status;
}
Status = UnicodeToAscii (Buffer, AsciiBuffer);
if (EFI_ERROR (Status)) {
EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Convert Unicode to ASCII - %r", Status));
BS->FreePool (ConfigBuffer);
BS->FreePool (Buffer);
BS->FreePool (AsciiBuffer);
return Status;
}
BS->FreePool (Buffer);
//
// Create the report file
//
Status = SctCreateFileFromDevicePath (
ReportDevicePath,
ReportFileName,
&Handle
);
if (EFI_ERROR (Status)) {
EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Create report file - %r", Status));
BS->FreePool (ConfigBuffer);
BS->FreePool (AsciiBuffer);
return Status;
}
//
// Write the ASCII buffer to the report file (remove the null-terminator)
//
AsciiBufferSize --;
Status = Handle->Write (
Handle,
&AsciiBufferSize,
AsciiBuffer
);
if (EFI_ERROR (Status)) {
EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Write report file - %r", Status));
BS->FreePool (ConfigBuffer);
BS->FreePool (AsciiBuffer);
Handle->Close (Handle);
return Status;
}
//
// Write the config buffer to the report file
//
Status = Handle->Write (
Handle,
&ConfigBufferSize,
ConfigBuffer
);
if (EFI_ERROR (Status)) {
EFI_SCT_DEBUG ((EFI_SCT_D_ERROR, L"Write report file - %r", Status));
BS->FreePool (ConfigBuffer);
BS->FreePool (AsciiBuffer);
Handle->Close (Handle);
return Status;
}
BS->FreePool (ConfigBuffer);
BS->FreePool (AsciiBuffer);
//
// Close the report file
//
Handle->Close (Handle);
//
// Done
//
return EFI_SUCCESS;
}