Commit bdc24d38 authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub

Merge pull request #32 from ids1024/bzip2

Support bzip2 extraction in tar
parents fdf2a839 5485b381
......@@ -86,6 +86,7 @@ filetime = "0.1.10"
termion = { git = "https://github.com/redox-os/termion.git", branch = "redox_termios" }
rust-lzma = "0.2"
tree_magic = "0.2"
bzip2 = { git = "https://github.com/ids1024/bzip2-rs", branch = "redox" }
[replace]
"filetime:0.1.10" = { git = "https://github.com/alexcrichton/filetime.git" }
......@@ -5,6 +5,7 @@ extern crate tree_magic;
extern crate lzma;
extern crate libflate;
extern crate filetime;
extern crate bzip2;
use std::{env, process};
use std::io::{stdin, stdout, stderr, copy, Error, ErrorKind, Result, Read, Write, BufReader};
......@@ -16,6 +17,7 @@ use std::str::FromStr;
use tar::{Archive, Builder, EntryType};
use lzma::LzmaReader;
use libflate::gzip::Decoder as GzipDecoder;
use bzip2::read::BzDecoder;
use filetime::FileTime;
fn create_inner<T: Write>(input: &str, ar: &mut Builder<T>) -> Result<()> {
......@@ -147,6 +149,8 @@ fn extract(tar: &Path, verbose: bool, strip: usize) -> Result<()> {
extract_inner(&mut Archive::new(GzipDecoder::new(file)
.map_err(|e| Error::new(ErrorKind::Other, e))?),
verbose, strip)
} else if mime == "application/x-bzip" {
extract_inner(&mut Archive::new(BzDecoder::new(file)), verbose, strip)
} else {
extract_inner(&mut Archive::new(file), verbose, strip)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment