annotate system/file_impl.h @ 60:e16e13d8cd68

Replaced SATURATE -> ADD, implemented objComposite, corrected minor things
author Thibaut GIRKA <thib@sitedethib.com>
date Fri, 18 Dec 2009 20:41:38 +0100
parents 15a18fbe6f21
children 4416cfac86ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 * Copyright (c) 2004 Kazunori "jagarl" Ueno
223b71206888 Initial import
thib
parents:
diff changeset
3 * All rights reserved.
223b71206888 Initial import
thib
parents:
diff changeset
4 *
223b71206888 Initial import
thib
parents:
diff changeset
5 * Redistribution and use in source and binary forms, with or without
223b71206888 Initial import
thib
parents:
diff changeset
6 * modification, are permitted provided that the following conditions
223b71206888 Initial import
thib
parents:
diff changeset
7 * are met:
223b71206888 Initial import
thib
parents:
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
9 * notice, this list of conditions and the following disclaimer.
223b71206888 Initial import
thib
parents:
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
223b71206888 Initial import
thib
parents:
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
223b71206888 Initial import
thib
parents:
diff changeset
12 * documentation and/or other materials provided with the distribution.
223b71206888 Initial import
thib
parents:
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
223b71206888 Initial import
thib
parents:
diff changeset
14 * derived from this software without specific prior written permission.
223b71206888 Initial import
thib
parents:
diff changeset
15 *
223b71206888 Initial import
thib
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
223b71206888 Initial import
thib
parents:
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223b71206888 Initial import
thib
parents:
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
223b71206888 Initial import
thib
parents:
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
223b71206888 Initial import
thib
parents:
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
223b71206888 Initial import
thib
parents:
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
223b71206888 Initial import
thib
parents:
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
223b71206888 Initial import
thib
parents:
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
223b71206888 Initial import
thib
parents:
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
223b71206888 Initial import
thib
parents:
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
223b71206888 Initial import
thib
parents:
diff changeset
26 */
223b71206888 Initial import
thib
parents:
diff changeset
27
223b71206888 Initial import
thib
parents:
diff changeset
28
223b71206888 Initial import
thib
parents:
diff changeset
29
223b71206888 Initial import
thib
parents:
diff changeset
30 #ifndef __FILE_IMPL_H__
223b71206888 Initial import
thib
parents:
diff changeset
31 #define __FILE_IMPL_H__
223b71206888 Initial import
thib
parents:
diff changeset
32
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
33 #include <vector>
0
223b71206888 Initial import
thib
parents:
diff changeset
34
223b71206888 Initial import
thib
parents:
diff changeset
35 struct ARCFILE_ATOM {
223b71206888 Initial import
thib
parents:
diff changeset
36 char* filename;
223b71206888 Initial import
thib
parents:
diff changeset
37 char* filename_lower;
223b71206888 Initial import
thib
parents:
diff changeset
38 off_t offset;
223b71206888 Initial import
thib
parents:
diff changeset
39 int arcsize;
223b71206888 Initial import
thib
parents:
diff changeset
40 int filesize;
223b71206888 Initial import
thib
parents:
diff changeset
41 int private_data;
223b71206888 Initial import
thib
parents:
diff changeset
42 bool operator <(const ARCFILE_ATOM& to) const {
223b71206888 Initial import
thib
parents:
diff changeset
43 return strcmp(filename_lower, to.filename_lower) < 0;
223b71206888 Initial import
thib
parents:
diff changeset
44 }
223b71206888 Initial import
thib
parents:
diff changeset
45 bool operator <(char* const to) const {
223b71206888 Initial import
thib
parents:
diff changeset
46 return strcmp(filename_lower, to) < 0;
223b71206888 Initial import
thib
parents:
diff changeset
47 }
223b71206888 Initial import
thib
parents:
diff changeset
48 };
223b71206888 Initial import
thib
parents:
diff changeset
49
223b71206888 Initial import
thib
parents:
diff changeset
50 class ARCFILE {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
51 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
52 char* arcname;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
53 char* filenames_orig;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
54 int list_point;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
55 std::vector<ARCFILE_ATOM> arc_atom;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
56 typedef std::vector<ARCFILE_ATOM>::iterator iterator;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
57 ARCFILE* next; /* FILESEARCH の一つの型が複数の ARCFILE を持つとき、リストをつくる */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
58 /* arcname に指定されたファイル/ディレクトリの内容チェック */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
59 virtual int CheckFileDeal(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
60 virtual void ListupFiles(int fname_len);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
61 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM&);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
62 iterator SearchName(const char* f, const char* ext=0);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
63 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
64 ARCFILE(const char* fname);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
65 void SetNext(ARCFILE* _next) { delete next; next = _next;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
66 ARCFILE* Next(void) { return next; }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
67 void Init(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
68 virtual ~ARCFILE();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
69 /* ファイル検索 */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
70 class ARCINFO* Find(const char* fname, const char* ext);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
71 /* ファイルリストの出力 */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
72 int Deal(void) { Init(); return arc_atom.size(); }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
73 void ListFiles(FILE* out);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
74 void InitList(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
75 char* ListItem(void);
0
223b71206888 Initial import
thib
parents:
diff changeset
76 };
223b71206888 Initial import
thib
parents:
diff changeset
77
223b71206888 Initial import
thib
parents:
diff changeset
78 class SCN2kFILE : public ARCFILE {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
79 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
80 virtual int CheckFileDeal(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
81 virtual void ListupFiles(int fname_len);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
82 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
83 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
84 SCN2kFILE(char* fname) : ARCFILE(fname) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
85 virtual ~SCN2kFILE() {}
0
223b71206888 Initial import
thib
parents:
diff changeset
86 };
223b71206888 Initial import
thib
parents:
diff changeset
87
223b71206888 Initial import
thib
parents:
diff changeset
88 class CattleyaFILE : public ARCFILE {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
89 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
90 bool is_compress;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
91 /* header の Huffman 木構築用 */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
92 char* bitbuf;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
93 char* bitbuf_end;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
94 int ltree[0x400];
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
95 int rtree[0x400];
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
96 int treecnt;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
97 int bitcnt;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
98 int GetBit(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
99 int GetCh(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
100 void SetBuf(char* buf, int len);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
101 int MakeTree(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
102 int Decode(int seed);
0
223b71206888 Initial import
thib
parents:
diff changeset
103
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
104 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
105 virtual int CheckFileDeal(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
106 virtual void ListupFiles(int fname_len);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
107 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
108
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
109 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
110 CattleyaFILE(char* fname) : ARCFILE(fname) {is_compress = false;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
111 virtual ~CattleyaFILE() {}
0
223b71206888 Initial import
thib
parents:
diff changeset
112 };
223b71206888 Initial import
thib
parents:
diff changeset
113
223b71206888 Initial import
thib
parents:
diff changeset
114 class NULFILE : public ARCFILE {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
115 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
116 virtual int CheckFileDeal(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
117 virtual void ListupFiles(int fname_len);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
118 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
119 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
120 NULFILE() : ARCFILE("") {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
121 virtual ~NULFILE() {}
0
223b71206888 Initial import
thib
parents:
diff changeset
122 };
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
123
0
223b71206888 Initial import
thib
parents:
diff changeset
124 class DIRFILE : public ARCFILE {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
125 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
126 virtual int CheckFileDeal(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
127 virtual void ListupFiles(int fname_len);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
128 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
129 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
130 DIRFILE(char* fname) : ARCFILE(fname) {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
131 virtual ~DIRFILE() {}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
132 FILE* Open(const char* fname); /* FILE* を開く */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
133 char* SearchFile(const char* dirname); /* ファイル検索 */
0
223b71206888 Initial import
thib
parents:
diff changeset
134 };
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
135
0
223b71206888 Initial import
thib
parents:
diff changeset
136 class ARCINFO_AVG32 : public ARCINFO {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
137 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
138 ARCINFO_AVG32(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name, atom) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
139 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
140 virtual bool ExecExtract(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
141 friend class ARCFILE;
0
223b71206888 Initial import
thib
parents:
diff changeset
142 };
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
143
0
223b71206888 Initial import
thib
parents:
diff changeset
144 class ARCINFO2k : public ARCINFO {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
145 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
146 static char decode_seed[256];
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
147 static char decode_seed2[16];
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
148 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
149 ARCINFO2k(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name,atom) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
150 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
151 virtual bool ExecExtract(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
152 friend class SCN2kFILE;
0
223b71206888 Initial import
thib
parents:
diff changeset
153 };
223b71206888 Initial import
thib
parents:
diff changeset
154
223b71206888 Initial import
thib
parents:
diff changeset
155 class ARCINFOZ : public ARCINFO {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
156 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
157 ARCINFOZ(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name, atom) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
158 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
159 virtual bool ExecExtract(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
160 friend class DaemonBaneFILE;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 50
diff changeset
161 friend class CattleyaFILE;
0
223b71206888 Initial import
thib
parents:
diff changeset
162 };
223b71206888 Initial import
thib
parents:
diff changeset
163
223b71206888 Initial import
thib
parents:
diff changeset
164 #endif /* __FILE_IMPL_H__ */