No description
Find a file
2025-07-15 10:52:51 -04:00
.github/workflows Create flakehub-publish-tagged.yml 2025-07-15 10:51:30 -04:00
doc added cargo doc 2023-09-21 17:05:28 -04:00
nix improved derrivation to be idomatic 2025-06-28 21:03:02 -04:00
src wip 2025-06-28 20:57:35 -04:00
.gitignore forgot to fix .gitignore 2023-09-19 17:56:34 -04:00
Cargo.lock wip 2025-06-28 20:57:35 -04:00
Cargo.toml Bump ring from 0.16.20 to 0.17.12 2025-03-22 14:28:20 +00:00
CONTRIBUTORS.md Added CONTRIBUTORS.md 2023-09-19 18:14:01 -04:00
flake.lock added xz support 2023-09-02 15:11:48 -04:00
flake.nix enabled generic allow unfree for sanity 2025-06-28 21:03:33 -04:00
LICENSE added license 2023-09-21 17:34:50 -04:00
rar-license.txt added rar license file 2023-09-21 17:40:05 -04:00
README.md added rar license file 2023-09-21 17:40:05 -04:00
rust-toolchain.toml updated rust-toolchain to new toml fmt 2025-03-22 10:27:04 -04:00
windows_build_reqs.ps1 updated README.md 2023-09-21 05:03:51 -04:00

TLDR

Interface for developers and users to interact with many common archive formats.

Installation

install with Cargo:

  cargo build --release

Install with nix:

add the flake call the module

Install with windows

  • Install git
  • Install vcpkg
    git clone https://github.com/microsoft/vcpkg.git
    .\bootstrap-vcpkg.bat
  • Install liblzma via vcpkg
    vcpkg install liblzma:x64-windows-static-md
  • Build using:
    cargo build --release

Examples

to use the cli run sk_extract [ARCHIVES]

to use the library first run:

  cargo add sk_extract

then import the extractors you need and call the extractor fn with parameters for input_path and output_path:

use sk_extract::extractors::{
    extract_zip,
    extract_rar,
    extract_tar,
    extract_lzma,
    extract_bz2,
    extract_tbz2,
    extract_tgz,
    extract_txz,
    extract_gz,
    extract_7z
};

            match extension {
                "zip" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if let Err(err) = extract_zip(&fname, &output_directory) {
                        println!("Error extracting ZIP: {}", err);
                        return 1;
                    }
                }
                "rar" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if let Err(err) = extract_rar(&fname, &output_directory) {
                        println!("Error extracting RAR: {}", err);
                        return 1;
                    }
                }
                "tar" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if let Err(err) = extract_tar(&fname,&output_directory) {
                        println!("Error extracting TAR: {}", err);
                        return 1;
                    }
                }
                "xz" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if fname.to_str().unwrap().ends_with(".tar.xz") {
                        if let Err(err) = extract_txz(&fname,&output_directory) {
                            println!("Error extracting TXZ: {}", err);
                            return 1;
                        }
                    } else {
                        if let Err(err) = fs::create_dir_all(&output_directory) {
                            println!("Error creating output directory: {}", err);
                            return 1;
                        }
                        if let Err(err) = extract_lzma(&fname, &output_directory) {
                            println!("Error extracting XZ: {}", err);
                            return 1;
                        }
                    }
                }
                "gz" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if fname.to_str().unwrap().ends_with(".tar.gz") {
                        if let Err(err) = extract_tgz(&fname,&output_directory) {
                            println!("Error extracting TGZ: {}", err);
                            return 1;
                        }
                    } else {
                        if let Err(err) = extract_gz(&fname, &output_directory) {
                            println!("Error extracting GZ: {}", err);
                            return 1;
                        }
                    }
                }
                "bz2" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if fname.to_str().unwrap().ends_with(".tar.bz2") {
                        if let Err(err) = extract_tbz2(&fname,&output_directory) {
                            println!("Error extracting TBZ2: {}", err);
                            return 1;
                        }
                    } else {
                        if let Err(err) = extract_bz2(&fname, &output_directory) {
                            println!("Error extracting BZ2: {}", err);
                            return 1;
                        }
                    }
                }
                "lzma" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if let Err(err) = extract_lzma(&fname, &output_directory) {
                        println!("Error extracting LZMA: {}", err);
                        return 1;
                    }
                }
                "7z" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if let Err(err) = extract_7z(&fname, &output_directory) {
                        println!("Error extracting 7Z: {}", err);
                        return 1;
                    }
                }
                "tbz2" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if let Err(err) = extract_tbz2(&fname,&output_directory) {
                        println!("Error extracting TBZ2: {}", err);
                        return 1;
                    }
                }
                "txz" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if let Err(err) = extract_txz(&fname,&output_directory) {
                        println!("Error extracting TXZ: {}", err);
                        return 1;
                    }
                }
                "tgz" => {
                    let output_directory = Path::new("output_directory"); // Change this to your desired output directory
                    if let Err(err) = fs::create_dir_all(&output_directory) {
                        println!("Error creating output directory: {}", err);
                        return 1;
                    }
                    if let Err(err) = extract_tgz(&fname,&output_directory) {
                        println!("Error extracting TGZ: {}", err);
                        return 1;
                    }
                }

Credits

Thanks to all of the wonderful library devs listed below that have helped the early bootstrapping of this project:

  • unrar.rs
  • zip
  • bzip2
  • flate2
  • rayon
  • rust-lzma
  • sevenz-rust
  • tar
  • serial_test Thanks to the dood sky who helped me with the nixery!

LICENSE:

This software is licensed under the MIT License except for any code that directly interacts with unrar which falls under it's gross license

TODO:

  • add support for the remaining filetypes