VirtualFileSystem

Struct VirtualFileSystem 

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

Virtual filesystem manager for lessons

Implementations§

Source§

impl VirtualFileSystem

Source

pub fn new(lesson_id: &str, session_id: &str) -> Result<Self>

Create a new virtual filesystem for a lesson

Source

pub fn resolve_path(&self, virtual_path: &str) -> PathBuf

Get the real filesystem path for a virtual path

Source

pub fn get_current_dir(&self) -> &Path

Get current directory (virtual path)

Source

pub fn get_current_dir_real(&self) -> PathBuf

Get current directory (real filesystem path)

Source

pub fn change_directory(&mut self, path: &str) -> Result<String>

Change directory (returns new virtual path)

Source

pub fn list_directory(&self, path: Option<&str>) -> Result<Vec<DirEntry>>

List directory contents

Source

pub fn get_tree(&self, max_depth: usize) -> Vec<TreeNode>

Get directory tree structure

Source

pub fn read_file(&self, path: &str) -> Result<String>

Read file contents (cat command)

Source

pub fn create_directory(&self, path: &str, parents: bool) -> Result<()>

Create directory (mkdir command)

Source

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

Create or update file (touch command)

Source

pub fn remove(&self, path: &str, recursive: bool, force: bool) -> Result<()>

Remove file or directory (rm command)

Source

pub fn move_item(&self, source: &str, destination: &str) -> Result<()>

Move or rename file/directory (mv command)

Source

pub fn copy( &self, source: &str, destination: &str, recursive: bool, ) -> Result<()>

Copy file or directory (cp command)

Source

pub fn write_file(&self, path: &str, content: &str, append: bool) -> Result<()>

Write content to file (for echo redirection, etc.)

Source

pub fn cleanup(&self) -> Result<()>

Clean up virtual filesystem

Trait Implementations§

Source§

impl Drop for VirtualFileSystem

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.