pub fn unpack_archive(
    reader: Box<dyn Read>,
    output_folder: &Path,
    question_policy: QuestionPolicy,
) -> crate::Result<Vec<PathBuf>> {
    let mut archive = tar::Archive::new(reader);

    let mut files_unpacked = vec![];
    for file in archive.entries()? {
        let mut file = file?;

        let file_path = output_folder.join(file.path()?);
        if file_path.exists() && !utils::user_wants_to_overwrite(&file_path, question_policy)? {
            continue;
        }

        if file_path.is_dir() {
            // ToDo: Maybe we should emphasise that `file_path` is a directory and everything inside it will be gone?
            fs::remove_dir_all(&file_path)?;
        } else if file_path.is_file() {
            fs::remove_file(&file_path)?;
        }

        file.unpack_in(output_folder)?;

        info!("{:?} extracted. ({})", output_folder.join(file.path()?), Bytes::new(file.size()));

        files_unpacked.push(file_path);
    }

    Ok(files_unpacked)
}
/// Unpacks the archive given by `archive` into the folder given by `into`.
Unpacks the archive given by `archive` into the folder given by `into`.
Unpacks the archive given by ` archive ` into the folder given by ` into ` .
pub fn unpack_archive(
    reader: Box<dyn Read>,
    output_folder: &Path,
    question_policy: QuestionPolicy,
) -> crate::Result<Vec<PathBuf>> {
    let mut archive = tar::Archive::new(reader);
    let mut files_unpacked = vec![];
    for file in archive.entries()? {
        let mut file = file?;
        let file_path = output_folder.join(file.path()?);
        if file_path.exists() && !utils::user_wants_to_overwrite(&file_path, question_policy)? {
            continue;
        }
        if file_path.is_dir() {
            // ToDo: Maybe we should emphasise that `file_path` is a directory and everything inside it will be gone?
            fs::remove_dir_all(&file_path)?;
        } else if file_path.is_file() {
            fs::remove_file(&file_path)?;
        }
        file.unpack_in(output_folder)?;
        info!("{:?} extracted. ({})", output_folder.join(file.path()?), Bytes::new(file.size()));
        files_unpacked.push(file_path);
    }
    Ok(files_unpacked)
}
pub fn unpack_archive ( reader : Box < dyn Read > , output_folder : & Path , question_policy : QuestionPolicy , ) -> crate :: Result < Vec < PathBuf > > { let mut archive = tar :: Archive :: new ( reader ) ; let mut files_unpacked = vec ! [ ] ; for file in archive . entries ( ) ? { let mut file = file ? ; let file_path = output_folder . join ( file . path ( ) ? ) ; if file_path . exists ( ) && ! utils :: user_wants_to_overwrite ( & file_path , question_policy ) ? { continue ; } if file_path . is_dir ( ) { // ToDo: Maybe we should emphasise that `file_path` is a directory and everything inside it will be gone? fs :: remove_dir_all ( & file_path ) ? ; } else if file_path . is_file ( ) { fs :: remove_file ( & file_path ) ? ; } file . unpack_in ( output_folder ) ? ; info ! ( " " output_folder join ( file path ( ) ) Bytes new ( file size ( ) ) ) ; files_unpacked . push ( file_path ) ; } Ok ( files_unpacked ) }
Unpacks the archive given by `archive` into the folder given by `into`.
Unpacks the archive given by ` archive ` into the folder given by ` into ` .
reader
Box<dyn Read>
output_folder
&Path
question_policy
QuestionPolicy
reader
Box<dyn Read>
output_folder
&Path
question_policy
QuestionPolicy