mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
Progress in Lzma compression
This commit is contained in:
parent
3fa939ac90
commit
f3dd4d9804
@ -9,4 +9,5 @@ pub use self::compressor::Entry;
|
|||||||
pub use self::tar::TarCompressor;
|
pub use self::tar::TarCompressor;
|
||||||
pub use self::zip::ZipCompressor;
|
pub use self::zip::ZipCompressor;
|
||||||
pub use self::bzip::BzipCompressor;
|
pub use self::bzip::BzipCompressor;
|
||||||
pub use self::tomemory::GzipCompressor;
|
pub use self::tomemory::GzipCompressor;
|
||||||
|
pub use self::tomemory::LzmaCompressor;
|
@ -8,6 +8,7 @@ use crate::utils::ensure_exists;
|
|||||||
use super::{Compressor, Entry};
|
use super::{Compressor, Entry};
|
||||||
|
|
||||||
pub struct GzipCompressor {}
|
pub struct GzipCompressor {}
|
||||||
|
pub struct LzmaCompressor {}
|
||||||
|
|
||||||
struct CompressorToMemory {}
|
struct CompressorToMemory {}
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ fn get_encoder<'a>(
|
|||||||
buffer,
|
buffer,
|
||||||
flate2::Compression::default(),
|
flate2::Compression::default(),
|
||||||
)),
|
)),
|
||||||
|
CompressionFormat::Lzma => Box::new(xz2::write::XzEncoder::new(buffer, 6)),
|
||||||
_other => unreachable!(),
|
_other => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,4 +96,19 @@ impl Compressor for GzipCompressor {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl Compressor for LzmaCompressor {
|
||||||
|
fn compress(&self, from: Entry) -> OuchResult<Vec<u8>> {
|
||||||
|
let format = CompressionFormat::Lzma;
|
||||||
|
match from {
|
||||||
|
Entry::Files(files) => Ok(
|
||||||
|
CompressorToMemory::compress_files(files, format)?
|
||||||
|
),
|
||||||
|
Entry::InMemory(file) => Ok(
|
||||||
|
CompressorToMemory::compress_file_in_memory(file, format)?
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ use crate::compressors::{
|
|||||||
ZipCompressor,
|
ZipCompressor,
|
||||||
GzipCompressor,
|
GzipCompressor,
|
||||||
BzipCompressor,
|
BzipCompressor,
|
||||||
|
LzmaCompressor
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::decompressors::{
|
use crate::decompressors::{
|
||||||
@ -73,7 +74,7 @@ impl Evaluator {
|
|||||||
CompressionFormat::Zip => Box::new(ZipCompressor {}),
|
CompressionFormat::Zip => Box::new(ZipCompressor {}),
|
||||||
CompressionFormat::Bzip => Box::new(BzipCompressor {}),
|
CompressionFormat::Bzip => Box::new(BzipCompressor {}),
|
||||||
CompressionFormat::Gzip => Box::new(GzipCompressor {}),
|
CompressionFormat::Gzip => Box::new(GzipCompressor {}),
|
||||||
_other => todo!()
|
CompressionFormat::Lzma => Box::new(LzmaCompressor {}),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok((first_compressor, second_compressor))
|
Ok((first_compressor, second_compressor))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user