[][src]Struct tar::Header

#[repr(C)]
pub struct Header { /* fields omitted */ }

Representation of the header of an entry in an archive

Methods

impl Header[src]

pub fn new_gnu() -> Header[src]

Creates a new blank GNU header.

The GNU style header is the default for this library and allows various extensions such as long path names, long link names, and setting the atime/ctime metadata attributes of files.

pub fn new_ustar() -> Header[src]

Creates a new blank UStar header.

The UStar style header is an extension of the original archive header which enables some extra metadata along with storing a longer (but not too long) path name.

UStar is also the basis used for pax archives.

pub fn new_old() -> Header[src]

Creates a new blank old header.

This header format is the original archive header format which all other versions are compatible with (e.g. they are a superset). This header format limits the path name limit and isn't able to contain extra metadata like atime/ctime.

pub fn as_old(&self) -> &OldHeader[src]

View this archive header as a raw "old" archive header.

This view will always succeed as all archive header formats will fill out at least the fields specified in the old header format.

pub fn as_old_mut(&mut self) -> &mut OldHeader[src]

Same as as_old, but the mutable version.

pub fn as_ustar(&self) -> Option<&UstarHeader>[src]

View this archive header as a raw UStar archive header.

The UStar format is an extension to the tar archive format which enables longer pathnames and a few extra attributes such as the group and user name.

This cast may not succeed as this function will test whether the magic/version fields of the UStar format have the appropriate values, returning None if they aren't correct.

pub fn as_ustar_mut(&mut self) -> Option<&mut UstarHeader>[src]

Same as as_ustar_mut, but the mutable version.

pub fn as_gnu(&self) -> Option<&GnuHeader>[src]

View this archive header as a raw GNU archive header.

The GNU format is an extension to the tar archive format which enables longer pathnames and a few extra attributes such as the group and user name.

This cast may not succeed as this function will test whether the magic/version fields of the GNU format have the appropriate values, returning None if they aren't correct.

pub fn as_gnu_mut(&mut self) -> Option<&mut GnuHeader>[src]

Same as as_gnu, but the mutable version.

pub fn from_byte_slice(bytes: &[u8]) -> &Header[src]

Treats the given byte slice as a header.

Panics if the length of the passed slice is not equal to 512.

pub fn as_bytes(&self) -> &[u8; 512][src]

Returns a view into this header as a byte array.

pub fn as_mut_bytes(&mut self) -> &mut [u8; 512][src]

Returns a view into this header as a byte array.

pub fn set_metadata(&mut self, meta: &Metadata)[src]

Blanket sets the metadata in this header from the metadata argument provided.

This is useful for initializing a Header from the OS's metadata from a file. By default, this will use HeaderMode::Complete to include all metadata.

pub fn set_metadata_in_mode(&mut self, meta: &Metadata, mode: HeaderMode)[src]

Sets only the metadata relevant to the given HeaderMode in this header from the metadata argument provided.

pub fn entry_size(&self) -> Result<u64>[src]

Returns the size of entry's data this header represents.

This is different from Header::size for sparse files, which have some longer size() but shorter entry_size(). The entry_size() listed here should be the number of bytes in the archive this header describes.

May return an error if the field is corrupted.

pub fn size(&self) -> Result<u64>[src]

Returns the file size this header represents.

May return an error if the field is corrupted.

pub fn set_size(&mut self, size: u64)[src]

Encodes the size argument into the size field of this header.

pub fn path(&self) -> Result<Cow<Path>>[src]

Returns the raw path name stored in this header.

This method may fail if the pathname is not valid unicode and this is called on a Windows platform.

Note that this function will convert any \ characters to directory separators.

pub fn path_bytes(&self) -> Cow<[u8]>[src]

Returns the pathname stored in this header as a byte array.

This function is guaranteed to succeed, but you may wish to call the path method to convert to a Path.

Note that this function will convert any \ characters to directory separators.

pub fn set_path<P: AsRef<Path>>(&mut self, p: P) -> Result<()>[src]

Sets the path name for this header.

This function will set the pathname listed in this header, encoding it in the appropriate format. May fail if the path is too long or if the path specified is not unicode and this is a Windows platform.

Returns the link name stored in this header, if any is found.

