pub fn list_archive_files<R>(source: R) -> Result<Vec<String>>
where
    R: Read + Seek,
{
    let _utf8_guard = ffi::UTF8LocaleGuard::new();
    run_with_archive(
        Ownership::Ignore,
        source,
        |archive_reader, _, mut entry| unsafe {
            let mut file_list = Vec::new();
            #[allow(clippy::vec_init_then_push)]
            loop {
                match ffi::archive_read_next_header(archive_reader, &mut entry) {
                    ffi::ARCHIVE_OK => {
                        file_list.push(
                            CStr::from_ptr(ffi::archive_entry_pathname(entry))
                                .to_string_lossy()
                                .into_owned(),
                        );
                    }
                    ffi::ARCHIVE_EOF => return Ok(file_list),
                    _ => return Err(Error::from(archive_reader)),
                }
            }
        },
    )
}
/// Get all files in a archive using `source` as a reader.
/// # Example
///
/// ```no_run
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// use compress_tools::*;
/// use std::fs::File;
///
/// let mut source = File::open("tree.tar")?;
///
/// let file_list = list_archive_files(&mut source)?;
/// # Ok(())
/// # }
/// ```
Get all files in a archive using `source` as a reader.
Get all files in a archive using ` source ` as a reader .
pub fn list_archive_files<R>(source: R) -> Result<Vec<String>>
where
    R: Read + Seek,
{
    let _utf8_guard = ffi::UTF8LocaleGuard::new();
    run_with_archive(
        Ownership::Ignore,
        source,
        |archive_reader, _, mut entry| unsafe {
            let mut file_list = Vec::new();
            #[allow(clippy::vec_init_then_push)]
            loop {
                match ffi::archive_read_next_header(archive_reader, &mut entry) {
                    ffi::ARCHIVE_OK => {
                        file_list.push(
                            CStr::from_ptr(ffi::archive_entry_pathname(entry))
                                .to_string_lossy()
                                .into_owned(),
                        );
                    }
                    ffi::ARCHIVE_EOF => return Ok(file_list),
                    _ => return Err(Error::from(archive_reader)),
                }
            }
        },
    )
}
pub fn list_archive_files < R > ( source : R ) -> Result < Vec < String > > where R : Read + Seek , { let _utf8_guard = ffi :: UTF8LocaleGuard :: new ( ) ; run_with_archive ( Ownership :: Ignore , source , | archive_reader , _ , mut entry | unsafe { let mut file_list = Vec :: new ( ) ; # [ allow ( clippy vec_init_then_push ) ] loop { match ffi :: archive_read_next_header ( archive_reader , & mut entry ) { ffi :: ARCHIVE_OK => { file_list . push ( CStr :: from_ptr ( ffi :: archive_entry_pathname ( entry ) ) . to_string_lossy ( ) . into_owned ( ) , ) ; } ffi :: ARCHIVE_EOF => return Ok ( file_list ) , _ => return Err ( Error :: from ( archive_reader ) ) , } } } , ) }
Get all files in a archive using `source` as a reader.
Get all files in a archive using ` source ` as a reader .
source
R
source
R
example
None
fn main() -> result<(), box<dyn std::error::error>> {
use compress_tools::*;
use std::fs::File.

let mut source = File::open("tree.tar")?.

let file_list = list_archive_files(&mut source)?.
use compress_tools :: * ; use std :: fs :: File . let mut source = File :: open ( " tree . tar " ) ? . let file_list = list_archive_files ( &mut source ) ? .
ok(())
None
}
None