Skip to main content

TarFS

Struct TarFS 

Source
pub struct TarFS { /* private fields */ }

Implementations§

Source§

impl TarFS

Source

pub fn from_device(device: impl Device + 'static) -> Option<TarFS>

Examples found in repository?
examples/dump.rs (line 13)
4fn main() {
5    let filename = match std::env::args().skip(1).next() {
6        Some(f) => f,
7        None => {
8            eprintln!("Please provide the name of a file.");
9            std::process::exit(1);    
10        },
11    };
12
13    let fs = TarFS::from_device(FileDevice(File::open(filename).unwrap()));
14
15    if fs.is_none() {
16        println!("Failed to open TAR file.");
17        return;
18    }
19
20    let mut fs = fs.unwrap();
21
22    let ents = fs.list();
23    
24    for i in ents {
25        let i = i.unwrap();
26        
27        println!("{:40} - {:12} bytes", &i.name, i.size);
28    }
29}
Source

pub fn get_entries<'a>(&'a mut self) -> EntryIter<'a>

Source

pub fn list<'a>(&'a mut self) -> EntityIter<'a>

Examples found in repository?
examples/dump.rs (line 22)
4fn main() {
5    let filename = match std::env::args().skip(1).next() {
6        Some(f) => f,
7        None => {
8            eprintln!("Please provide the name of a file.");
9            std::process::exit(1);    
10        },
11    };
12
13    let fs = TarFS::from_device(FileDevice(File::open(filename).unwrap()));
14
15    if fs.is_none() {
16        println!("Failed to open TAR file.");
17        return;
18    }
19
20    let mut fs = fs.unwrap();
21
22    let ents = fs.list();
23    
24    for i in ents {
25        let i = i.unwrap();
26        
27        println!("{:40} - {:12} bytes", &i.name, i.size);
28    }
29}
Source

pub fn list_by_path(&mut self, path: &str) -> Result<Vec<Entity>>

Source

pub fn list_by_path_shallow(&mut self, path: &str) -> Result<Vec<Entity>>

Source

pub fn find_file(&mut self, path: &str) -> Result<Entity>

Source

pub fn read_file_by_entity( &mut self, entity: &Entity, position: usize, output: &mut [u8], ) -> Result<usize>

Source

pub fn read_file( &mut self, path: &str, position: usize, output: &mut [u8], ) -> Result<usize>

Source

pub fn read_entire_file(&mut self, path: &str) -> Result<Vec<u8>>

Source

pub fn read_to_string(&mut self, path: &str) -> Result<String>

Auto Trait Implementations§

§

impl Freeze for TarFS

§

impl !RefUnwindSafe for TarFS

§

impl !Send for TarFS

§

impl !Sync for TarFS

§

impl Unpin for TarFS

§

impl !UnwindSafe for TarFS

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.