Archive Extraction

Overview

Support for extracting ZIP, TAR, and TAR.GZ archives with proper error handling and permission preservation.

Quick Example

use lighty_core::extract_archive;

#[tokio::main]
async fn main()  {
    extract_archive(
        "/tmp/archive.zip",
        "/tmp/extracted"
    ).await?;

    Ok(())
}

Supported Formats

Format
Extension
Compression

ZIP

.zip

Deflate

TAR

.tar

None

TAR.GZ

.tar.gz

Gzip

API Reference

extract_archive(archive_path, destination)

Extracts an archive to the specified destination.

Parameters:

  • archive_path: impl AsRef<Path> - Path to archive file

  • destination: impl AsRef<Path> - Output directory

Returns: Result<(), ExtractError>

Auto-Detection: Format is detected from file extension

Error Handling

Best Practices

1. Validate Archive Before Extraction

2. Clean Destination Directory

See Also

Last updated