pub fn create_tar_with_progress<P: AsRef<Path>, Q: AsRef<Path>>(
output: P,
sources: &[Q],
config: &CreationConfig,
progress: &mut dyn ProgressCallback,
) -> Result<CreationReport>Expand description
Creates an uncompressed TAR archive with progress reporting.
This function provides real-time progress updates during archive creation through callback functions. Useful for displaying progress bars or logging in interactive applications.
§Parameters
output: Path where the TAR archive will be createdsources: Slice of source paths to include in the archiveconfig: Configuration controlling filtering, permissions, and archiving behaviorprogress: Mutable reference to a progress callback implementation
§Progress Callbacks
The progress callback receives four types of events:
on_entry_start: Called before processing each file/directoryon_bytes_written: Called for each chunk of data written (typically every 64 KB)on_entry_complete: Called after successfully processing an entryon_complete: Called once when the entire archive is finished
Note: Callbacks are invoked frequently during large file processing. For better performance with very large files, consider batching updates.
§Examples
use exarch_core::ProgressCallback;
use exarch_core::creation::CreationConfig;
use exarch_core::creation::tar::create_tar_with_progress;
use std::path::Path;
struct SimpleProgress;
impl ProgressCallback for SimpleProgress {
fn on_entry_start(&mut self, path: &Path, total: usize, current: usize) {
println!("[{}/{}] Processing: {}", current, total, path.display());
}
fn on_bytes_written(&mut self, bytes: u64) {
// Called frequently - consider rate limiting
}
fn on_entry_complete(&mut self, path: &Path) {
println!("Completed: {}", path.display());
}
fn on_complete(&mut self) {
println!("Archive creation complete!");
}
}
let config = CreationConfig::default();
let mut progress = SimpleProgress;
let report = create_tar_with_progress(
Path::new("output.tar"),
&[Path::new("src")],
&config,
&mut progress,
)?;§Errors
Returns an error if:
- Source path does not exist
- Output file cannot be created
- I/O error during archive creation
- File metadata cannot be read