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
impl File
pub fn open<T: Into<PathBuf>>(path: T, flags: OpenFlags) -> VfsResult<File>
pub fn new_dev(inner: Arc<dyn INodeInterface>) -> Arc<Self>
Sourcepub fn open_link<T: Into<PathBuf>>(
path: T,
flags: OpenFlags,
) -> Result<File, Errno>
pub fn open_link<T: Into<PathBuf>>( path: T, flags: OpenFlags, ) -> Result<File, Errno>
打开真正的文件,如果 path 是 link 文件,会打开真正的文件
pub fn remove_self(&self) -> VfsResult<()>
pub fn get_bare_file(&self) -> Arc<dyn INodeInterface>
pub fn path(&self) -> String
pub fn path_buf(&self) -> PathBuf
pub fn file_size(&self) -> VfsResult<usize>
pub fn file_type(&self) -> VfsResult<FileType>
pub fn getdents(&self, buffer: &mut [u8]) -> Result<usize, Errno>
Source§impl File
impl File
pub fn mkdir(&self, name: &str) -> Result<(), Errno>
pub fn rmdir(&self, name: &str) -> Result<(), Errno>
pub fn remove(&self, name: &str) -> Result<(), Errno>
pub fn moveto(&self, _path: &str) -> Result<Self, Errno>
pub fn read_dir(&self) -> Result<Vec<DirEntry>, Errno>
pub fn lookup(&self, name: &str) -> Result<Arc<dyn INodeInterface>, Errno>
pub fn ioctl(&self, command: usize, arg: usize) -> Result<usize, Errno>
pub fn truncate(&self, size: usize) -> Result<(), Errno>
pub fn flush(&self) -> Result<(), Errno>
pub fn resolve_link(&self) -> Result<String, Errno>
pub fn link( &self, name: &str, src: Arc<dyn INodeInterface>, ) -> Result<(), Errno>
pub fn unlink(&self, name: &str) -> Result<(), Errno>
pub fn stat(&self, stat: &mut Stat) -> Result<(), Errno>
pub fn symlink(&self, name: &str, target: &str) -> Result<(), Errno>
pub fn mount(&self, path: &str) -> Result<(), Errno>
pub fn umount(&self) -> Result<(), Errno>
pub fn statfs(&self, statfs: &mut StatFS) -> Result<(), Errno>
pub fn utimes(&self, times: &mut [TimeSpec]) -> Result<(), Errno>
pub fn poll(&self, events: PollEvent) -> Result<PollEvent, Errno>
Source§impl File
impl File
pub fn readat(&self, offset: usize, buffer: &mut [u8]) -> Result<usize, Errno>
pub fn writeat(&self, offset: usize, buffer: &[u8]) -> Result<usize, Errno>
pub fn read(&self, buffer: &mut [u8]) -> Result<usize, Errno>
pub fn write(&self, buffer: &[u8]) -> Result<usize, Errno>
pub async fn async_read(&self, buffer: &mut [u8]) -> Result<usize, Errno>
pub async fn async_write(&self, buffer: &[u8]) -> Result<usize, Errno>
pub fn seek(&self, seek_from: SeekFrom) -> Result<usize, Errno>
Trait Implementations§
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dst: *mut u8)
unsafe fn clone_to_uninit(&self, dst: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
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>
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)
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)
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 Twhere
T: Any + Send,
impl<T> DowncastSend for Twhere
T: Any + Send,
Source§fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>
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 Twhere
T: Any + Send + Sync,
impl<T> DowncastSync for Twhere
T: Any + Send + Sync,
Source§fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>
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>
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
.