mirror of
https://github.com/pcvolkmer/osc-variant.git
synced 2025-04-19 19:56:50 +00:00
Add optional destination dir for OSB file extraction
This commit is contained in:
parent
f851e9c424
commit
1f5ec80cc6
@ -111,5 +111,7 @@ pub enum SubCommand {
|
||||
help = "Passwort der OSB-Datei (Optional)"
|
||||
)]
|
||||
password: Option<String>,
|
||||
#[arg(short = 'd', help = "Zielverzeichnis (Optional)")]
|
||||
dir: Option<String>,
|
||||
},
|
||||
}
|
||||
|
14
src/main.rs
14
src/main.rs
@ -259,11 +259,19 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
};
|
||||
}
|
||||
#[cfg(feature = "unzip-osb")]
|
||||
SubCommand::UnzipOsb { file, password } => {
|
||||
SubCommand::UnzipOsb {
|
||||
file,
|
||||
password,
|
||||
dir,
|
||||
} => {
|
||||
use crate::unzip_osb::unzip_osb;
|
||||
match password {
|
||||
Some(password) => unzip_osb_using_password(file.as_str(), password.as_str()),
|
||||
None => unzip_osb(file.as_str()),
|
||||
Some(password) => unzip_osb_using_password(
|
||||
file.as_str(),
|
||||
dir.unwrap_or_default().as_str(),
|
||||
password.as_str(),
|
||||
),
|
||||
None => unzip_osb(file.as_str(), dir.unwrap_or_default().as_str()),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
use console::style;
|
||||
use deob::deobfuscate;
|
||||
use std::path::Path;
|
||||
use std::{fs, io};
|
||||
|
||||
macro_rules! started {
|
||||
@ -48,7 +49,7 @@ macro_rules! error {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn unzip_osb_using_password(path: &str, password: &str) {
|
||||
pub fn unzip_osb_using_password(path: &str, dir: &str, password: &str) {
|
||||
println!("Entpacke OSB-Datei {}\n", style(path).yellow());
|
||||
|
||||
let file = match fs::File::open(path) {
|
||||
@ -87,7 +88,7 @@ pub fn unzip_osb_using_password(path: &str, password: &str) {
|
||||
};
|
||||
|
||||
let outpath = match file.enclosed_name() {
|
||||
Some(path) => path.to_owned(),
|
||||
Some(path) => Path::new(dir).join(path.to_owned()),
|
||||
None => continue,
|
||||
};
|
||||
|
||||
@ -129,6 +130,6 @@ pub fn unzip_osb_using_password(path: &str, password: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unzip_osb(path: &str) {
|
||||
unzip_osb_using_password(path, deobfuscate(env!("OSB_KEY").trim()).as_str());
|
||||
pub fn unzip_osb(path: &str, dir: &str) {
|
||||
unzip_osb_using_password(path, dir, deobfuscate(env!("OSB_KEY").trim()).as_str());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user