mirror of
https://github.com/xavo95/repak.git
synced 2025-01-18 19:04:07 +00:00
new_any should not consume the reader
This commit is contained in:
parent
524cd11e02
commit
0a90725d4a
2 changed files with 6 additions and 7 deletions
|
@ -84,14 +84,14 @@ fn decrypt(key: &Option<aes::Aes256>, bytes: &mut [u8]) -> Result<(), super::Err
|
|||
|
||||
impl PakReader {
|
||||
pub fn new_any<R: Read + Seek>(
|
||||
mut reader: R,
|
||||
reader: &mut R,
|
||||
key: Option<aes::Aes256>,
|
||||
) -> Result<Self, super::Error> {
|
||||
use std::fmt::Write;
|
||||
let mut log = "\n".to_owned();
|
||||
|
||||
for ver in Version::iter() {
|
||||
match Pak::read(&mut reader, ver, key.clone()) {
|
||||
match Pak::read(&mut *reader, ver, key.clone()) {
|
||||
Ok(pak) => {
|
||||
return Ok(PakReader { pak, key });
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ fn main() -> Result<(), repak::Error> {
|
|||
}
|
||||
|
||||
fn info(aes_key: Option<aes::Aes256>, action: ActionInfo) -> Result<(), repak::Error> {
|
||||
let pak = repak::PakReader::new_any(BufReader::new(File::open(action.input)?), aes_key)?;
|
||||
let pak = repak::PakReader::new_any(&mut BufReader::new(File::open(action.input)?), aes_key)?;
|
||||
println!("mount point: {}", pak.mount_point());
|
||||
println!("version: {}", pak.version());
|
||||
println!("version major: {}", pak.version().version_major());
|
||||
|
@ -186,7 +186,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> {
|
||||
let pak = repak::PakReader::new_any(BufReader::new(File::open(action.input)?), aes_key)?;
|
||||
let pak = repak::PakReader::new_any(&mut BufReader::new(File::open(action.input)?), aes_key)?;
|
||||
|
||||
let mount_point = PathBuf::from(pak.mount_point());
|
||||
let prefix = Path::new(&action.strip_prefix);
|
||||
|
@ -215,8 +215,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> {
|
||||
let mut reader = BufReader::new(File::open(&action.input)?);
|
||||
let pak = repak::PakReader::new_any(&mut reader, aes_key)?;
|
||||
let pak = repak::PakReader::new_any(&mut BufReader::new(File::open(&action.input)?), aes_key)?;
|
||||
|
||||
let mount_point = PathBuf::from(pak.mount_point());
|
||||
let prefix = Path::new(&action.strip_prefix);
|
||||
|
@ -271,7 +270,7 @@ fn hash_list(aes_key: Option<aes::Aes256>, action: ActionHashList) -> Result<(),
|
|||
const STYLE: &str = "[{elapsed_precise}] [{wide_bar}] {pos}/{len} ({eta})";
|
||||
|
||||
fn unpack(aes_key: Option<aes::Aes256>, action: ActionUnpack) -> Result<(), repak::Error> {
|
||||
let pak = repak::PakReader::new_any(BufReader::new(File::open(&action.input)?), aes_key)?;
|
||||
let pak = repak::PakReader::new_any(&mut BufReader::new(File::open(&action.input)?), aes_key)?;
|
||||
let output = action
|
||||
.output
|
||||
.map(PathBuf::from)
|
||||
|
|
Loading…
Reference in a new issue