equal
deleted
inserted
replaced
36 &self, |
36 &self, |
37 relative_path: impl AsRef<Path>, |
37 relative_path: impl AsRef<Path>, |
38 ) -> Result<Vec<u8>, HgError> { |
38 ) -> Result<Vec<u8>, HgError> { |
39 let path = self.join(relative_path); |
39 let path = self.join(relative_path); |
40 std::fs::read(&path).when_reading_file(&path) |
40 std::fs::read(&path).when_reading_file(&path) |
|
41 } |
|
42 |
|
43 /// Returns `Ok(None)` if the file does not exist. |
|
44 pub fn try_read( |
|
45 &self, |
|
46 relative_path: impl AsRef<Path>, |
|
47 ) -> Result<Option<Vec<u8>>, HgError> { |
|
48 match self.read(relative_path) { |
|
49 Err(e) => match &e { |
|
50 HgError::IoError { error, .. } => match error.kind() { |
|
51 ErrorKind::NotFound => return Ok(None), |
|
52 _ => Err(e), |
|
53 }, |
|
54 _ => Err(e), |
|
55 }, |
|
56 Ok(v) => Ok(Some(v)), |
|
57 } |
41 } |
58 } |
42 |
59 |
43 fn mmap_open_gen( |
60 fn mmap_open_gen( |
44 &self, |
61 &self, |
45 relative_path: impl AsRef<Path>, |
62 relative_path: impl AsRef<Path>, |