rlm@1: // Archive/Zip/Header.h rlm@1: rlm@1: #ifndef __ARCHIVE_ZIP_HEADER_H rlm@1: #define __ARCHIVE_ZIP_HEADER_H rlm@1: rlm@1: #include "../../../Common/Types.h" rlm@1: rlm@1: namespace NArchive { rlm@1: namespace NZip { rlm@1: rlm@1: namespace NSignature rlm@1: { rlm@1: extern UInt32 kLocalFileHeader; rlm@1: extern UInt32 kDataDescriptor; rlm@1: extern UInt32 kCentralFileHeader; rlm@1: extern UInt32 kEndOfCentralDir; rlm@1: extern UInt32 kZip64EndOfCentralDir; rlm@1: extern UInt32 kZip64EndOfCentralDirLocator; rlm@1: rlm@1: static const UInt32 kMarkerSize = 4; rlm@1: } rlm@1: rlm@1: const UInt32 kEcdSize = 22; rlm@1: const UInt32 kZip64EcdSize = 44; rlm@1: const UInt32 kZip64EcdLocatorSize = 20; rlm@1: /* rlm@1: struct CEndOfCentralDirectoryRecord rlm@1: { rlm@1: UInt16 ThisDiskNumber; rlm@1: UInt16 StartCentralDirectoryDiskNumber; rlm@1: UInt16 NumEntriesInCentaralDirectoryOnThisDisk; rlm@1: UInt16 NumEntriesInCentaralDirectory; rlm@1: UInt32 CentralDirectorySize; rlm@1: UInt32 CentralDirectoryStartOffset; rlm@1: UInt16 CommentSize; rlm@1: }; rlm@1: rlm@1: struct CEndOfCentralDirectoryRecordFull rlm@1: { rlm@1: UInt32 Signature; rlm@1: CEndOfCentralDirectoryRecord Header; rlm@1: }; rlm@1: */ rlm@1: rlm@1: namespace NFileHeader rlm@1: { rlm@1: /* rlm@1: struct CVersion rlm@1: { rlm@1: Byte Version; rlm@1: Byte HostOS; rlm@1: }; rlm@1: */ rlm@1: rlm@1: namespace NCompressionMethod rlm@1: { rlm@1: enum EType rlm@1: { rlm@1: kStored = 0, rlm@1: kShrunk = 1, rlm@1: kReduced1 = 2, rlm@1: kReduced2 = 3, rlm@1: kReduced3 = 4, rlm@1: kReduced4 = 5, rlm@1: kImploded = 6, rlm@1: kReservedTokenizing = 7, // reserved for tokenizing rlm@1: kDeflated = 8, rlm@1: kDeflated64 = 9, rlm@1: kPKImploding = 10, rlm@1: rlm@1: kBZip2 = 12, rlm@1: kLZMA = 14, rlm@1: kTerse = 18, rlm@1: kLz77 = 19, rlm@1: kJpeg = 0x60, rlm@1: kWavPack = 0x61, rlm@1: kPPMd = 0x62, rlm@1: kWzAES = 0x63 rlm@1: }; rlm@1: const int kNumCompressionMethods = 11; rlm@1: const Byte kMadeByProgramVersion = 20; rlm@1: rlm@1: const Byte kDeflateExtractVersion = 20; rlm@1: const Byte kStoreExtractVersion = 10; rlm@1: rlm@1: const Byte kSupportedVersion = 20; rlm@1: } rlm@1: rlm@1: namespace NExtraID rlm@1: { rlm@1: enum rlm@1: { rlm@1: kZip64 = 0x01, rlm@1: kNTFS = 0x0A, rlm@1: kStrongEncrypt = 0x17, rlm@1: kWzAES = 0x9901 rlm@1: }; rlm@1: } rlm@1: rlm@1: namespace NNtfsExtra rlm@1: { rlm@1: const UInt16 kTagTime = 1; rlm@1: enum rlm@1: { rlm@1: kMTime = 0, rlm@1: kATime = 1, rlm@1: kCTime = 2 rlm@1: }; rlm@1: } rlm@1: rlm@1: const UInt32 kLocalBlockSize = 26; rlm@1: /* rlm@1: struct CLocalBlock rlm@1: { rlm@1: CVersion ExtractVersion; rlm@1: rlm@1: UInt16 Flags; rlm@1: UInt16 CompressionMethod; rlm@1: UInt32 Time; rlm@1: UInt32 FileCRC; rlm@1: UInt32 PackSize; rlm@1: UInt32 UnPackSize; rlm@1: UInt16 NameSize; rlm@1: UInt16 ExtraSize; rlm@1: }; rlm@1: */ rlm@1: rlm@1: const UInt32 kDataDescriptorSize = 16; rlm@1: // const UInt32 kDataDescriptor64Size = 16 + 8; rlm@1: /* rlm@1: struct CDataDescriptor rlm@1: { rlm@1: UInt32 Signature; rlm@1: UInt32 FileCRC; rlm@1: UInt32 PackSize; rlm@1: UInt32 UnPackSize; rlm@1: }; rlm@1: rlm@1: struct CLocalBlockFull rlm@1: { rlm@1: UInt32 Signature; rlm@1: CLocalBlock Header; rlm@1: }; rlm@1: */ rlm@1: rlm@1: const UInt32 kCentralBlockSize = 42; rlm@1: /* rlm@1: struct CBlock rlm@1: { rlm@1: CVersion MadeByVersion; rlm@1: CVersion ExtractVersion; rlm@1: UInt16 Flags; rlm@1: UInt16 CompressionMethod; rlm@1: UInt32 Time; rlm@1: UInt32 FileCRC; rlm@1: UInt32 PackSize; rlm@1: UInt32 UnPackSize; rlm@1: UInt16 NameSize; rlm@1: UInt16 ExtraSize; rlm@1: UInt16 CommentSize; rlm@1: UInt16 DiskNumberStart; rlm@1: UInt16 InternalAttributes; rlm@1: UInt32 ExternalAttributes; rlm@1: UInt32 LocalHeaderOffset; rlm@1: }; rlm@1: rlm@1: struct CBlockFull rlm@1: { rlm@1: UInt32 Signature; rlm@1: CBlock Header; rlm@1: }; rlm@1: */ rlm@1: rlm@1: namespace NFlags rlm@1: { rlm@1: const int kEncrypted = 1 << 0; rlm@1: const int kLzmaEOS = 1 << 1; rlm@1: const int kDescriptorUsedMask = 1 << 3; rlm@1: const int kStrongEncrypted = 1 << 6; rlm@1: const int kUtf8 = 1 << 11; rlm@1: rlm@1: const int kImplodeDictionarySizeMask = 1 << 1; rlm@1: const int kImplodeLiteralsOnMask = 1 << 2; rlm@1: rlm@1: const int kDeflateTypeBitStart = 1; rlm@1: const int kNumDeflateTypeBits = 2; rlm@1: const int kNumDeflateTypes = (1 << kNumDeflateTypeBits); rlm@1: const int kDeflateTypeMask = (1 << kNumDeflateTypeBits) - 1; rlm@1: } rlm@1: rlm@1: namespace NHostOS rlm@1: { rlm@1: enum EEnum rlm@1: { rlm@1: kFAT = 0, rlm@1: kAMIGA = 1, rlm@1: kVMS = 2, // VAX/VMS rlm@1: kUnix = 3, rlm@1: kVM_CMS = 4, rlm@1: kAtari = 5, // what if it's a minix filesystem? [cjh] rlm@1: kHPFS = 6, // filesystem used by OS/2 (and NT 3.x) rlm@1: kMac = 7, rlm@1: kZ_System = 8, rlm@1: kCPM = 9, rlm@1: kTOPS20 = 10, // pkzip 2.50 NTFS rlm@1: kNTFS = 11, // filesystem used by Windows NT rlm@1: kQDOS = 12, // SMS/QDOS rlm@1: kAcorn = 13, // Archimedes Acorn RISC OS rlm@1: kVFAT = 14, // filesystem used by Windows 95, NT rlm@1: kMVS = 15, rlm@1: kBeOS = 16, // hybrid POSIX/database filesystem rlm@1: kTandem = 17, rlm@1: kOS400 = 18, rlm@1: kOSX = 19 rlm@1: }; rlm@1: } rlm@1: namespace NUnixAttribute rlm@1: { rlm@1: const UInt32 kIFMT = 0170000; /* Unix file type mask */ rlm@1: rlm@1: const UInt32 kIFDIR = 0040000; /* Unix directory */ rlm@1: const UInt32 kIFREG = 0100000; /* Unix regular file */ rlm@1: const UInt32 kIFSOCK = 0140000; /* Unix socket (BSD, not SysV or Amiga) */ rlm@1: const UInt32 kIFLNK = 0120000; /* Unix symbolic link (not SysV, Amiga) */ rlm@1: const UInt32 kIFBLK = 0060000; /* Unix block special (not Amiga) */ rlm@1: const UInt32 kIFCHR = 0020000; /* Unix character special (not Amiga) */ rlm@1: const UInt32 kIFIFO = 0010000; /* Unix fifo (BCC, not MSC or Amiga) */ rlm@1: rlm@1: const UInt32 kISUID = 04000; /* Unix set user id on execution */ rlm@1: const UInt32 kISGID = 02000; /* Unix set group id on execution */ rlm@1: const UInt32 kISVTX = 01000; /* Unix directory permissions control */ rlm@1: const UInt32 kENFMT = kISGID; /* Unix record locking enforcement flag */ rlm@1: const UInt32 kIRWXU = 00700; /* Unix read, write, execute: owner */ rlm@1: const UInt32 kIRUSR = 00400; /* Unix read permission: owner */ rlm@1: const UInt32 kIWUSR = 00200; /* Unix write permission: owner */ rlm@1: const UInt32 kIXUSR = 00100; /* Unix execute permission: owner */ rlm@1: const UInt32 kIRWXG = 00070; /* Unix read, write, execute: group */ rlm@1: const UInt32 kIRGRP = 00040; /* Unix read permission: group */ rlm@1: const UInt32 kIWGRP = 00020; /* Unix write permission: group */ rlm@1: const UInt32 kIXGRP = 00010; /* Unix execute permission: group */ rlm@1: const UInt32 kIRWXO = 00007; /* Unix read, write, execute: other */ rlm@1: const UInt32 kIROTH = 00004; /* Unix read permission: other */ rlm@1: const UInt32 kIWOTH = 00002; /* Unix write permission: other */ rlm@1: const UInt32 kIXOTH = 00001; /* Unix execute permission: other */ rlm@1: } rlm@1: rlm@1: namespace NAmigaAttribute rlm@1: { rlm@1: const UInt32 kIFMT = 06000; /* Amiga file type mask */ rlm@1: const UInt32 kIFDIR = 04000; /* Amiga directory */ rlm@1: const UInt32 kIFREG = 02000; /* Amiga regular file */ rlm@1: const UInt32 kIHIDDEN = 00200; /* to be supported in AmigaDOS 3.x */ rlm@1: const UInt32 kISCRIPT = 00100; /* executable script (text command file) */ rlm@1: const UInt32 kIPURE = 00040; /* allow loading into resident memory */ rlm@1: const UInt32 kIARCHIVE = 00020; /* not modified since bit was last set */ rlm@1: const UInt32 kIREAD = 00010; /* can be opened for reading */ rlm@1: const UInt32 kIWRITE = 00004; /* can be opened for writing */ rlm@1: const UInt32 kIEXECUTE = 00002; /* executable image, a loadable runfile */ rlm@1: const UInt32 kIDELETE = 00001; /* can be deleted */ rlm@1: } rlm@1: } rlm@1: rlm@1: }} rlm@1: rlm@1: #endif