Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,8 @@ pub enum TarFormat {
TarBz2,
#[strum(serialize = "tar.zst")]
TarZst,
#[strum(serialize = "tar")]
Tar,
#[strum(serialize = "zip")]
Zip,
#[strum(serialize = "7z")]
Expand All @@ -705,6 +707,7 @@ pub enum TarFormat {
impl TarFormat {
pub fn from_ext(ext: &str) -> Self {
match ext {
"tar" => TarFormat::Tar,
"gz" | "tgz" => TarFormat::TarGz,
"xz" | "txz" => TarFormat::TarXz,
"bz2" | "tbz2" => TarFormat::TarBz2,
Expand Down Expand Up @@ -877,12 +880,14 @@ fn open_tar(format: TarFormat, archive: &Path) -> Result<Box<dyn std::io::Read>>
TarFormat::TarXz => Box::new(xz2::read::XzDecoder::new(f)),
TarFormat::TarBz2 => Box::new(BzDecoder::new(f)),
TarFormat::TarZst => Box::new(zstd::stream::read::Decoder::new(f)?),
TarFormat::Tar => Box::new(f),
Comment thread
roele marked this conversation as resolved.
TarFormat::Zip => bail!("zip format not supported"),
TarFormat::SevenZip => bail!("7z format not supported"),
TarFormat::Auto => match archive.extension().and_then(|s| s.to_str()) {
Some("xz") => open_tar(TarFormat::TarXz, archive)?,
Some("bz2") => open_tar(TarFormat::TarBz2, archive)?,
Some("zst") => open_tar(TarFormat::TarZst, archive)?,
Some("tar") => open_tar(TarFormat::Tar, archive)?,
Some("zip") => bail!("zip format not supported"),
_ => open_tar(TarFormat::TarGz, archive)?,
},
Expand Down
Loading