MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / create_dir

Function create_dir

euralios_std/src/fs.rs:468–495  ·  view source on GitHub ↗
(path: P)

Source from the content-addressed store, hash-verified

466}
467
468pub fn create_dir<P: AsRef<Path>>(path: P) -> Result<(), SyscallError> {
469 let path: &Path = path.as_ref();
470
471 // Get the directory's parent
472 let parent = match path.parent() {
473 Some(parent) => parent,
474 None => { return Err(syscalls::SYSCALL_ERROR_PARAM); }
475 };
476
477 // Get the final part of the path
478 let new_dir_name = match path.file_name() {
479 Some(name) => name,
480 None => { return Err(syscalls::SYSCALL_ERROR_PARAM); }
481 };
482
483 // Open the parent directory for modifying
484 let f = OpenOptions::new().write(true).open(parent)?;
485
486 // Send a MKDIR message
487 let bytes = new_dir_name.bytes();
488 match f.rcall(message::MKDIR,
489 (bytes.len() as u64).into(),
490 MemoryHandle::from_u8_slice(bytes).into()) {
491 Err((err, _)) => Err(err),
492 Ok((message::OK, _, _)) => Ok(()),
493 _ => Err(syscalls::SYSCALL_ERROR_PARAM)
494 }
495}
496
497/// Returns the canonical, absolute form of a path with all intermediate
498/// components normalized and symbolic links resolved.

Callers 2

mainFunction · 0.85
mkdirFunction · 0.85

Calls 8

parentMethod · 0.80
rcallMethod · 0.80
as_refMethod · 0.45
file_nameMethod · 0.45
openMethod · 0.45
writeMethod · 0.45
bytesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected