Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/vfs.rs @ 49485:ffd4b1f1c9cb
rhg: add sparse support
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Tue, 19 Jul 2022 15:37:45 +0200 |
parents | abeae090ce67 |
children | be019ac8c1e4 58074252db3c |
line wrap: on
line diff
--- a/rust/hg-core/src/vfs.rs Tue Jul 19 15:37:09 2022 +0200 +++ b/rust/hg-core/src/vfs.rs Tue Jul 19 15:37:45 2022 +0200 @@ -40,6 +40,23 @@ std::fs::read(&path).when_reading_file(&path) } + /// Returns `Ok(None)` if the file does not exist. + pub fn try_read( + &self, + relative_path: impl AsRef<Path>, + ) -> Result<Option<Vec<u8>>, HgError> { + match self.read(relative_path) { + Err(e) => match &e { + HgError::IoError { error, .. } => match error.kind() { + ErrorKind::NotFound => return Ok(None), + _ => Err(e), + }, + _ => Err(e), + }, + Ok(v) => Ok(Some(v)), + } + } + fn mmap_open_gen( &self, relative_path: impl AsRef<Path>,