pub struct MtFile;Expand description
MT Framework’s file stream class (MtFile).
Wraps a game-side file object, exposing its I/O operations — open, read,
write, seek and the various size/position queries — through the underlying
vtable. Instances are created through the game’s own factory (see
open), which is why the type derives
CacheDti to locate its MtDti.
MtFile also implements core::fmt::Write, so it can be used as the
target of write! / writeln! to append UTF-8 text.
§Layout
#[repr(C)] (an opaque, vtable-only type via #[derive(Object)]), since it
is only ever used by reference to call its virtual functions.
Implementations§
Source§impl MtFile
impl MtFile
Sourcepub fn open(path: &str, mode: OpenMode) -> MtResult<&mut Self>
pub fn open(path: &str, mode: OpenMode) -> MtResult<&mut Self>
Opens the file at path with the given OpenMode.
Locates the MtFile class, constructs a new instance through its
factory, and opens the file on it. The path is passed to the game as a
raw byte pointer.
§Errors
Returns MtError::DtiNotFound if the MtFile class is missing,
MtError::FailedToCreateInstance if construction fails, or
MtError::FailedToOpenFile if the open itself fails.
Sourcepub fn read(&mut self, buffer: &mut [u8]) -> usize
pub fn read(&mut self, buffer: &mut [u8]) -> usize
Reads up to buffer.len() bytes into buffer, returning the number of
bytes actually read.
Sourcepub fn write(&mut self, data: &[u8]) -> usize
pub fn write(&mut self, data: &[u8]) -> usize
Writes data to the file, returning the number of bytes actually
written.
Sourcepub fn seek(&mut self, offset: isize, origin: Origin)
pub fn seek(&mut self, offset: isize, origin: Origin)
Moves the file position by offset bytes relative to origin.
pub fn close(&mut self)
pub fn is_async_reading(&self) -> bool
pub fn tell(&self) -> usize
pub fn size(&self) -> usize
pub fn set_size(&mut self, size: usize)
pub fn is_readable(&self) -> bool
pub fn is_writable(&self) -> bool
pub fn is_async_readable(&self) -> bool
pub fn get_async_read_size(&self) -> usize
Trait Implementations§
Source§impl Object for MtFile
impl Object for MtFile
Source§fn is_enable_instance(&self) -> bool
fn is_enable_instance(&self) -> bool
Source§fn create_property(&self, props: *mut c_void)
fn create_property(&self, props: *mut c_void)
props (an MtPropertyList) with the object’s reflected
properties (vtable slot 4). Read more