mod detect;
mod mount;
mod tar;
mod types;
mod zip;
pub use detect::*;
pub use mount::*;
pub use types::*;
pub use tar::{
TarHeader, TarType, compression_stats, create_tar, create_tar_lz4, extract_all_lz4, parse_tar,
parse_tar_directory, parse_tar_lz4,
};
pub use zip::{
add_to_archive, create_zip, extract_all, extract_archive, extract_file, parse_zip,
parse_zip_directory,
};
use alloc::collections::BTreeMap;
use alloc::string::String;
use alloc::vec::Vec;
use lazy_static::lazy_static;
use spin::Mutex;
lazy_static! {
static ref ARCHIVE_CACHE: Mutex<BTreeMap<String, ArchiveMount>> = Mutex::new(BTreeMap::new());
}
pub struct Archive;
impl Archive {
pub fn open(path: &str) -> Result<ArchiveMount, ArchiveError> {
ArchiveMount::open(path)
}
pub fn is_archive(path: &str) -> bool {
detect_archive_type(path).is_some()
}
pub fn archive_type(path: &str) -> Option<ArchiveType> {
detect_archive_type(path)
}
pub fn create(path: &str, archive_type: ArchiveType) -> Result<ArchiveMount, ArchiveError> {
ArchiveMount::create(path, archive_type)
}
pub fn extract(archive_data: &[u8], target_dir: &str) -> Result<ExtractResult, ArchiveError> {
extract_archive(archive_data, target_dir)
}
pub fn add_files(archive_path: &str, files: &[(&str, &[u8])]) -> Result<Vec<u8>, ArchiveError> {
add_to_archive(archive_path, files)
}
}