diff --git a/Cargo.toml b/Cargo.toml index 1fc3168..b251309 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,3 +19,12 @@ sevenz-rust = "0.5.2" tar = "0.4.40" unrar = "0.5.1" zip = "0.6.6" + + +[[bin]] +name = "sk_extract_cli" +path = "src/main.rs" + +[lib] +name = "sk_extract_lib" +path = "src/lib/lib.rs" diff --git a/src/extensions.rs b/src/extensions.rs deleted file mode 100644 index b37be04..0000000 --- a/src/extensions.rs +++ /dev/null @@ -1,60 +0,0 @@ -pub enum Extensions{ - Zip, - Rar, - Tar, - Bz2, - Tbz2, - Tgz, - Txz, - Lzma, - Gz, - Xz, - Z, - Sevenz, - Arj, - Cab, - Chm, - Deb, - Dmg, - Iso, - Lzh, - Msi, - Rpm, - Udf, - Wim, - Xar, - Exe -}; - -pub struct File{ - filename: String; - extensions: ; - path: String; -}; - -pub struct Zip{}; -pub struct Rar{}; -pub struct Tar{}; -pub struct Bz2{}; -pub struct Tbz2{}; -pub struct Tgz{}; -pub struct Txz{}; -pub struct Lzma{}; -pub struct Gz{}; -pub struct Gz{}; -pub struct Xz{}; -pub struct Z{}; -pub struct Sevenz{}; -pub struct Arj{}; -pub struct Cab{}; -pub struct Chm{}; -pub struct Deb{}; -pub struct Dmg{}; -pub struct Iso{}; -pub struct Lzh{}; -pub struct Msi{}; -pub struct Rpm{}; -pub struct Udf{}; -pub struct Wim{}; -pub struct Xar{}; -pub struct Exe{}; diff --git a/src/extractors.rs b/src/lib/extractors.rs similarity index 95% rename from src/extractors.rs rename to src/lib/extractors.rs index bd9cb76..d7e1fab 100644 --- a/src/extractors.rs +++ b/src/lib/extractors.rs @@ -28,15 +28,8 @@ pub fn extract_zip(input_path: &Path, output_directory: &Path) -> Result<(), io: } if (*file.name()).ends_with('/') { - println!("File {} extracted to \"{}\"", i, full_outpath.display()); fs::create_dir_all(&full_outpath).unwrap(); } else { - println!( - "File {} extracted to \"{}\" ({} bytes)", - i, - full_outpath.display(), - file.size() - ); if let Some(p) = full_outpath.parent() { if !p.exists() { fs::create_dir_all(p).unwrap(); @@ -65,11 +58,6 @@ pub fn extract_rar(input_path: &Path, output_directory: &Path) -> Result<(), Box .open_for_processing() .unwrap(); while let Some(header) = archive.read_header()? { - println!( - "{} bytes: {}", - header.entry().unpacked_size, - header.entry().filename.to_string_lossy(), - ); // Create the complete output path by combining the output_directory and the filename let output_path = output_directory.join(&header.entry().filename); diff --git a/src/lib/lib.rs b/src/lib/lib.rs new file mode 100644 index 0000000..c7b7cbd --- /dev/null +++ b/src/lib/lib.rs @@ -0,0 +1 @@ +pub mod extractors; \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 774640f..4547906 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,19 +1,6 @@ -/* -TODO_3: setup rayon to handle parallel file processsing when passed -more than one file -*/ -/* -TODO_1: define supported extensions as structs and write an extensions enum -*/ -mod extractors; -// mod extensions; -// use extenstions::{ - // File, - // Extensions -// } use std::{path::Path, fs}; use rayon::prelude::*; -use extractors::{ +use sk_extract_lib::extractors::{ extract_zip, extract_rar, extract_tar,