[][src]Trait uefi::proto::media::file::File

pub trait File: Sized {
    fn open(
        &mut self,
        filename: &str,
        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 { ... } }

Common interface to FileHandle, RegularFile, and Directory.

File contains all functionality that is safe to perform on any type of file handle.

Provided methods

fn open(
    &mut self,
    filename: &str,
    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 file
  • open_mode The mode to open the file with
  • attributes Only valid when FILE_MODE_CREATE is used as a mode

Errors

  • uefi::Status::INVALID_PARAMETER The filename exceeds the maximum length of 255 chars
  • uefi::Status::NOT_FOUND Could not find file
  • uefi::Status::NO_MEDIA The device has no media
  • uefi::Status::MEDIA_CHANGED The device has a different medium in it
  • uefi::Status::DEVICE_ERROR The device reported an error
  • uefi::Status::VOLUME_CORRUPTED The filesystem structures are corrupted
  • uefi::Status::WRITE_PROTECTED Write/Create attempted on readonly file
  • uefi::Status::ACCESS_DENIED The service denied access to the file
  • uefi::Status::OUT_OF_RESOURCES Not enough resources to open file
  • uefi::Status::VOLUME_FULL The volume is full

fn close(self)

Close this file handle. Same as dropping this structure.

fn delete(self) -> Result

Closes and deletes this file

Warnings

  • uefi::Status::WARN_DELETE_FAILURE The file was closed, but deletion failed

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

  • uefi::Status::UNSUPPORTED The file does not possess this information type
  • uefi::Status::NO_MEDIA The device has no medium
  • uefi::Status::DEVICE_ERROR The device reported an error
  • uefi::Status::VOLUME_CORRUPTED The file system structures are corrupted
  • uefi::Status::BUFFER_TOO_SMALL The buffer is too small for the requested

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

  • uefi::Status::UNSUPPORTED The file does not possess this information type
  • uefi::Status::NO_MEDIA The device has no medium
  • uefi::Status::DEVICE_ERROR The device reported an error
  • uefi::Status::VOLUME_CORRUPTED The file system structures are corrupted
  • uefi::Status::WRITE_PROTECTED Attempted to set information on a read-only media
  • uefi::Status::ACCESS_DENIED Requested change is invalid for this information type
  • uefi::Status::VOLUME_FULL Not enough space left on the volume to change the info

fn flush(&mut self) -> Result

Flushes all modified data associated with the file handle to the device

Errors

  • uefi::Status::NO_MEDIA The device has no media
  • uefi::Status::DEVICE_ERROR The device reported an error
  • uefi::Status::VOLUME_CORRUPTED The filesystem structures are corrupted
  • uefi::Status::WRITE_PROTECTED The file or medium is write protected
  • uefi::Status::ACCESS_DENIED The file was opened read only
  • uefi::Status::VOLUME_FULL The volume is full
Loading content...

Implementors

impl File for Directory[src]

impl File for FileHandle[src]

impl File for RegularFile[src]

Loading content...