pub fn create_archive(
files: &[PathBuf],
archive_path: &Path,
format: ArchiveFormat,
) -> ArchiveResult<()>Expand description
Create an archive from a list of files and/or directories.
Creates a new archive containing the specified files and directories. Directories are added recursively with all their contents.
§Arguments
files- Paths to files and directories to include in the archivearchive_path- Path where the archive will be createdformat- The archive format to use
§Errors
Returns an error if:
- The destination already exists (
ArchiveError::DestinationExists) - Any source file cannot be read
- The archive cannot be written
§Note
Symlinks in source directories are currently skipped (not followed or stored).
§Example
use std::path::PathBuf;
use gravityfile_ops::{create_archive, ArchiveFormat};
create_archive(
&[PathBuf::from("src/"), PathBuf::from("Cargo.toml")],
&PathBuf::from("backup.tar.gz"),
ArchiveFormat::TarGz,
)?;