Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CabHeader.h « Cab « Archive « 7zip - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2eac96bf48e3c2a83b797350f8e3dc0c4836c962 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Archive/Cab/Header.h

#ifndef __ARCHIVE_CAB_HEADER_H
#define __ARCHIVE_CAB_HEADER_H

#include "Common/Types.h"

namespace NArchive {
namespace NCab {
namespace NHeader{

namespace NArchive {
  
  extern UInt32 kSignature;
  
  namespace NFlags
  {
    const int kPrevCabinet = 0x0001;
    const int kNextCabinet = 0x0002;
    const int kReservePresent = 0x0004;
  }

  const UInt32 kArchiveHeaderSize = 36;
  /*
  struct CBlock
  {
    UInt32  Signature;	// cabinet file signature
    UInt32  Reserved1;	// reserved
    UInt32  Size;	// size of this cabinet file in bytes
    UInt32  Reserved2;	// reserved
    UInt32  FileOffset;	// offset of the first CFFILE entry
    UInt32  Reserved3;	// reserved
    Byte  VersionMinor;	// cabinet file format version, minor
    Byte  VersionMajor;	// cabinet file format version, major
    UInt16  NumFolders;	// number of CFFOLDER entries in this cabinet
    UInt16  NumFiles;	// number of CFFILE entries in this cabinet
    UInt16  Flags;	// cabinet file option indicators
    UInt16  SetID;	// must be the same for all cabinets in a set
    UInt16  CabinetNumber;	// number of this cabinet file in a set
  };
  */

  const UInt32 kPerDataSizesHeaderSize = 4;

  struct CPerDataSizes
  {
    UInt16 PerCabinetAreaSize; 	// (optional) size of per-cabinet reserved area
    Byte PerFolderAreaSize; 	// (optional) size of per-folder reserved area
    Byte PerDatablockAreaSize; 	// (optional) size of per-datablock reserved area
  };

    /*
    Byte  abReserve[];	// (optional) per-cabinet reserved area
    Byte  szCabinetPrev[];	// (optional) name of previous cabinet file
    Byte  szDiskPrev[];	// (optional) name of previous disk
    Byte  szCabinetNext[];	// (optional) name of next cabinet file
    Byte  szDiskNext[];	// (optional) name of next disk
    */
}

namespace NCompressionMethodMajor
{
  const Byte kNone = 0;
  const Byte kMSZip = 1;
  const Byte kQuantum = 2;
  const Byte kLZX = 3;
}

const UInt32 kFolderHeaderSize = 8;
struct CFolder
{
  UInt32 DataStart;	// offset of the first CFDATA block in this folder
  UInt16 NumDataBlocks;	// number of CFDATA blocks in this folder
  Byte CompressionTypeMajor;
  Byte CompressionTypeMinor;
  // Byte  abReserve[];	// (optional) per-folder reserved area
  Byte GetCompressionMethod() const { return CompressionTypeMajor & 0xF; }
};

const int kFileNameIsUTFAttributeMask = 0x80;

namespace NFolderIndex
{
  const int kContinuedFromPrev    = 0xFFFD;
  const int kContinuedToNext      = 0xFFFE;
  const int kContinuedPrevAndNext = 0xFFFF;
  inline UInt16 GetRealFolderIndex(UInt16 aNumFolders, UInt16 aFolderIndex)
  {
    switch(aFolderIndex)
    {
      case kContinuedFromPrev:
        return 0;
      case kContinuedToNext:
      case kContinuedPrevAndNext:
        return aNumFolders - 1;
      default:
        return aFolderIndex;
    }
  }
}

const UInt32 kFileHeaderSize = 16;
/*
struct CFile
{
  UInt32  UnPackSize;	// uncompressed size of this file in bytes
  UInt32  UnPackOffset;	// uncompressed offset of this file in the folder
  UInt16  FolderIndex;	// index into the CFFOLDER area
  UInt16  PureDate;
  UInt16  PureTime;	// Time
  UInt16  Attributes;	// attribute flags for this file
  Byte  szName[];	// name of this file
};
*/
}}}

#endif