diff options
Diffstat (limited to 'cli/standalone/virtual_fs.rs')
-rw-r--r-- | cli/standalone/virtual_fs.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cli/standalone/virtual_fs.rs b/cli/standalone/virtual_fs.rs index c96aed143..ee870611b 100644 --- a/cli/standalone/virtual_fs.rs +++ b/cli/standalone/virtual_fs.rs @@ -92,9 +92,7 @@ impl VfsBuilder { if file_type.is_dir() { self.add_dir_recursive_internal(&path)?; } else if file_type.is_file() { - let file_bytes = std::fs::read(&path) - .with_context(|| format!("Reading {}", path.display()))?; - self.add_file(&path, file_bytes)?; + self.add_file_at_path(&path)?; } else if file_type.is_symlink() { let target = util::fs::canonicalize_path(&path) .with_context(|| format!("Reading symlink {}", path.display()))?; @@ -163,6 +161,12 @@ impl VfsBuilder { Ok(current_dir) } + pub fn add_file_at_path(&mut self, path: &Path) -> Result<(), AnyError> { + let file_bytes = std::fs::read(path) + .with_context(|| format!("Reading {}", path.display()))?; + self.add_file(path, file_bytes) + } + fn add_file(&mut self, path: &Path, data: Vec<u8>) -> Result<(), AnyError> { log::debug!("Adding file '{}'", path.display()); let checksum = util::checksum::gen(&[&data]); |