mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-30 00:51:34 +00:00
use the header
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
use crate::vfs::vfs_header::{header_from_bytes, ArchiveType, CompressionType};
|
||||
use std::collections::BTreeMap;
|
||||
use std::io;
|
||||
use std::io::Read;
|
||||
@ -19,6 +20,14 @@ impl Vfs {
|
||||
Vfs::from_tar_bytes(&decompressed_data[..])
|
||||
}
|
||||
|
||||
pub fn from_compressed_bytes(compressed_data_slice: &[u8]) -> Result<Self, failure::Error> {
|
||||
let data_bytes = &compressed_data_slice[4..];
|
||||
match header_from_bytes(compressed_data_slice)? {
|
||||
(_, CompressionType::ZSTD, ArchiveType::TAR) => Vfs::from_tar_zstd_bytes(data_bytes),
|
||||
(_, CompressionType::NONE, ArchiveType::TAR) => Vfs::from_tar_bytes(data_bytes),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a vfs from raw bytes in tar format
|
||||
pub fn from_tar_bytes<Reader: Read>(tar_bytes: Reader) -> Result<Self, failure::Error> {
|
||||
let mut ar = tar::Archive::new(tar_bytes);
|
||||
|
Reference in New Issue
Block a user