(
root_dir: &cap_std_ext::cap_std::fs::Dir,
output_path: Option<&Utf8Path>,
options: &ExportOptions,
)
| 53 | /// Export container filesystem as tar archive. |
| 54 | #[context("Exporting to tar")] |
| 55 | async fn export_tar( |
| 56 | root_dir: &cap_std_ext::cap_std::fs::Dir, |
| 57 | output_path: Option<&Utf8Path>, |
| 58 | options: &ExportOptions, |
| 59 | ) -> Result<()> { |
| 60 | let output: Box<dyn Write> = match output_path { |
| 61 | Some(path) => { |
| 62 | let file = File::create(path) |
| 63 | .with_context(|| format!("Failed to create output file: {}", path))?; |
| 64 | Box::new(file) |
| 65 | } |
| 66 | None => Box::new(io::stdout()), |
| 67 | }; |
| 68 | |
| 69 | let mut tar_builder = tar::Builder::new(output); |
| 70 | export_filesystem(&mut tar_builder, root_dir, options)?; |
| 71 | tar_builder.finish().context("Finalizing tar archive")?; |
| 72 | |
| 73 | Ok(()) |
| 74 | } |
| 75 | |
| 76 | fn export_filesystem<W: Write>( |
| 77 | tar_builder: &mut tar::Builder<W>, |
no test coverage detected