This method may fail if the pathname is not valid unicode and this is called on a Windows platform. Ok(None) being returned, however, indicates that the link name was not present.

Note that this function will convert any \ characters to directory separators.

Returns the link name stored in this header as a byte array, if any.

This function is guaranteed to succeed, but you may wish to call the link_name method to convert to a Path.

Note that this function will convert any \ characters to directory separators.

Sets the link name for this header.

This function will set the linkname listed in this header, encoding it in the appropriate format. May fail if the link name is too long or if the path specified is not unicode and this is a Windows platform.

pub fn mode(&self) -> Result<u32>[src]

Returns the mode bits for this file

May return an error if the field is corrupted.

pub fn set_mode(&mut self, mode: u32)[src]

Encodes the mode provided into this header.

pub fn uid(&self) -> Result<u64>[src]

Returns the value of the owner's user ID field

May return an error if the field is corrupted.

pub fn set_uid(&mut self, uid: u64)[src]

Encodes the uid provided into this header.

pub fn gid(&self) -> Result<u64>[src]

Returns the value of the group's user ID field

pub fn set_gid(&mut self, gid: u64)[src]

Encodes the gid provided into this header.

pub fn mtime(&self) -> Result<u64>[src]

Returns the last modification time in Unix time format

pub fn set_mtime(&mut self, mtime: u64)[src]

Encodes the mtime provided into this header.

Note that this time is typically a number of seconds passed since January 1, 1970.

pub fn username(&self) -> Result<Option<&str>, Utf8Error>[src]

Return the user name of the owner of this file.

A return value of Ok(Some(..)) indicates that the user name was present and was valid utf-8, Ok(None) indicates that the user name is not present in this archive format, and Err indicates that the user name was present but was not valid utf-8.

pub fn username_bytes(&self) -> Option<&[u8]>[src]

Returns the user name of the owner of this file, if present.

A return value of None indicates that the user name is not present in this header format.

pub fn set_username(&mut self, name: &str) -> Result<()>[src]

Sets the username inside this header.

This function will return an error if this header format cannot encode a user name or the name is too long.

pub fn groupname(&self) -> Result<Option<&str>, Utf8Error>[src]

Return the group name of the owner of this file.

A return value of Ok(Some(..)) indicates that the group name was present and was valid utf-8, Ok(None) indicates that the group name is not present in this archive format, and Err indicates that the group name was present but was not valid utf-8.

pub fn groupname_bytes(&self) -> Option<&[u8]>[src]

Returns the group name of the owner of this file, if present.

A return value of None indicates that the group name is not present in this header format.

pub fn set_groupname(&mut self, name: &str) -> Result<()>[src]

Sets the group name inside this header.

This function will return an error if this header format cannot encode a group name or the name is too long.

pub fn device_major(&self) -> Result<Option<u32>>[src]

Returns the device major number, if present.

This field may not be present in all archives, and it may not be correctly formed in all archives. Ok(Some(..)) means it was present and correctly decoded, Ok(None) indicates that this header format does not include the device major number, and Err indicates that it was present and failed to decode.

pub fn set_device_major(&mut self, major: u32) -> Result<()>[src]

Encodes the value major into the dev_major field of this header.

This function will return an error if this header format cannot encode a major device number.

pub fn device_minor(&self) -> Result<Option<u32>>[src]

Returns the device minor number, if present.

This field may not be present in all archives, and it may not be correctly formed in all archives. Ok(Some(..)) means it was present and correctly decoded, Ok(None) indicates that this header format does not include the device minor number, and Err indicates that it was present and failed to decode.

pub fn set_device_minor(&mut self, minor: u32) -> Result<()>[src]

Encodes the value minor into the dev_minor field of this header.

This function will return an error if this header format cannot encode a minor device number.

pub fn entry_type(&self) -> EntryType[src]

Returns the type of file described by this header.

pub fn set_entry_type(&mut self, ty: EntryType)[src]

Sets the type of file that will be described by this header.

pub fn cksum(&self) -> Result<u32>[src]

Returns the checksum field of this header.

May return an error if the field is corrupted.

pub fn set_cksum(&mut self)[src]

Sets the checksum field of this header based on the current fields in this header.

Trait Implementations

impl Clone for Header[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Header[src]

Auto Trait Implementations

impl Send for Header

impl Sync for Header

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]