MCPcopy Index your code
hub / github.com/endbasic/endbasic / mount_cloud_share

Function mount_cloud_share

repl/src/lib.rs:119–141  ·  view source on GitHub ↗

Resolves `username_path`, which must be of the form `user/path`, into an `AUTORUN` location.

(
    console: Rc<RefCell<dyn Console>>,
    storage: Rc<RefCell<Storage>>,
    username_path: &str,
)

Source from the content-addressed store, hash-verified

117
118/// Resolves `username_path`, which must be of the form `user/path`, into an `AUTORUN` location.
119pub fn mount_cloud_share(
120 console: Rc<RefCell<dyn Console>>,
121 storage: Rc<RefCell<Storage>>,
122 username_path: &str,
123) -> io::Result<String> {
124 let (fs_uri, path) = match username_path.split_once('/') {
125 Some((username, path)) => (format!("cloud://{}", username), format!("AUTORUN:/{}", path)),
126 None => {
127 return Err(io::Error::new(
128 io::ErrorKind::InvalidInput,
129 format!(
130 "Invalid program to run '{}'; must be of the form 'username/path'",
131 username_path
132 ),
133 ));
134 }
135 };
136
137 console.borrow_mut().print(&format!("Mounting {} as AUTORUN...", fs_uri))?;
138 storage.borrow_mut().mount("AUTORUN", &fs_uri)?;
139 storage.borrow_mut().cd("AUTORUN:/")?;
140 Ok(path)
141}
142
143/// Loads the program given by `path` from storage and executes it on the `machine`.
144pub async fn run_from_storage_path(

Callers 4

run_interactiveFunction · 0.85
safe_run_repl_loopMethod · 0.85

Calls 3

mountMethod · 0.80
cdMethod · 0.80
printMethod · 0.45

Tested by 2