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

Method cd

std/src/storage/mod.rs:515–534  ·  view source on GitHub ↗

Changes the current location. Given that we currently do not support directories, the location can only be of the forms `DRIVE:` or `DRIVE:/`.

(&mut self, location: &str)

Source from the content-addressed store, hash-verified

513 /// Given that we currently do not support directories, the location can only be of the forms
514 /// `DRIVE:` or `DRIVE:/`.
515 pub fn cd(&mut self, location: &str) -> io::Result<()> {
516 let location = Location::new(location)?;
517 if location.leaf_name().is_some() {
518 return Err(io::Error::new(io::ErrorKind::InvalidInput, "Cannot cd to a file"));
519 }
520
521 match location.drive {
522 Some(drive) => {
523 if !self.drives.contains_key(&drive) {
524 return Err(io::Error::new(
525 io::ErrorKind::AlreadyExists,
526 format!("Drive '{}' is not mounted", drive),
527 ));
528 }
529 self.current = drive;
530 Ok(())
531 }
532 None => Ok(()),
533 }
534 }
535
536 /// Returns the current location, used to resolve relative paths.
537 pub fn cwd(&self) -> String {

Callers 13

setup_storageFunction · 0.80
execMethod · 0.80
test_dir_other_by_cwdFunction · 0.80
test_mount_listFunction · 0.80
test_unmount_okFunction · 0.80
setup_storageFunction · 0.80

Calls 1

leaf_nameMethod · 0.80