Skip to content

Commit

Permalink
7zx
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchrisster committed Sep 20, 2023
1 parent 4a450be commit d415acc
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::{Arg, App};
use log::debug;
use log::info;
use sevenzip::Archive;
use sevenzipx::{list_7z_contents, extract_7z_contents_to};
// use log::info;
use rand::seq::SliceRandom;
use std::collections::HashSet;
Expand Down Expand Up @@ -83,7 +83,6 @@ fn main() -> Result<(), std::io::Error> {
.default_value("zip")
)
.get_matches();
.get_matches();

if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
Expand Down Expand Up @@ -239,20 +238,18 @@ fn main() -> Result<(), std::io::Error> {
}
}
}

let archive_type = matches.value_of("type").unwrap();
match archive_type {
"zip" => {
// Existing ZIP logic
},
"7z" => {
// New 7z logic using sevenzip-rs
let archive_path = std::path::Path::new(archive);
let mut archive = Archive::open(archive_path).unwrap();
let items = archive.list().unwrap();
for item in items {
// Extract or list items based on user's command-line arguments
// New 7z logic using sevenzipx
let contents = list_7z_contents(archive).unwrap();
for file in contents {
// Handle the file entries as needed
}
extract_7z_contents_to(archive, "./output_directory/").unwrap(); // Replace "./output_directory/" with the desired output directory
},
_ => {
eprintln!("Unsupported archive type: {}", archive_type);
Expand Down

0 comments on commit d415acc

Please sign in to comment.