Struct tar::Header [−][src]
#[repr(C)]pub struct Header { /* fields omitted */ }
Expand description
Representation of the header of an entry in an archive
Implementations
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.
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.
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.
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.
Same as as_old
, but the mutable version.
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.
Same as as_ustar_mut
, but the mutable version.
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.
Same as as_gnu
, but the mutable version.
Treats the given byte slice as a header.
Panics if the length of the passed slice is not equal to 512.
Returns a view into this header as a byte array.
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.
Sets only the metadata relevant to the given HeaderMode in this header from the metadata argument provided.
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.
Returns the file size this header represents.
May return an error if the field is corrupted.
Encodes the size
argument into the size field of this header.
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.
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.
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. Will strip out any “.” path component, which signifies the current directory.
Note: This function does not support names over 100 bytes, or paths
over 255 bytes, even for formats that support longer names. Instead,
use Builder
methods to insert a long-name extension at the same time
as the file content.
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. Will strip out any “.” path component, which signifies the current directory.
To use GNU long link names, prefer instead crate::Builder::append_link
.
Sets the link name for this header without any transformation.
This function is like Self::set_link_name
but accepts an arbitrary byte array.
Hence it will not perform any canonicalization, such as replacing duplicate //
with /
.
Returns the mode bits for this file
May return an error if the field is corrupted.
Returns the value of the owner’s user ID field
May return an error if the field is corrupted.
Encodes the mtime
provided into this header.
Note that this time is typically a number of seconds passed since January 1, 1970.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Returns the type of file described by this header.
Sets the type of file that will be described by this header.
Returns the checksum field of this header.
May return an error if the field is corrupted.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Header
impl UnwindSafe for Header
Blanket Implementations
Mutably borrows from an owned value. Read more