(&self, path: &Path)
| 489 | } |
| 490 | |
| 491 | fn read(&self, path: &Path) -> Result<Vec<u8>> { |
| 492 | #[cfg(test)] |
| 493 | { |
| 494 | if let Some(&delay) = self.delays.read().unwrap().get(path) { |
| 495 | std::thread::sleep(std::time::Duration::from_millis(delay)); |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | if let Some(vf) = self.get_virtual_entry(path) { |
| 500 | if vf.is_dir { |
| 501 | return Err(Error::other("Is a directory")); |
| 502 | } |
| 503 | return Ok(vf.content.as_bytes().to_vec()); |
| 504 | } |
| 505 | |
| 506 | if self.is_allowed(path) { |
| 507 | if let Ok(content) = self.physical.read(path) { |
| 508 | count_read(content.len()); |
| 509 | return Ok(content); |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | // If direct lookup fails on both virtual and physical FS, check across rootDirs virtual merging |
| 514 | if let Some(resolved) = self.resolve_across_root_dirs(path) { |
| 515 | if let Some(vf) = self.get_virtual_entry(&resolved) { |
| 516 | if vf.is_dir { |
| 517 | return Err(Error::other("Is a directory")); |
| 518 | } |
| 519 | return Ok(vf.content.as_bytes().to_vec()); |
| 520 | } |
| 521 | if self.is_allowed(&resolved) { |
| 522 | let res = self.physical.read(&resolved); |
| 523 | if let Ok(content) = &res { |
| 524 | count_read(content.len()); |
| 525 | } |
| 526 | return res; |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | Err(Error::from(std::io::ErrorKind::NotFound)) |
| 531 | } |
| 532 | |
| 533 | fn read_to_string(&self, path: &Path) -> Result<String> { |
| 534 | #[cfg(test)] |
nothing calls this directly
no test coverage detected