mirror of
https://github.com/xavo95/repak.git
synced 2025-01-18 10:54:38 +00:00
consume in builders
This commit is contained in:
parent
a15e3fe372
commit
8798e578f1
2 changed files with 13 additions and 9 deletions
|
@ -16,12 +16,12 @@ impl PakBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(feature = "encryption")]
|
#[cfg(feature = "encryption")]
|
||||||
pub fn key(&mut self, key: aes::Aes256) -> &mut Self {
|
pub fn key(mut self, key: aes::Aes256) -> Self {
|
||||||
self.key = super::Key::Some(key);
|
self.key = super::Key::Some(key);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
#[cfg(feature = "oodle")]
|
#[cfg(feature = "oodle")]
|
||||||
pub fn oodle(&mut self, oodle: fn() -> super::Decompress) -> &mut Self {
|
pub fn oodle(self, oodle: fn() -> super::Decompress) -> Self {
|
||||||
unsafe { super::OODLE = Some(once_cell::sync::Lazy::new(oodle)) }
|
unsafe { super::OODLE = Some(once_cell::sync::Lazy::new(oodle)) }
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ fn main() -> Result<(), repak::Error> {
|
||||||
fn info(aes_key: Option<aes::Aes256>, action: ActionInfo) -> Result<(), repak::Error> {
|
fn info(aes_key: Option<aes::Aes256>, action: ActionInfo) -> Result<(), repak::Error> {
|
||||||
let mut builder = repak::PakBuilder::new();
|
let mut builder = repak::PakBuilder::new();
|
||||||
if let Some(aes_key) = aes_key {
|
if let Some(aes_key) = aes_key {
|
||||||
builder.key(aes_key);
|
builder = builder.key(aes_key);
|
||||||
}
|
}
|
||||||
let pak = builder.reader(&mut BufReader::new(File::open(action.input)?))?;
|
let pak = builder.reader(&mut BufReader::new(File::open(action.input)?))?;
|
||||||
println!("mount point: {}", pak.mount_point());
|
println!("mount point: {}", pak.mount_point());
|
||||||
|
@ -192,7 +192,7 @@ fn info(aes_key: Option<aes::Aes256>, action: ActionInfo) -> Result<(), repak::E
|
||||||
fn list(aes_key: Option<aes::Aes256>, action: ActionList) -> Result<(), repak::Error> {
|
fn list(aes_key: Option<aes::Aes256>, action: ActionList) -> Result<(), repak::Error> {
|
||||||
let mut builder = repak::PakBuilder::new();
|
let mut builder = repak::PakBuilder::new();
|
||||||
if let Some(aes_key) = aes_key {
|
if let Some(aes_key) = aes_key {
|
||||||
builder.key(aes_key);
|
builder = builder.key(aes_key);
|
||||||
}
|
}
|
||||||
let pak = builder.reader(&mut BufReader::new(File::open(action.input)?))?;
|
let pak = builder.reader(&mut BufReader::new(File::open(action.input)?))?;
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ fn list(aes_key: Option<aes::Aes256>, action: ActionList) -> Result<(), repak::E
|
||||||
fn hash_list(aes_key: Option<aes::Aes256>, action: ActionHashList) -> Result<(), repak::Error> {
|
fn hash_list(aes_key: Option<aes::Aes256>, action: ActionHashList) -> Result<(), repak::Error> {
|
||||||
let mut builder = repak::PakBuilder::new();
|
let mut builder = repak::PakBuilder::new();
|
||||||
if let Some(aes_key) = aes_key {
|
if let Some(aes_key) = aes_key {
|
||||||
builder.key(aes_key);
|
builder = builder.key(aes_key);
|
||||||
}
|
}
|
||||||
let pak = builder.reader(&mut BufReader::new(File::open(&action.input)?))?;
|
let pak = builder.reader(&mut BufReader::new(File::open(&action.input)?))?;
|
||||||
|
|
||||||
|
@ -284,9 +284,11 @@ fn unpack(aes_key: Option<aes::Aes256>, action: ActionUnpack) -> Result<(), repa
|
||||||
for input in &action.input {
|
for input in &action.input {
|
||||||
let mut builder = repak::PakBuilder::new();
|
let mut builder = repak::PakBuilder::new();
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
builder.oodle(get_oodle::decompress);
|
{
|
||||||
|
builder = builder.oodle(get_oodle::decompress);
|
||||||
|
}
|
||||||
if let Some(aes_key) = aes_key.clone() {
|
if let Some(aes_key) = aes_key.clone() {
|
||||||
builder.key(aes_key);
|
builder = builder.key(aes_key);
|
||||||
}
|
}
|
||||||
let pak = builder.reader(&mut BufReader::new(File::open(input)?))?;
|
let pak = builder.reader(&mut BufReader::new(File::open(input)?))?;
|
||||||
let output = action
|
let output = action
|
||||||
|
@ -457,9 +459,11 @@ fn get(aes_key: Option<aes::Aes256>, args: ActionGet) -> Result<(), repak::Error
|
||||||
let mut reader = BufReader::new(File::open(&args.input)?);
|
let mut reader = BufReader::new(File::open(&args.input)?);
|
||||||
let mut builder = repak::PakBuilder::new();
|
let mut builder = repak::PakBuilder::new();
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
builder.oodle(get_oodle::decompress);
|
{
|
||||||
|
builder = builder.oodle(get_oodle::decompress);
|
||||||
|
}
|
||||||
if let Some(aes_key) = aes_key {
|
if let Some(aes_key) = aes_key {
|
||||||
builder.key(aes_key);
|
builder = builder.key(aes_key);
|
||||||
}
|
}
|
||||||
let pak = builder.reader(&mut reader)?;
|
let pak = builder.reader(&mut reader)?;
|
||||||
let mount_point = PathBuf::from(pak.mount_point());
|
let mount_point = PathBuf::from(pak.mount_point());
|
||||||
|
|
Loading…
Reference in a new issue