(&self, path: &Path)
| 28 | } |
| 29 | |
| 30 | fn prepare_path(&self, path: &Path) -> virtual_fs::Result<PathBuf> { |
| 31 | let path = normalize_path(path); |
| 32 | |
| 33 | if matches!(path.components().next(), Some(Component::Prefix(..))) { |
| 34 | return Err(FsError::InvalidInput); |
| 35 | } |
| 36 | |
| 37 | if self.root != Path::new("/") && path.starts_with(&self.root) { |
| 38 | return Err(FsError::InvalidInput); |
| 39 | } |
| 40 | |
| 41 | let path = path.strip_prefix("/").unwrap_or(&path); |
| 42 | let path = self.root.join(path); |
| 43 | |
| 44 | debug_assert!(path.starts_with(&self.root)); |
| 45 | Ok(path) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | impl virtual_fs::FileSystem for SyncHostFileSystem { |
no test coverage detected