Lhaz
読み取り中…
検索中…
一致する文字列を見つけられません
lzh.h
[詳解]
1/*************************************************************************/
6#pragma once
7
8#include <stdio.h>
9#include <time.h>
10#include "mystr.h"
11#include "lhazdef.h"
12#include "lha_macro.h"
13
14class MYFILE;
15class MYBUF;
16
17#define METHOD_TYPE_STRAGE 5
18#define LZHUFF0_METHOD "-lh0-"
19#define LZHUFF1_METHOD "-lh1-"
20#define LZHUFF2_METHOD "-lh2-"
21#define LZHUFF3_METHOD "-lh3-"
22#define LZHUFF4_METHOD "-lh4-"
23#define LZHUFF5_METHOD "-lh5-"
24#define LZHUFF6_METHOD "-lh6-"
25#define LZHUFF7_METHOD "-lh7-"
26#define LARC_METHOD "-lzs-"
27#define LARC5_METHOD "-lz5-"
28#define LARC4_METHOD "-lz4-"
29#define LZHDIRS_METHOD "-lhd-"
30
31#define LZH_EXT_HEAD_CRC 0x00
32#define LZH_EXT_HEAD_FNAME 0x01
33#define LZH_EXT_HEAD_PATH 0x02
34#define LZH_EXT_HEAD_COMNT 0x3F
35#define LZH_EXT_HEAD_ATRB 0x40
36#define LZH_EXT_HEAD_TIME 0x41
37#define LZH_EXT_HEAD_SIZE 0x42
38#define LZH_EXT_HEAD_UNI_FNAME 0x44
39#define LZH_EXT_HEAD_UNI_PATH 0x45
40#define LZH_EXT_HEAD_CP 0x46
41#define LZH_EXT_HEAD_PERMS 0x50
42#define LZH_EXT_HEAD_GID 0x51
43#define LZH_EXT_HEAD_GROUP 0x52
44#define LZH_EXT_HEAD_USER 0x53
45#define LZH_EXT_HEAD_MODT 0x54
46#define LZH_EXT_HEAD_RESRV 0xFF
47
48#define EXTEND_GENERIC 0
49#define EXTEND_UNIX 'U'
50#define EXTEND_MSDOS 'M'
51#define EXTEND_MACOS 'm'
52#define EXTEND_OS9 '9'
53#define EXTEND_OS2 '2'
54#define EXTEND_OS68K 'K'
55#define EXTEND_OS386 '3'
56#define EXTEND_HUMAN 'H'
57#define EXTEND_CPM 'C'
58#define EXTEND_FLEX 'F'
59#define EXTEND_RUNSER 'R'
60#define EXTEND_TOWNSOS 'T'
61#define EXTEND_XOSK 'X'
62
63#define I_HEADER_SIZE 0
64#define I_HEADER_CHECKSUM 1
65#define I_METHOD 2
66#define I_PACKED_SIZE 7
67#define I_ORIGINAL_SIZE 11
68#define I_LAST_MODIFIED_STAMP 15
69#define I_ATTRIBUTE 19
70#define I_HEADER_LEVEL 20
71#define I_NAME_LENGTH 21
72#define I_NAME 22
73#define I_CRC 22 /* + name_length */
74#define I_EXTEND_TYPE 24 /* + name_length */
75#define I_MINOR_VERSION 25 /* + name_length */
76#define I_UNIX_LAST_MODIFIED_STAMP 26 /* + name_length */
77#define I_UNIX_MODE 30 /* + name_length */
78#define I_UNIX_UID 32 /* + name_length */
79#define I_UNIX_GID 34 /* + name_length */
80#define I_UNIX_EXTEND_BOTTOM 36 /* + name_length */
81#define I_GENERIC_HEADER_BOTTOM I_EXTEND_TYPE
82
83#define GENERIC_ATTRIBUTE 0x20
84#define GENERIC_DIRECTORY_ATTRIBUTE 0x10
85
86class CLZH {
87public:
102 CLZH(int arctype = 0);
103 CLZH(const MYSTR& name, struct _stat *v_stat);
104 ‾CLZH(void);
105 // 展開
106 bool Match(char* p, char* s, int f);
107 bool ReadHeader(MYFILE&);
108 bool Extract(MYFILE& fp, bool& force, bool& skip, bool test = false);
109 // 圧縮
110 bool Add(MYFILE& fp, MYFILE& nafp, int method, uchar level);
111 void WriteHeader(MYFILE& nafp);
112 // サブ
113 const MYSTR& GetName(void) { return Name; }
114 const MYSTR& GetFname(void) { return Fname; }
115 void SetName(const MYSTR& name);
116 void SetFname(const MYSTR& name, bool dir = false);
117 const MYSTR& GetDir(void) { return Dir; }
118 void SetDir(const MYSTR& dir);
120 LONGLONG GetTotalSize(void);
121 LONGLONG GetSize(void) { return OriginalSize; }
122 void SetOriginalSize(LONGLONG size);
123 LONGLONG GetPackedSize(void) { return PackedSize; }
124 void SetPackedSize(ulong size);
125 float GetRatio(void) { return Ratio; }
126 void SetRatio(void);
127 int GetMethod(void) { return MethodNum; }
128 void SetMethod(int method) { MethodNum = method; }
129 const MYSTR& GetMethodText(void) { return MethodText; }
130 void SetMethodText(const MYSTR& method) { MethodText = method; }
131 time_t GetTime(void) { return Unix_last_modified_stamp; }
132 void SetUnix_last_modified_stamp(time_t t);
133 ushort GetUnix_mode(void) { return Unix_mode; }
134 const MYSTR& GetType(void) { return Type; }
135 void SetType(const MYSTR& type) { Type = type; }
136 int GetImage(void) { return Image; }
137 void SetImage(int image) { Image = image; }
138 fpos_t GetFpos(void) { return Fpos; }
139 void SetFpos(fpos_t fpos) { Fpos = fpos; }
140 bool GetEncrypt(void) { return Encrypt; }
141 void SetEncrypt(bool f) { Encrypt = f; }
143 int GetTreeFolder(void) const { return TreeFolder; }
144 void SetTreeFolder(int f) { TreeFolder = f; }
145 ushort GetAttribute(void) const { return Attribute; }
146 void SetZoneIdentifier(const MYBUF& buf) { ZoneIdentifier = buf; }
147
148private:
149 static const int FILENAME_LENGTH;
150 static const int LZHEADER_STRAGE;
152 static const ushort UNIX_RW_RW_RW;
153 //
154 uchar HeaderSize; /* ヘッダサイズ */
155 int MethodNum; /* 圧縮形式(数値) */
156 char Method[METHOD_TYPE_STRAGE]; /* 圧縮形式(テキスト) */
157 MYSTR MethodText; /* 圧縮形式(テキスト) */
158 LONGLONG PackedSize; /* 圧縮サイズ */
159 LONGLONG OriginalSize; /* 元サイズ */
160 long Last_modified_stamp; /* 最終更新日時(MS-DOS) */
161 time_t Unix_last_modified_stamp; /* 最終更新日時(time_t) */
162 ushort Attribute; /* 属性 */
163 uchar HeaderLevel; /* ヘッダレベル */
164 MYSTR Dir; /* ディレクトリ */
165 MYSTR Fname; /* ファイル名 */
166 MYSTR Name; /* ファイル名(フルパス) */
167 ushort Crc; /* CRC */
168 bool HasCrc; /* CRC付きか? */
169 uchar ExtendType; /* 拡張形式 */
170 uchar Minor_version; /* マイナーバージョン */
171 ushort Unix_mode; /* モード */
172 ushort Unix_uid; /* ユーザーID */
173 ushort Unix_gid; /* グループID */
174 MYSTR Type; /* ファイルの種別 */
175 int Image; /* イメージインデックス */
176 fpos_t Fpos; /* ファイル位置 */
177 float Ratio; /* 圧縮率 */
178 int ArcType; /* 書庫種別 */
179 bool Encrypt; /* 暗号化フラグ */
180 unsigned char* get_ptr; /* データポインタ */
181 int TreeFolder; /* ツリービューフォルダ */
182 static char* Methods[]; /* 圧縮メソッド */
183 FILETIME CreationTime; /* 作成日時 */
184 FILETIME LastAccessTime; /* 最終アクセス日時 */
185 FILETIME LastWriteTime; /* 最終更新日時 */
186 bool TimeStampExist; /* タイムスタンプヘッダ有無 */
187 MYBUF ZoneIdentifier; /* Zone.Identifier */
188 //
189 void clzh(void);
190 ushort get_word(void);
191 void put_word(unsigned int);
192 ulong get_longword(void);
193 void put_longword(long);
194 void generic_to_unix_filename(char*, int);
195 void unix_to_generic_filename(MYSTR&);
196 void macos_to_unix_filename(char*, int);
197 long unix_to_generic_stamp(time_t);
198 long gettz(void) const;
199 void adjust_info(const MYSTR& name);
200 int inquire_extract(const MYSTR& name, bool& force, bool& skip);
201 bool open_with_make_path(const MYSTR& name, MYFILE** fp);
202 bool make_parent_path(const MYSTR& name);
203 ushort decode_lzhuf(MYFILE& infp, MYFILE& outfp, LONGLONG original_size, LONGLONG packed_size, const MYSTR& name, int method);
204 ushort encode_lzhuf(MYFILE& infp, MYFILE& outfp, LONGLONG* original_size_var, LONGLONG* packed_size_var);
205 ushort encode_stored_crc(MYFILE& ifp, MYFILE& ofp, LONGLONG size, LONGLONG* original_size_var, LONGLONG* write_size_var);
206 void fatal_error(const MYSTR& msg);
207 bool ReadLevel0Header(MYFILE&);
208 bool ReadLevel1Header(MYFILE&);
209 bool ReadLevel2Header(MYFILE&);
210 bool ReadLevel3Header(MYFILE&);
211 void WriteLevel0Header(MYFILE& nafp);
212 void WriteLevel1Header(MYFILE& nafp);
213 void WriteLevel2Header(MYFILE& nafp);
214 void WriteLevel3Header(MYFILE& nafp);
215
216};
Definition lzh.h:86
unsigned char * get_ptr
Definition lzh.h:180
long gettz(void) const
Definition lzh.cpp:233
int inquire_extract(const MYSTR &name, bool &force, bool &skip)
Definition lzh.cpp:269
bool ReadLevel0Header(MYFILE &)
Definition lzh.cpp:606
void macos_to_unix_filename(char *, int)
Definition lzh.cpp:205
void SetDir(const MYSTR &dir)
Definition lzh.cpp:482
ushort encode_lzhuf(MYFILE &infp, MYFILE &outfp, LONGLONG *original_size_var, LONGLONG *packed_size_var)
Definition lzh.cpp:414
bool Add(MYFILE &fp, MYFILE &nafp, int method, uchar level)
Definition lzh.cpp:1604
void WriteHeader(MYFILE &nafp)
Definition lzh.cpp:1081
static char * Methods[]
Definition lzh.h:51
void generic_to_unix_filename(char *, int)
Definition lzh.cpp:184
int GetImage(void)
Definition lzh.h:136
void SetMethod(int method)
Definition lzh.h:128
void SetName(const MYSTR &name)
Definition lzh.cpp:452
fpos_t GetFpos(void)
Definition lzh.h:138
LONGLONG OriginalSize
Definition lzh.h:159
char Method[METHOD_TYPE_STRAGE]
Definition lzh.h:156
int GetMethod(void)
Definition lzh.h:127
bool Extract(MYFILE &fp, bool &force, bool &skip, bool test=false)
Definition lzh.cpp:1512
static const ushort UNIX_RW_RW_RW
Definition lzh.h:152
bool TimeStampExist
Definition lzh.h:186
MYSTR MethodText
Definition lzh.h:157
uchar GetHeaderLevel(void)
Definition lzh.h:142
void adjust_info(const MYSTR &name)
Definition lzh.cpp:244
MYSTR Name
Definition lzh.h:166
ulong get_longword(void)
Definition lzh.cpp:160
void SetType(const MYSTR &type)
Definition lzh.h:135
void SetMethodText(const MYSTR &method)
Definition lzh.h:130
LONGLONG PackedSize
Definition lzh.h:158
time_t GetTime(void)
Definition lzh.h:131
void WriteLevel0Header(MYFILE &nafp)
Definition lzh.cpp:1102
ushort encode_stored_crc(MYFILE &ifp, MYFILE &ofp, LONGLONG size, LONGLONG *original_size_var, LONGLONG *write_size_var)
Definition lzh.cpp:433
static const int LZHEADER_STRAGE
Definition lzh.h:150
bool ReadLevel3Header(MYFILE &)
Definition lzh.cpp:1073
void SetOriginalSize(LONGLONG size)
Definition lzh.cpp:495
MYSTR Fname
Definition lzh.h:165
MYSTR Type
Definition lzh.h:174
time_t Unix_last_modified_stamp
Definition lzh.h:161
void SetTreeFolder(int f)
Definition lzh.h:144
LONGLONG GetPackedSize(void)
Definition lzh.h:123
FILETIME LastAccessTime
Definition lzh.h:184
long Last_modified_stamp
Definition lzh.h:160
void SetFpos(fpos_t fpos)
Definition lzh.h:139
void WriteLevel1Header(MYFILE &nafp)
Definition lzh.cpp:1137
void fatal_error(const MYSTR &msg)
Definition lzh.cpp:443
int Image
Definition lzh.h:175
uchar GetHeaderSize(void)
Definition lzh.h:119
ushort Unix_gid
Definition lzh.h:173
void SetUnix_last_modified_stamp(time_t t)
Definition lzh.cpp:549
void SetZoneIdentifier(const MYBUF &buf)
Definition lzh.h:146
static const ushort UNIX_FILE_REGULAR
Definition lzh.h:151
void WriteLevel3Header(MYFILE &nafp)
Definition lzh.cpp:1354
bool Match(char *p, char *s, int f)
Definition lzh.cpp:557
void unix_to_generic_filename(MYSTR &)
Definition lzh.cpp:197
bool Encrypt
Definition lzh.h:179
bool make_parent_path(const MYSTR &name)
Definition lzh.cpp:332
void clzh(void)
Definition lzh.cpp:103
int GetTreeFolder(void) const
Definition lzh.h:143
const MYSTR & GetMethodText(void)
Definition lzh.h:129
‾CLZH(void)
Definition lzh.cpp:133
const MYSTR & GetName(void)
Definition lzh.h:113
float Ratio
Definition lzh.h:177
void SetFname(const MYSTR &name, bool dir=false)
Definition lzh.cpp:462
fpos_t Fpos
Definition lzh.h:176
MYSTR Dir
Definition lzh.h:164
const MYSTR & GetFname(void)
Definition lzh.h:114
void SetEncrypt(bool f)
Definition lzh.h:141
void SetPackedSize(ulong size)
Definition lzh.cpp:517
float GetRatio(void)
Definition lzh.h:125
const MYSTR & GetType(void)
Definition lzh.h:134
void SetRatio(void)
Definition lzh.cpp:525
ushort GetUnix_mode(void)
Definition lzh.h:133
int ArcType
Definition lzh.h:178
uchar HeaderLevel
Definition lzh.h:163
uchar Minor_version
Definition lzh.h:170
bool ReadLevel1Header(MYFILE &)
Definition lzh.cpp:717
MYBUF ZoneIdentifier
Definition lzh.h:187
void WriteLevel2Header(MYFILE &nafp)
Definition lzh.cpp:1239
LONGLONG GetTotalSize(void)
Definition lzh.cpp:503
ushort GetAttribute(void) const
Definition lzh.h:145
LONGLONG GetSize(void)
Definition lzh.h:121
bool HasCrc
Definition lzh.h:168
void SetImage(int image)
Definition lzh.h:137
uchar ExtendType
Definition lzh.h:169
void put_word(unsigned int)
Definition lzh.cpp:151
static const int FILENAME_LENGTH
Definition lzh.h:149
ushort decode_lzhuf(MYFILE &infp, MYFILE &outfp, LONGLONG original_size, LONGLONG packed_size, const MYSTR &name, int method)
Definition lzh.cpp:374
ushort Unix_uid
Definition lzh.h:172
ushort Attribute
Definition lzh.h:162
uchar HeaderSize
Definition lzh.h:154
ushort Crc
Definition lzh.h:167
const MYSTR & GetDir(void)
Definition lzh.h:117
bool ReadLevel2Header(MYFILE &)
Definition lzh.cpp:876
bool open_with_make_path(const MYSTR &name, MYFILE **fp)
Definition lzh.cpp:297
bool ReadHeader(MYFILE &)
Definition lzh.cpp:581
FILETIME LastWriteTime
Definition lzh.h:185
long unix_to_generic_stamp(time_t)
Definition lzh.cpp:218
ushort Unix_mode
Definition lzh.h:171
METHOD
Definition lzh.h:88
@ LZHUFF1_METHOD_NUM1
Definition lzh.h:90
@ LARC_METHOD_NUM1
Definition lzh.h:97
@ LZHUFF7_METHOD_NUM1
Definition lzh.h:96
@ LARC5_METHOD_NUM1
Definition lzh.h:98
@ LZHUFF5_METHOD_NUM1
Definition lzh.h:94
@ LZHDIRS_METHOD_NUM1
Definition lzh.h:100
@ LZHUFF6_METHOD_NUM1
Definition lzh.h:95
@ LZHUFF0_METHOD_NUM1
Definition lzh.h:89
@ LARC4_METHOD_NUM1
Definition lzh.h:99
@ LZHUFF4_METHOD_NUM1
Definition lzh.h:93
@ LZHUFF3_METHOD_NUM1
Definition lzh.h:92
@ LZHUFF2_METHOD_NUM1
Definition lzh.h:91
FILETIME CreationTime
Definition lzh.h:183
int MethodNum
Definition lzh.h:155
void put_longword(long)
Definition lzh.cpp:173
ushort get_word(void)
Definition lzh.cpp:140
bool GetEncrypt(void)
Definition lzh.h:140
int TreeFolder
Definition lzh.h:181
unsigned char uchar
Definition lhazdef.h:4
unsigned long ulong
Definition lhazdef.h:7
unsigned short ushort
Definition lhazdef.h:5
#define METHOD_TYPE_STRAGE
Definition lzh.h:17