Lhaz
xzfile.h
[詳解]
1 /*==========================================================================*/
2 /* Lhaz xzfileインタフェース lhaz@chitora.jp */
3 /*==========================================================================*/
4 #pragma once
5 
6 #include <vector>
7 #include "lzma.h"
8 #include "mybuf.h"
9 
10 using namespace std;
11 
12 class MYSTR;
13 class MYFILE;
14 
15 class XZFILE {
16 
17 public:
18  static const uint8_t HEADER_MAGIC[6];
19  //
20  XZFILE(void) :
21  UnCompressedSize(0)
22  {
23  }
24  //
25  uint64_t GetUnCompressedSize(void) const { return UnCompressedSize; }
26  bool Get(const MYSTR& name);
27  bool Test(const MYSTR& name);
28 
29 private:
30  enum STREAM_FLAGS {
31  SF_CRC32 = 0x01,
32  SF_CRC64 = 0x04,
33  SF_SHA256 = 0x0A,
34  };
35  enum BLOCK_FLAGS {
36  BF_NUMBER_OF_FILTERS_M = 0x03,
37  BF_RESERVED_M = 0x3C,
38  BF_COMPRESSED_SIZE_PRESENT = 0x40,
39  BF_UNCOMPRESSED_SIZE_PRESENT = 0x80,
40  };
41  //
42  static const uint8_t FOOTER_MAGIC[2];
43  //
44  struct stream_header_t {
45  uint8_t header_magic_bytes[6];
46  uint8_t stream_flags[2];
47  uint32_t crc32;
48  } stream_header;
49  struct block_t {
50  struct block_header_t {
52  uint8_t block_flags;
53  uint64_t compressed_size;
55  struct filter_flags_t {
56  uint64_t filter_id;
59  };
60  vector<filter_flags_t> filter_flags;
62  uint32_t crc32;
63  } block_header;
66  MYBUF check;
67  };
68  vector<block_t> block;
69  struct index_t {
70  uint8_t index_indicator;
72  struct record_t {
73  uint64_t unpadded_size;
75  };
76  vector<record_t> record;
78  uint32_t crc32;
79  } index;
80  struct stream_footer_t {
81  uint32_t crc32;
83  uint8_t stream_flags[2];
84  uint8_t footer_magic_bytes[2];
85  } stream_footer;
86  //
87  uint64_t UnCompressedSize;
88  //
89  bool GetVli(MYFILE& fp, uint64_t& ret, uint64_t& read);
90 
91 };
uint8_t block_header_size
Definition: xzfile.h:51
vector< block_t > block
Definition: xzfile.h:68
uint8_t index_indicator
Definition: xzfile.h:70
Definition: xzfile.h:15
uint8_t block_flags
Definition: xzfile.h:52
MYBUF block_padding
Definition: xzfile.h:65
uint64_t GetUnCompressedSize(void) const
Definition: xzfile.h:25
Definition: xzfile.h:44
uint64_t size_of_properties
Definition: xzfile.h:57
uint32_t crc32
Definition: xzfile.h:78
uint64_t number_of_records
Definition: xzfile.h:71
MYBUF header_padding
Definition: xzfile.h:61
STREAM_FLAGS
Definition: xzfile.h:30
MYBUF compressed_data
Definition: xzfile.h:64
uint64_t uncompressed_size
Definition: xzfile.h:54
Definition: xzfile.h:50
BLOCK_FLAGS
Definition: xzfile.h:35
uint64_t unpadded_size
Definition: xzfile.h:73
MYBUF check
Definition: xzfile.h:66
Definition: xzfile.h:69
vector< filter_flags_t > filter_flags
Definition: xzfile.h:60
vector< record_t > record
Definition: xzfile.h:76
uint64_t UnCompressedSize
Definition: xzfile.h:87
MYBUF filter_properties
Definition: xzfile.h:58
Definition: xzfile.h:72
Definition: xzfile.h:49
uint32_t crc32
Definition: xzfile.h:62
XZFILE(void)
Definition: xzfile.h:20
uint64_t filter_id
Definition: xzfile.h:56
uint32_t crc32
Definition: xzfile.h:47
uint64_t uncompressed_size
Definition: xzfile.h:74
MYBUF index_padding
Definition: xzfile.h:77
uint64_t compressed_size
Definition: xzfile.h:53