[−][src]Struct delharc::header::LhaHeader
Semi-parsed LHA header.
Fields
level: u8
Header level: 0, 1, 2 or 3.
compression: [u8; 5]
Raw compression identifier.
compressed_size: u64
Compressed file size.
original_size: u64
Original file size.
filename: Box<[u8]>
A raw filename for level 1 or 0 headers, might be empty. Always being empty for levels 2 or 3.
In this instance the filename is stored in extra headers.
msdos_attrs: MsDosAttrs
MS-DOS attributes.
last_modified: u32
File's last modified date, format depends on the header level.
- Level 0 and 1 - MS-DOS format (no time zone).
- Level 2 and 3 - Unix timestamp (UTC).
The "last modified" timestamp can also be found in the extended area and extra headers, as well as other kinds of timestamps (- last access, created).
os_type: u8
A raw OS-TYPE.
file_crc: u16
Uncompressed file's CRC-16.
extended_area: Box<[u8]>
An extended area as raw bytes.
first_header_len: u32
The size of the first extra header.
extra_headers: Box<[u8]>
The extra headers' data.
Implementations
impl LhaHeader
[src]
pub fn read<R: Read>(rd: R) -> Result<Option<LhaHeader>>
[src]
Attempts to parse the LHA header. Returns Ok(Some(LhaHeader))
on success. Returns Ok(None)
if the end of archive marker (a 0
byte) was encountered.
The method validates all length and checksum fields of the header, but does not parse extra headers except:
- The "Common" header for validating the header's CRC-16 checksum.
- The "MS-DOS Attributes" header for reading MS-DOS attributes.
- The "MS-DOS Size" header for reading 64-bit file size.
All extra data is available as raw bytes and extra headers can be iterated with LhaHeader::iter_extra.
Instance methods can be further called on the parsed LhaHeader
struct to attempt to parse the
name and path of the file or other file's meta-data.
Errors
Returns an error from the underlying reading operations or because a malformed header was encountered.
pub fn iter_extra(&self) -> ExtraHeaderIterⓘImportant traits for ExtraHeaderIter<'a>
impl<'a> Iterator for ExtraHeaderIter<'a> type Item = &'a [u8];
[src]
Important traits for ExtraHeaderIter<'a>
impl<'a> Iterator for ExtraHeaderIter<'a> type Item = &'a [u8];
Returns an iterator that will iterate through extra headers, yielding the headers' raw data, excluding the next header length field.
Note
Each iterated raw header will have at least the size of 1 byte containing the header identifier.
impl LhaHeader
[src]
pub fn is_directory(&self) -> bool
[src]
Returns true
if the archive is an empty directory or a symbolic link.
pub fn parse_os_type(&self) -> Result<OsType, UnrecognizedOsType>
[src]
Attempts to parse the os_type
field and returns the OsType
enum on success.
pub fn parse_last_modified(&self) -> TimestampResult
[src]
Attempts to parse the extended area, extra headers and as a last resort the last_modified
field
taking into account the header level, and on success returns an instance of DateTime<Utc>
or a NaiveDateTime wrapped in an TimestampResult
enum.
pub fn compression_method(
&self
) -> Result<CompressionMethod, UnrecognizedCompressionMethod>
[src]
&self
) -> Result<CompressionMethod, UnrecognizedCompressionMethod>
Attempts to parse the compression
method field and returns the CompressionMethod
enum on success.
pub fn parse_pathname(&self) -> PathBuf
[src]
Attempts to parse the filename
field and searches the extended data for the directory and an
alternative file name and returns a PathBuf
.
The routine converts all non-ascii or control ascii characters to %xx
sequences and all system
specific directory separator characters to _
in file names.
Malicious path components, like ..
, .
or //
are stripped from the path names.
Notes
- If the path name could not be found the returned
PathBuf
will be empty. - Some filesystems may still reject the file or path names if path names include some forbidden
characters, e.g.
?
or*
inWindows
. - This method makes its best effort to return a non-absolute path name, however it is not guaranteed, so make sure the path is not absolute before creating a file or a directory.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for LhaHeader
impl Send for LhaHeader
impl Sync for LhaHeader
impl Unpin for LhaHeader
impl UnwindSafe for LhaHeader
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,