pub fn extract_file(path: &Path, archive_type: &ArchiveType) -> Vec<PathBuf> {
    let file_name = path.file_name().unwrap();
    let output_dir = util::data_dir().join("temp").join(file_name);

    let file = open_file(path, false);

    let mut archive = match ZipArchive::new(file) {
        Ok(zip) => zip,
        Err(err) => {
            eprintln!(
                "       {} Unable to open {}. Reason: {}",
                Red.paint("error"),
                path.to_str().unwrap(),
                err.to_string()
            );
            process::exit(1);
        }
    };

    // Try to extract the archive.
    if let Err(err) = archive.extract(&output_dir) {
        eprintln!(
            "       {} Unable to extract {}. Reason: {}",
            Red.paint("error"),
            path.to_str().unwrap(),
            err.to_string()
        );
        process::exit(1);
    }

    match archive_type {
        ArchiveType::Aia => {
            let external_comps = output_dir.join("assets").join("external_comps");

            let base_dirs = match fs::read_dir(external_comps) {
                Ok(res) => res,
                Err(err) => {
                    eprintln!(
                        "       {} Unable to extract {}. Reason: {}",
                        Red.paint("error"),
                        path.to_str().unwrap(),
                        err.to_string()
                    );
                    process::exit(1);
                }
            };

            let mut res: Vec<PathBuf> = Vec::new();
            for el in base_dirs {
                let el = el.unwrap();
                res.push(el.path());
            }

            res
        }
        ArchiveType::Aix => [output_dir.join(ext_base_dir(archive))].into(),
    }
}
/// Extracts the given file and dumps the contents to a temporary directory.
/// Returns a vec of [PathBuf]s that corresponds to the base directories of
/// extensions.
Extracts the given file and dumps the contents to a temporary directory.
Returns a vec of [PathBuf]s that corresponds to the base directories of
extensions.
Extracts the given file and dumps the contents to a temporary directory . Returns a vec of [ PathBuf ] s that corresponds to the base directories of extensions .
pub fn extract_file(path: &Path, archive_type: &ArchiveType) -> Vec<PathBuf> {
    let file_name = path.file_name().unwrap();
    let output_dir = util::data_dir().join("temp").join(file_name);
    let file = open_file(path, false);
    let mut archive = match ZipArchive::new(file) {
        Ok(zip) => zip,
        Err(err) => {
            eprintln!(
                "       {} Unable to open {}. Reason: {}",
                Red.paint("error"),
                path.to_str().unwrap(),
                err.to_string()
            );
            process::exit(1);
        }
    };
    // Try to extract the archive.
    if let Err(err) = archive.extract(&output_dir) {
        eprintln!(
            "       {} Unable to extract {}. Reason: {}",
            Red.paint("error"),
            path.to_str().unwrap(),
            err.to_string()
        );
        process::exit(1);
    }
    match archive_type {
        ArchiveType::Aia => {
            let external_comps = output_dir.join("assets").join("external_comps");
            let base_dirs = match fs::read_dir(external_comps) {
                Ok(res) => res,
                Err(err) => {
                    eprintln!(
                        "       {} Unable to extract {}. Reason: {}",
                        Red.paint("error"),
                        path.to_str().unwrap(),
                        err.to_string()
                    );
                    process::exit(1);
                }
            };
            let mut res: Vec<PathBuf> = Vec::new();
            for el in base_dirs {
                let el = el.unwrap();
                res.push(el.path());
            }
            res
        }
        ArchiveType::Aix => [output_dir.join(ext_base_dir(archive))].into(),
    }
}
pub fn extract_file ( path : & Path , archive_type : & ArchiveType ) -> Vec < PathBuf > { let file_name = path . file_name ( ) . unwrap ( ) ; let output_dir = util :: data_dir ( ) . join ( " " ) . join ( file_name ) ; let file = open_file ( path , false ) ; let mut archive = match ZipArchive :: new ( file ) { Ok ( zip ) => zip , Err ( err ) => { eprintln ! ( " " Red paint ( " " ) path to_str ( ) unwrap ( ) err to_string ( ) ) ; process :: exit ( 1 ) ; } } ; // Try to extract the archive. if let Err ( err ) = archive . extract ( & output_dir ) { eprintln ! ( " " Red paint ( " " ) path to_str ( ) unwrap ( ) err to_string ( ) ) ; process :: exit ( 1 ) ; } match archive_type { ArchiveType :: Aia => { let external_comps = output_dir . join ( " " ) . join ( " " ) ; let base_dirs = match fs :: read_dir ( external_comps ) { Ok ( res ) => res , Err ( err ) => { eprintln ! ( " " Red paint ( " " ) path to_str ( ) unwrap ( ) err to_string ( ) ) ; process :: exit ( 1 ) ; } } ; let mut res : Vec < PathBuf > = Vec :: new ( ) ; for el in base_dirs { let el = el . unwrap ( ) ; res . push ( el . path ( ) ) ; } res } ArchiveType :: Aix => [ output_dir . join ( ext_base_dir ( archive ) ) ] . into ( ) , } }
Extracts the given file and dumps the contents to a temporary directory.
Extracts the given file and dumps the contents to a temporary directory .
path
&Path
archive_type
&ArchiveType
path
&Path
archive_type
&ArchiveType