implement file insertion

This commit is contained in:
Jean-Marie Mineau 2024-01-22 14:22:28 +01:00
parent 7b6a5980c8
commit 0f5764c340
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
4 changed files with 98 additions and 17 deletions

View file

@ -35,6 +35,29 @@ pub mod general_purpose_flags {
pub const MASK_ENCRYPTED_CENTRAL_DIR: u16 = 1 << 13;
}
pub mod external_file_attributes {
pub const FIFO_FILE: u32 = 0b00010000 << 24;
// #define S_IFCHR 0020000 /* character special */ ?
pub const DIR_FILE: u32 = 0b01000000 << 24;
// #define S_IFBLK 0060000 /* block special */ ?
pub const SYMBOLIC_LINK_FILE: u32 = 0b10100000 << 24;
pub const SOCKET_FILE: u32 = 0b11000000 << 24;
pub const REGULAR_FILE: u32 = 0b10000000 << 24;
pub const MASK_FILE_TYPE: u32 = 0b11110000 << 24;
pub const SETUID: u32 = 0b0000100000000000 << 16;
pub const SETGID: u32 = 0b0000010000000000 << 16;
pub const STICKY: u32 = 0b0000001000000000 << 16;
pub const PERM_UR: u32 = 0b0000000100000000 << 16;
pub const PERM_UW: u32 = 0b0000000010000000 << 16;
pub const PERM_UX: u32 = 0b0000000001000000 << 16;
pub const PERM_GR: u32 = 0b0000000000100000 << 16;
pub const PERM_GW: u32 = 0b0000000000010000 << 16;
pub const PERM_GX: u32 = 0b0000000000001000 << 16;
pub const PERM_OR: u32 = 0b0000000000000100 << 16;
pub const PERM_OW: u32 = 0b0000000000000010 << 16;
pub const PERM_OX: u32 = 0b0000000000000001 << 16;
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FileInfo {
pub local_header: LocalFileHeader,
@ -46,6 +69,19 @@ impl FileInfo {
pub fn get_name(&self) -> String {
self.header.get_name()
}
pub fn set_name(&mut self, name: &str) {
self.header.set_name(name);
self.local_header.set_name(name);
}
pub fn external_file_attributes_set_flag(&mut self, flag: u32) {
self.header.external_file_attributes_set_flag(flag);
}
pub fn external_file_attributes_unset_flag(&mut self, flag: u32) {
self.header.external_file_attributes_unset_flag(flag);
}
pub fn set_file_type(&mut self, file_type: u32) {
self.header.set_file_type(file_type);
}
pub fn get_offset_local_header(&self) -> u64 {
self.header.get_offset_local_header()
}