MCPcopy Create free account
hub / github.com/angular/angular / read

Method read

packages/compiler-cli/preprocessor/ng-analyze/src/fs.rs:491–531  ·  view source on GitHub ↗
(&self, path: &Path)

Source from the content-addressed store, hash-verified

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)]

Callers

nothing calls this directly

Calls 8

count_readFunction · 0.85
get_virtual_entryMethod · 0.80
is_allowedMethod · 0.80
getMethod · 0.65
unwrapMethod · 0.65
readMethod · 0.65
lenMethod · 0.45

Tested by

no test coverage detected