Skip to main content

RamFS

Struct RamFS 

Source
pub struct RamFS { /* private fields */ }
Expand description

RamFS文件系统

管理inode分配和根目录

Implementations§

Source§

impl RamFS

Source

pub fn new() -> RamFS

Source

pub fn root(&self) -> Arc<Mutex<RamInode>> ⓘ

Source

pub fn create_file( &self, parent: Arc<Mutex<RamInode>>, name: String, ) -> Result<Arc<Mutex<RamInode>>, FileError>

在目录中创建文件

§参数
  • parent - 父目录inode
  • name - 文件名
§返回值

新文件的inode

Source

pub fn create_directory( &self, parent: Arc<Mutex<RamInode>>, name: String, ) -> Result<Arc<Mutex<RamInode>>, FileError>

在父目录中创建目录

Source

pub fn remove( &self, parent: Arc<Mutex<RamInode>>, name: &str, ) -> Result<(), FileError>

删除文件或目录

§注意

删除目录前必须为空

Source

pub fn lookup( &self, parent: Arc<Mutex<RamInode>>, name: &str, ) -> Result<Arc<Mutex<RamInode>>, FileError>

在目录中查找文件

Source

pub fn open_file( &self, inode: Arc<Mutex<RamInode>>, ) -> Result<RamFile, FileError>

打开文件用于读写

§错误
  • IsDirectory - 不能将目录作为文件打开

Trait Implementations§

Source§

impl Default for RamFS

Source§

fn default() -> RamFS

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for RamFS

§

impl !RefUnwindSafe for RamFS

§

impl !UnwindSafe for RamFS

§

impl Forget for RamFS

§

impl Send for RamFS

§

impl Sync for RamFS

§

impl Unpin for RamFS

§

impl UnsafeUnpin for RamFS

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.