pub fn parse(data: raw::header::Raw) -> Result<Self, BasicTarError> {
		// Check if we have an empty header
		if data.as_ref() == raw::header::raw().as_ref() {
			Err(BasicTarError::EmptyHeader)?
		}
		
		// Parse the basic tar header and verify the checksum
		let tar = raw::header::Header::from(data);
		Checksum::verify(&tar)?;
		
		// Decode the path
		let path = String::from_field(&tar.name)?;
		
		// Decode the mode, UID and GID
		let mode = Option::from_octal_field(&tar.mode)?;
		let uid = Option::from_octal_field(&tar.uid)?;
		let gid = Option::from_octal_field(&tar.gid)?;
		
		// Decode the size and the modification time
		let size = u64::from_octal_field(&tar.size)?;
		let mtime = Option::from_octal_field(&tar.mtime)?;
		
		// Decode link name and create the struct
		let linkname = Option::from_field(&tar.linkname)?;
		Ok(Self{ path, mode, uid, gid, size, typeflag: tar.typeflag[0], mtime, linkname })
	}
/// Parses a raw byte block into a classic tar header
Parses a raw byte block into a classic tar header
Parses a raw byte block into a classic tar header
pub fn parse(data: raw::header::Raw) -> Result<Self, BasicTarError> {
		// Check if we have an empty header
		if data.as_ref() == raw::header::raw().as_ref() {
			Err(BasicTarError::EmptyHeader)?
		}
		// Parse the basic tar header and verify the checksum
		let tar = raw::header::Header::from(data);
		Checksum::verify(&tar)?;
		// Decode the path
		let path = String::from_field(&tar.name)?;
		// Decode the mode, UID and GID
		let mode = Option::from_octal_field(&tar.mode)?;
		let uid = Option::from_octal_field(&tar.uid)?;
		let gid = Option::from_octal_field(&tar.gid)?;
		// Decode the size and the modification time
		let size = u64::from_octal_field(&tar.size)?;
		let mtime = Option::from_octal_field(&tar.mtime)?;
		// Decode link name and create the struct
		let linkname = Option::from_field(&tar.linkname)?;
		Ok(Self{ path, mode, uid, gid, size, typeflag: tar.typeflag[0], mtime, linkname })
	}
pub fn parse ( data : raw :: header :: Raw ) -> Result < Self , BasicTarError > { // Check if we have an empty header if data . as_ref ( ) == raw :: header :: raw ( ) . as_ref ( ) { Err ( BasicTarError :: EmptyHeader ) ? } // Parse the basic tar header and verify the checksum let tar = raw :: header :: Header :: from ( data ) ; Checksum :: verify ( & tar ) ? ; // Decode the path let path = String :: from_field ( & tar . name ) ? ; // Decode the mode, UID and GID let mode = Option :: from_octal_field ( & tar . mode ) ? ; let uid = Option :: from_octal_field ( & tar . uid ) ? ; let gid = Option :: from_octal_field ( & tar . gid ) ? ; // Decode the size and the modification time let size = u64 :: from_octal_field ( & tar . size ) ? ; let mtime = Option :: from_octal_field ( & tar . mtime ) ? ; // Decode link name and create the struct let linkname = Option :: from_field ( & tar . linkname ) ? ; Ok ( Self { path , mode , uid , gid , size , typeflag : tar . typeflag [ 0 ] , mtime , linkname } ) }
Parses a raw byte block into a classic tar header
Parses a raw byte block into a classic tar header
data
raw::header::Raw
data
raw::header::Raw