explore files

This commit is contained in:
Jean-Marie Mineau 2024-01-16 18:23:58 +01:00
parent 0794aac016
commit 0d305fbe62
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
5 changed files with 189 additions and 47 deletions

View file

@ -1,7 +1,7 @@
use std::io::{SeekFrom, Write};
use crate::extra_fields::{ExtraField, GenericExtraField, Zip64ExtraField};
use crate::{cp437, Encoding, Signature};
use crate::{cp437, general_purpose_flags, Encoding, Signature};
use androscalpel_serializer::{ReadSeek, Result, Serializable};
#[derive(Debug, Clone, PartialEq, Eq)]
@ -9,7 +9,7 @@ pub struct FileHeader {
// signature: Signature(0x02014b50)
pub version_made_by: u16,
pub version_needed_to_extract: u16,
pub general_purpose_flag: u16,
pub general_purpose_flags: u16,
pub compression_method: u16,
pub last_mod_file_time: u16,
pub last_mod_file_data: u16,
@ -35,7 +35,7 @@ impl Serializable for FileHeader {
Self::SIGNATURE.serialize(output)?;
self.version_made_by.serialize(output)?;
self.version_needed_to_extract.serialize(output)?;
self.general_purpose_flag.serialize(output)?;
self.general_purpose_flags.serialize(output)?;
self.compression_method.serialize(output)?;
self.last_mod_file_time.serialize(output)?;
self.last_mod_file_data.serialize(output)?;
@ -69,7 +69,7 @@ impl Serializable for FileHeader {
assert_eq!(signature, Self::SIGNATURE); // TODO
let version_made_by = u16::deserialize(input)?;
let version_needed_to_extract = u16::deserialize(input)?;
let general_purpose_flag = u16::deserialize(input)?;
let general_purpose_flags = u16::deserialize(input)?;
let compression_method = u16::deserialize(input)?;
let last_mod_file_time = u16::deserialize(input)?;
let last_mod_file_data = u16::deserialize(input)?;
@ -90,7 +90,7 @@ impl Serializable for FileHeader {
let mut header = Self {
version_made_by,
version_needed_to_extract,
general_purpose_flag,
general_purpose_flags,
compression_method,
last_mod_file_time,
last_mod_file_data,
@ -181,10 +181,8 @@ impl FileHeader {
const SIGNATURE: Signature = Signature(0x02014b50);
const MIN_SIZE: usize = 4 + 6 * 2 + 4 * 3 + 5 * 2 + 4 * 2;
const MASK_UTF8_FILENAME: u16 = 1 << 11;
pub fn get_name_encoding(&self) -> Encoding {
if self.general_purpose_flag & Self::MASK_UTF8_FILENAME != 0 {
if self.general_purpose_flags & general_purpose_flags::MASK_UTF8_FILENAME != 0 {
Encoding::UTF8
} else {
Encoding::CP437