Materialize a view's visible file content into `dir` (created if needed). Writes each visible file's bytes exactly as they appear on `view` (the view's own changes plus its parent chain). Returns the number of files written.
(&self, view: &str, dir: &Path)
| 203 | /// view's own changes plus its parent chain). Returns the number of files |
| 204 | /// written. |
| 205 | pub fn materialize_view_to(&self, view: &str, dir: &Path) -> Result<usize, RepositoryError> { |
| 206 | std::fs::create_dir_all(dir)?; |
| 207 | |
| 208 | let mut count = 0usize; |
| 209 | for path in self.visible_file_paths(view)? { |
| 210 | let bytes = match self.get_file_content_on_view(&path, view)? { |
| 211 | Some(bytes) => bytes, |
| 212 | None => continue, |
| 213 | }; |
| 214 | let target = dir.join(&path); |
| 215 | if let Some(parent) = target.parent() { |
| 216 | std::fs::create_dir_all(parent)?; |
| 217 | } |
| 218 | std::fs::write(&target, &bytes)?; |
| 219 | count += 1; |
| 220 | } |
| 221 | |
| 222 | Ok(count) |
| 223 | } |
| 224 | |
| 225 | /// Produce a two-layer OCI image: a base layer (the `base_view` |
| 226 | /// materialized) plus a thin delta layer (files that differ on `view` |