pub fn extract_compressed(
kind: &TagKind,
compressed_tar: impl Read,
extract_destination: &Path,
) -> Result<PathBuf, Error>
Expand description
Extracts a compressed archive for a tag kind into the given extract_destination
and returns a PathBuf
to the
extracted location.
This method first decompresses compressed_tar
with flate2
or xz2
and then extracts it with tar
. The
decompression algorithm to use is decided by the provided kind
. If kind
is a TagKind::Proton
, gzip
decompression is used. If kind
is a TagKind::Wine {..}
xz decompression is used.
The difference in decompression is due to the fact that Proton GE releases use gzip compression and Wine GE releases use xz compressions.
§Examples
Extracting a Proton GE release (Proton GE releases use GZIP for compression).
ⓘ
let archive = std::fs::read("archive.tar.gz").unwrap();
let kind = TagKind::Proton;
let destination = PathBuf::from("/path/to/destination");
let extracted_location = archive::extract_tar(&kind, archive, destination);
Extracting a Wine GE release (Wine GE releases use XZ for compression).
ⓘ
let archive = std::fs::read("archive.tar.xz").unwrap();
let kind = TagKind::wine();
let destination = PathBuf::from("/path/to/destination");
let extracted_location = archive::extract_tar(&kind, archive, destination);
§Errors
This method returns a std::io::Error
when:
- any standard library IO error is encountered
- the
flat2
crate returns an error during decompression - the
xz2
crate returns an error during decompression - the
tar
crate returns an error during extraction