Ensure all directories in a path exist.
(&self, path: &str)
| 440 | |
| 441 | /// Ensure all directories in a path exist. |
| 442 | fn ensure_directories(&self, path: &str) { |
| 443 | let mut current = String::new(); |
| 444 | for component in path.split('/') { |
| 445 | if component.is_empty() { |
| 446 | continue; |
| 447 | } |
| 448 | if !current.is_empty() { |
| 449 | current.push('/'); |
| 450 | } |
| 451 | current.push_str(component); |
| 452 | |
| 453 | let mut files = self.files.borrow_mut(); |
| 454 | if !files.contains_key(¤t) { |
| 455 | let inode = Inode::new(self.next_inode.fetch_add(1, Ordering::SeqCst)); |
| 456 | files.insert(current.clone(), MemoryFile::new_directory(inode)); |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | /// Get entries within a directory. |
| 462 | #[allow(dead_code)] |
no test coverage detected