MCPcopy Create free account
hub / github.com/bootc-dev/bootc / export_tar

Function export_tar

crates/lib/src/container_export.rs:55–74  ·  view source on GitHub ↗
(
    root_dir: &cap_std_ext::cap_std::fs::Dir,
    output_path: Option<&Utf8Path>,
    options: &ExportOptions,
)

Source from the content-addressed store, hash-verified

53/// Export container filesystem as tar archive.
54#[context("Exporting to tar")]
55async 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
76fn export_filesystem<W: Write>(
77 tar_builder: &mut tar::Builder<W>,

Callers 1

exportFunction · 0.85

Calls 2

export_filesystemFunction · 0.85
finishMethod · 0.80

Tested by

no test coverage detected