pub struct File { /* private fields */ }
Expand description
An opened file object, with open permissions and a cursor.
Implementations§
source§impl File
impl File
sourcepub fn open(path: &str, opts: &OpenOptions) -> AxResult<Self>
pub fn open(path: &str, opts: &OpenOptions) -> AxResult<Self>
Opens a file at the path relative to the current directory. Returns a
File
object.
sourcepub fn read(&mut self, buf: &mut [u8]) -> AxResult<usize>
pub fn read(&mut self, buf: &mut [u8]) -> AxResult<usize>
Reads the file at the current position. Returns the number of bytes read.
After the read, the cursor will be advanced by the number of bytes read.
sourcepub fn read_at(&self, offset: u64, buf: &mut [u8]) -> AxResult<usize>
pub fn read_at(&self, offset: u64, buf: &mut [u8]) -> AxResult<usize>
Reads the file at the given position. Returns the number of bytes read.
It does not update the file cursor.
sourcepub fn write(&mut self, buf: &[u8]) -> AxResult<usize>
pub fn write(&mut self, buf: &[u8]) -> AxResult<usize>
Writes the file at the current position. Returns the number of bytes written.
After the write, the cursor will be advanced by the number of bytes written.
sourcepub fn write_at(&self, offset: u64, buf: &[u8]) -> AxResult<usize>
pub fn write_at(&self, offset: u64, buf: &[u8]) -> AxResult<usize>
Writes the file at the given position. Returns the number of bytes written.
It does not update the file cursor.
sourcepub fn flush(&self) -> AxResult
pub fn flush(&self) -> AxResult
Flushes the file, writes all buffered data to the underlying device.
sourcepub fn seek(&mut self, pos: SeekFrom) -> AxResult<u64>
pub fn seek(&mut self, pos: SeekFrom) -> AxResult<u64>
Sets the cursor of the file to the specified offset. Returns the new position after the seek.
sourcepub fn executable(&self) -> bool
pub fn executable(&self) -> bool
whether the file is executable.