Make a sub-directory
(&mut self, path: &str)
| 140 | |
| 141 | /// Make a sub-directory |
| 142 | fn make_dir(&mut self, path: &str) -> Result<Arc<RwLock<dyn DirLike + Send + Sync>>, syscalls::SyscallError> { |
| 143 | println!("[ramdisk] Making directory {}", path); |
| 144 | if path.contains(MAIN_SEP_STR) { |
| 145 | // Cannot contain separator |
| 146 | return Err(syscalls::SYSCALL_ERROR_PARAM); |
| 147 | } |
| 148 | if self.subdirs.contains_key(path) { |
| 149 | // Already exists |
| 150 | return Err(syscalls::SYSCALL_ERROR_EXISTS); |
| 151 | } |
| 152 | let new_dir = Arc::new(RwLock::new(Directory::new())); |
| 153 | self.subdirs.insert(String::from(path), new_dir.clone()); |
| 154 | Ok(new_dir) |
| 155 | } |
| 156 | /// Create a new file, returning a shared reference |
| 157 | fn make_file(&mut self, name: &str) -> Result<Arc<RwLock<dyn FileLike + Send + Sync>>, syscalls::SyscallError> { |
| 158 | println!("[ramdisk] Making file {}", name); |