mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-18 23:50:35 +00:00
style: cargo fmt
This commit is contained in:
parent
cd104a2377
commit
7e63526abc
@ -68,16 +68,20 @@ pub fn compress_files(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
Lz4 => Box::new(lz4_flex::frame::FrameEncoder::new(encoder).auto_finish()),
|
Lz4 => Box::new(lz4_flex::frame::FrameEncoder::new(encoder).auto_finish()),
|
||||||
Lzma => return Err(crate::Error::UnsupportedFormat {
|
Lzma => {
|
||||||
reason: "LZMA1 compression is not supported in ouch, use .xz instead.".to_string(),
|
return Err(crate::Error::UnsupportedFormat {
|
||||||
}),
|
reason: "LZMA1 compression is not supported in ouch, use .xz instead.".to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
Xz => Box::new(liblzma::write::XzEncoder::new(
|
Xz => Box::new(liblzma::write::XzEncoder::new(
|
||||||
encoder,
|
encoder,
|
||||||
level.map_or(6, |l| (l as u32).clamp(0, 9)),
|
level.map_or(6, |l| (l as u32).clamp(0, 9)),
|
||||||
)),
|
)),
|
||||||
Lzip => return Err(crate::Error::UnsupportedFormat {
|
Lzip => {
|
||||||
reason: "Lzip compression is not supported in ouch.".to_string(),
|
return Err(crate::Error::UnsupportedFormat {
|
||||||
}),
|
reason: "Lzip compression is not supported in ouch.".to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
Snappy => Box::new(
|
Snappy => Box::new(
|
||||||
gzp::par::compress::ParCompress::<gzp::snap::Snap>::builder()
|
gzp::par::compress::ParCompress::<gzp::snap::Snap>::builder()
|
||||||
.compression_level(gzp::par::compress::Compression::new(
|
.compression_level(gzp::par::compress::Compression::new(
|
||||||
|
@ -128,8 +128,9 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
|
|||||||
Box::new(bzip3::read::Bz3Decoder::new(decoder)?)
|
Box::new(bzip3::read::Bz3Decoder::new(decoder)?)
|
||||||
}
|
}
|
||||||
Lz4 => Box::new(lz4_flex::frame::FrameDecoder::new(decoder)),
|
Lz4 => Box::new(lz4_flex::frame::FrameDecoder::new(decoder)),
|
||||||
Lzma => Box::new(liblzma::read::XzDecoder::new_stream(decoder,
|
Lzma => Box::new(liblzma::read::XzDecoder::new_stream(
|
||||||
liblzma::stream::Stream::new_lzma_decoder(u64::MAX).unwrap()
|
decoder,
|
||||||
|
liblzma::stream::Stream::new_lzma_decoder(u64::MAX).unwrap(),
|
||||||
)),
|
)),
|
||||||
Xz => Box::new(liblzma::read::XzDecoder::new(decoder)),
|
Xz => Box::new(liblzma::read::XzDecoder::new(decoder)),
|
||||||
Lzip => Box::new(liblzma::read::XzDecoder::new_stream(
|
Lzip => Box::new(liblzma::read::XzDecoder::new_stream(
|
||||||
|
@ -86,7 +86,7 @@ pub enum CompressionFormat {
|
|||||||
Bzip3,
|
Bzip3,
|
||||||
/// .lz4
|
/// .lz4
|
||||||
Lz4,
|
Lz4,
|
||||||
/// .xz
|
/// .xz
|
||||||
Xz,
|
Xz,
|
||||||
/// .lzma
|
/// .lzma
|
||||||
Lzma,
|
Lzma,
|
||||||
|
@ -136,10 +136,7 @@ pub fn try_infer_extension(path: &Path) -> Option<Extension> {
|
|||||||
buf.starts_with(b"BZ3v1")
|
buf.starts_with(b"BZ3v1")
|
||||||
}
|
}
|
||||||
fn is_lzma(buf: &[u8]) -> bool {
|
fn is_lzma(buf: &[u8]) -> bool {
|
||||||
buf.len() >= 14
|
buf.len() >= 14 && buf[0] == 0x5d && (buf[12] == 0x00 || buf[12] == 0xff) && buf[13] == 0x00
|
||||||
&& buf[0] == 0x5d
|
|
||||||
&& (buf[12] == 0x00 || buf[12] == 0xff)
|
|
||||||
&& buf[13] == 0x00
|
|
||||||
}
|
}
|
||||||
fn is_xz(buf: &[u8]) -> bool {
|
fn is_xz(buf: &[u8]) -> bool {
|
||||||
buf.starts_with(&[0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])
|
buf.starts_with(&[0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])
|
||||||
|
@ -17,8 +17,7 @@ fn sanity_check_through_mime() {
|
|||||||
write_random_content(test_file, &mut SmallRng::from_entropy());
|
write_random_content(test_file, &mut SmallRng::from_entropy());
|
||||||
|
|
||||||
let formats = [
|
let formats = [
|
||||||
"7z", "tar", "zip", "tar.gz", "tgz", "tbz", "tbz2", "txz", "tzst", "tar.bz", "tar.bz2",
|
"7z", "tar", "zip", "tar.gz", "tgz", "tbz", "tbz2", "txz", "tzst", "tar.bz", "tar.bz2", "tar.xz", "tar.zst",
|
||||||
"tar.xz", "tar.zst",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let expected_mimes = [
|
let expected_mimes = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user