Struct File

Source
pub struct File {
    pub inner: Arc<dyn INodeInterface>,
    pub offset: Mutex<usize>,
    pub flags: Mutex<OpenFlags>,
    /* private fields */
}

Fields§

§inner: Arc<dyn INodeInterface>§offset: Mutex<usize>§flags: Mutex<OpenFlags>

Implementations§

Source§

impl File

Source

pub fn open<T: Into<PathBuf>>(path: T, flags: OpenFlags) -> VfsResult<File>

Source

pub fn new_dev(inner: Arc<dyn INodeInterface>) -> Arc<Self>

打开真正的文件,如果 path 是 link 文件,会打开真正的文件

Source

pub fn remove_self(&self) -> VfsResult<()>

Source

pub fn get_bare_file(&self) -> Arc<dyn INodeInterface>

Source

pub fn path(&self) -> String

Source

pub fn path_buf(&self) -> PathBuf

Source

pub fn file_size(&self) -> VfsResult<usize>

Source

pub fn file_type(&self) -> VfsResult<FileType>

Source

pub fn getdents(&self, buffer: &mut [u8]) -> Result<usize, Errno>

Source§

impl File

Source

pub fn mkdir(&self, name: &str) -> Result<(), Errno>

Source

pub fn rmdir(&self, name: &str) -> Result<(), Errno>

Source

pub fn remove(&self, name: &str) -> Result<(), Errno>

Source

pub fn moveto(&self, _path: &str) -> Result<Self, Errno>

Source

pub fn read_dir(&self) -> Result<Vec<DirEntry>, Errno>

Source

pub fn lookup(&self, name: &str) -> Result<Arc<dyn INodeInterface>, Errno>

Source

pub fn ioctl(&self, command: usize, arg: usize) -> Result<usize, Errno>

Source

pub fn truncate(&self, size: usize) -> Result<(), Errno>

Source

pub fn flush(&self) -> Result<(), Errno>

Source

pub fn stat(&self, stat: &mut Stat) -> Result<(), Errno>

Source

pub fn mount(&self, path: &str) -> Result<(), Errno>

Source

pub fn umount(&self) -> Result<(), Errno>

Source

pub fn statfs(&self, statfs: &mut StatFS) -> Result<(), Errno>

Source

pub fn utimes(&self, times: &mut [TimeSpec]) -> Result<(), Errno>

Source

pub fn poll(&self, events: PollEvent) -> Result<PollEvent, Errno>

Source§

impl File

Source

pub fn readat(&self, offset: usize, buffer: &mut [u8]) -> Result<usize, Errno>

Source

pub fn writeat(&self, offset: usize, buffer: &[u8]) -> Result<usize, Errno>

Source

pub fn read(&self, buffer: &mut [u8]) -> Result<usize, Errno>

Source

pub fn write(&self, buffer: &[u8]) -> Result<usize, Errno>

Source

pub async fn async_read(&self, buffer: &mut [u8]) -> Result<usize, Errno>

Source

pub async fn async_write(&self, buffer: &[u8]) -> Result<usize, Errno>

Source

pub fn seek(&self, seek_from: SeekFrom) -> Result<usize, Errno>

Trait Implementations§

Source§

impl Clone for File

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !Freeze for File

§

impl !RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl !UnwindSafe for File

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.