Struct tar::Header [] [src]

pub struct Header {
    pub name: [u8; 100],
    pub mode: [u8; 8],
    pub owner_id: [u8; 8],
    pub group_id: [u8; 8],
    pub size: [u8; 12],
    pub mtime: [u8; 12],
    pub cksum: [u8; 8],
    pub link: [u8; 1],
    pub linkname: [u8; 100],
    pub ustar: [u8; 6],
    pub ustar_version: [u8; 2],
    pub owner_name: [u8; 32],
    pub group_name: [u8; 32],
    pub dev_major: [u8; 8],
    pub dev_minor: [u8; 8],
    pub prefix: [u8; 155],
    // some fields omitted
}

Representation of the header of a file in an archive

Fields

name: [u8; 100] mode: [u8; 8] owner_id: [u8; 8] group_id: [u8; 8] size: [u8; 12] mtime: [u8; 12] cksum: [u8; 8] link: [u8; 1] linkname: [u8; 100] ustar: [u8; 6] ustar_version: [u8; 2] owner_name: [u8; 32] group_name: [u8; 32] dev_major: [u8; 8] dev_minor: [u8; 8] prefix: [u8; 155]

Methods

impl Header
[src]

fn new() -> Header

Creates a new blank header ready to be filled in

fn set_metadata(&mut self, meta: &Metadata)

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.

fn size(&self) -> Result<u64>

Returns the file size this header represents.

May return an error if the field is corrupted.

fn set_size(&mut self, size: u64)

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

fn path(&self) -> Result<Cow<Path>>

Returns the pathname 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.

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

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.

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

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.

fn mode(&self) -> Result<u32>

Returns the mode bits for this file

May return an error if the field is corrupted.

fn set_mode(&mut self, mode: u32)

Encodes the mode provided into this header.

fn uid(&self) -> Result<u32>

Returns the value of the owner's user ID field

May return an error if the field is corrupted.

fn set_uid(&mut self, uid: u32)

Encodes the uid provided into this header.

fn gid(&self) -> Result<u32>

Returns the value of the group's user ID field

fn set_gid(&mut self, gid: u32)

Encodes the gid provided into this header.

fn mtime(&self) -> Result<u64>

Returns the last modification time in Unix time format

fn set_mtime(&mut self, mtime: u64)

Encodes the mtime provided into this header.

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

fn username(&self) -> Option<&str>

Return the username of the owner of this file, if present and if valid utf8

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

Returns the username of the owner of this file, if present

fn set_username(&mut self, name: &str) -> Result<()>

Sets the username inside this header.

May return an error if the name provided is too long.

fn groupname(&self) -> Option<&str>

Return the group name of the owner of this file, if present and if valid utf8

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

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

fn set_groupname(&mut self, name: &str) -> Result<()>

Sets the group name inside this header.

May return an error if the name provided is too long.

fn device_major(&self) -> Option<Result<u32>>

Returns the device major number, if present.

This field is only present in UStar archives. A value of None means that this archive is not a UStar archive, while a value of Some represents the attempt to decode the field in the header.

fn set_device_major(&mut self, major: u32)

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

fn device_minor(&self) -> Option<Result<u32>>

Returns the device minor number, if present.

This field is only present in UStar archives. A value of None means that this archive is not a UStar archive, while a value of Some represents the attempt to decode the field in the header.

fn set_device_minor(&mut self, minor: u32)

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

fn cksum(&self) -> Result<u32>

Returns the checksum field of this header.

May return an error if the field is corrupted.

fn set_cksum(&mut self)

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