[−][src]Struct uefi::proto::media::file::RegularFile
A FileHandle
that is also a regular (data) file.
Use FileHandle::into_kind
or RegularFile::new
to create a RegularFile
.
In addition to supporting the normal File
operations, RegularFile
supports direct reading and writing.
Implementations
impl RegularFile
[src]
pub const END_OF_FILE: u64
[src]
A special position used to seek to the end of a file with set_position()
.
pub unsafe fn new(handle: FileHandle) -> Self
[src]
Coverts a FileHandle
into a RegularFile
without checking the file kind.
Safety
This function should only be called on handles which ARE NOT directories, doing otherwise is unsafe.
pub fn read(&mut self, buffer: &mut [u8]) -> Result<usize, Option<usize>>
[src]
Read data from file
Try to read as much as possible into buffer
. Returns the number of bytes that were
actually read.
Arguments
buffer
The target buffer of the read operation
Errors
uefi::Status::NO_MEDIA
The device has no mediauefi::Status::DEVICE_ERROR
The device reported an error, the file was deleted, or the end of the file was reached before theread()
.uefi::Status::VOLUME_CORRUPTED
The filesystem structures are corrupteduefi::Status::BUFFER_TOO_SMALL
The buffer is too small to hold a directory entry, and the required buffer size is provided as output.
pub fn write(&mut self, buffer: &[u8]) -> Result<(), usize>
[src]
Write data to file
Write buffer
to file, increment the file pointer.
If an error occurs, returns the number of bytes that were actually written. If no error occured, the entire buffer is guaranteed to have been written successfully.
Arguments
buffer
Buffer to write to file
Errors
uefi::Status::NO_MEDIA
The device has no mediauefi::Status::DEVICE_ERROR
The device reported an error or the file was deleted.uefi::Status::VOLUME_CORRUPTED
The filesystem structures are corrupteduefi::Status::WRITE_PROTECTED
Attempt to write to readonly fileuefi::Status::ACCESS_DENIED
The file was opened read only.uefi::Status::VOLUME_FULL
The volume is full
pub fn get_position(&mut self) -> Result<u64>
[src]
Get the file's current position
Errors
uefi::Status::DEVICE_ERROR
An attempt was made to get the position of a deleted file
pub fn set_position(&mut self, position: u64) -> Result
[src]
Sets the file's current position
Set the position of this file handle to the absolute position specified by position
.
Seeking past the end of the file is allowed, it will trigger file growth on the next write. Using a position of RegularFile::END_OF_FILE will seek to the end of the file.
Arguments
position
The new absolution position of the file handle
Errors
uefi::Status::DEVICE_ERROR
An attempt was made to set the position of a deleted file
Trait Implementations
impl File for RegularFile
[src]
fn handle(&mut self) -> &mut FileHandle
[src]
fn open(
&mut self,
filename: &str,
open_mode: FileMode,
attributes: FileAttribute
) -> Result<FileHandle>
[src]
&mut self,
filename: &str,
open_mode: FileMode,
attributes: FileAttribute
) -> Result<FileHandle>
fn close(self)
[src]
fn delete(self) -> Result
[src]
fn get_info<'buf, Info: FileProtocolInfo + ?Sized>(
&mut self,
buffer: &'buf mut [u8]
) -> Result<&'buf mut Info, Option<usize>>
[src]
&mut self,
buffer: &'buf mut [u8]
) -> Result<&'buf mut Info, Option<usize>>
fn set_info<Info: FileProtocolInfo + ?Sized>(&mut self, info: &Info) -> Result
[src]
fn flush(&mut self) -> Result
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,