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)
| 225 | /// view's own changes plus its parent chain). Returns the number of files |
| 226 | /// written. |
| 227 | pub fn materialize_view_to(&self, view: &str, dir: &Path) -> Result<usize, RepositoryError> { |
| 228 | std::fs::create_dir_all(dir)?; |
| 229 | |
| 230 | let mut count = 0usize; |
| 231 | for path in self.visible_file_paths(view)? { |
| 232 | let bytes = match self.get_file_content_on_view(&path, view)? { |
| 233 | Some(bytes) => bytes, |
| 234 | None => continue, |
| 235 | }; |
| 236 | let target = dir.join(&path); |
| 237 | if let Some(parent) = target.parent() { |
| 238 | std::fs::create_dir_all(parent)?; |
| 239 | } |
| 240 | std::fs::write(&target, &bytes)?; |
| 241 | count += 1; |
| 242 | } |
| 243 | |
| 244 | Ok(count) |
| 245 | } |
| 246 | |
| 247 | /// Produce a two-layer OCI image: a base layer (the `base_view` |
| 248 | /// materialized) plus a thin delta layer (files that differ on `view` |