pub trait File: Sized {
// Required methods
fn is_regular_file(&self) -> Result<bool>;
fn is_directory(&self) -> Result<bool>;
// Provided methods
fn open(
&mut self,
filename: &CStr16,
open_mode: FileMode,
attributes: FileAttribute
) -> Result<FileHandle> { ... }
fn close(self) { ... }
fn delete(self) -> Result { ... }
fn get_info<'buf, Info: FileProtocolInfo + ?Sized>(
&mut self,
buffer: &'buf mut [u8]
) -> Result<&'buf mut Info, Option<usize>> { ... }
fn set_info<Info: FileProtocolInfo + ?Sized>(
&mut self,
info: &Info
) -> Result { ... }
fn flush(&mut self) -> Result { ... }
fn get_boxed_info<Info: FileProtocolInfo + ?Sized + Debug>(
&mut self
) -> Result<Box<Info>> { ... }
fn get_boxed_info_in<Info: FileProtocolInfo + ?Sized + Debug, A: Allocator>(
&mut self,
allocator: A
) -> Result<Box<Info>> { ... }
}
Expand description
Common interface to FileHandle
, RegularFile
, and Directory
.
File
contains all functionality that is safe to perform on any type of
file handle.
Required Methods§
sourcefn is_regular_file(&self) -> Result<bool>
fn is_regular_file(&self) -> Result<bool>
Returns if the underlying file is a regular file. The result is an error if the underlying file was already closed or deleted.
UEFI file system protocol only knows “regular files” and “directories”.
sourcefn is_directory(&self) -> Result<bool>
fn is_directory(&self) -> Result<bool>
Returns if the underlying file is a directory. The result is an error if the underlying file was already closed or deleted.
UEFI file system protocol only knows “regular files” and “directories”.
Provided Methods§
sourcefn open(
&mut self,
filename: &CStr16,
open_mode: FileMode,
attributes: FileAttribute
) -> Result<FileHandle>
fn open( &mut self, filename: &CStr16, open_mode: FileMode, attributes: FileAttribute ) -> Result<FileHandle>
Try to open a file relative to this file.
§Arguments
filename
Path of file to open, relative to this fileopen_mode
The mode to open the file withattributes
Only valid whenFILE_MODE_CREATE
is used as a mode
§Errors
See section EFI_FILE_PROTOCOL.Open()
in the UEFI Specification for more details.
Note that INVALID_PARAMETER
is not listed in the specification as one of the
errors returned by this function, but some implementations (such as EDK2) perform
additional validation and may return that status for invalid inputs.
sourcefn delete(self) -> Result
fn delete(self) -> Result
Closes and deletes this file
§Warnings
See section EFI_FILE_PROTOCOL.Delete()
in the UEFI Specification for more details.
sourcefn get_info<'buf, Info: FileProtocolInfo + ?Sized>(
&mut self,
buffer: &'buf mut [u8]
) -> Result<&'buf mut Info, Option<usize>>
fn get_info<'buf, Info: FileProtocolInfo + ?Sized>( &mut self, buffer: &'buf mut [u8] ) -> Result<&'buf mut Info, Option<usize>>
Queries some information about a file
The information will be written into a user-provided buffer. If the buffer is too small, the required buffer size will be returned as part of the error.
The buffer must be aligned on an <Info as Align>::alignment()
boundary.
§Arguments
buffer
Buffer that the information should be written into
§Errors
See section EFI_FILE_PROTOCOL.GetInfo()
in the UEFI Specification for more details.
sourcefn set_info<Info: FileProtocolInfo + ?Sized>(&mut self, info: &Info) -> Result
fn set_info<Info: FileProtocolInfo + ?Sized>(&mut self, info: &Info) -> Result
Sets some information about a file
There are various restrictions on the information that may be modified using this method.
The simplest one is that it is usually not possible to call it on read-only media. Further
restrictions specific to a given information type are described in the corresponding
FileProtocolInfo
type documentation.
§Arguments
info
Info that should be set for the file
§Errors
See section EFI_FILE_PROTOCOL.SetInfo()
in the UEFI Specification for more details.
sourcefn flush(&mut self) -> Result
fn flush(&mut self) -> Result
Flushes all modified data associated with the file handle to the device
§Errors
See section EFI_FILE_PROTOCOL.Flush()
in the UEFI Specification for more details.
sourcefn get_boxed_info<Info: FileProtocolInfo + ?Sized + Debug>(
&mut self
) -> Result<Box<Info>>
Available on crate feature alloc
only.
fn get_boxed_info<Info: FileProtocolInfo + ?Sized + Debug>( &mut self ) -> Result<Box<Info>>
alloc
only.Read the dynamically allocated info for a file.
sourcefn get_boxed_info_in<Info: FileProtocolInfo + ?Sized + Debug, A: Allocator>(
&mut self,
allocator: A
) -> Result<Box<Info>>
Available on crate features unstable
and alloc
only.
fn get_boxed_info_in<Info: FileProtocolInfo + ?Sized + Debug, A: Allocator>( &mut self, allocator: A ) -> Result<Box<Info>>
unstable
and alloc
only.Read the dynamically allocated info for a file.