annotate system/file.h @ 59:36d92d21300f

Implemented sin opcode
author Thibaut GIRKA <thib@sitedethib.com>
date Fri, 18 Dec 2009 18:51:44 +0100
parents ddbcbd000206
children 4416cfac86ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /* file.h : KANON の圧縮ファイル・PDT ファイル(画像ファイル)の展開の
223b71206888 Initial import
thib
parents:
diff changeset
2 * ためのクラス
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
3 * class FileSearcher : ファイルの管理を行う
0
223b71206888 Initial import
thib
parents:
diff changeset
4 * class ARCINFO : 書庫ファイルの中の1つのファイルを扱うクラス
223b71206888 Initial import
thib
parents:
diff changeset
5 * class PDTCONV : PDT ファイルの展開を行う。
223b71206888 Initial import
thib
parents:
diff changeset
6 */
223b71206888 Initial import
thib
parents:
diff changeset
7
223b71206888 Initial import
thib
parents:
diff changeset
8 /*
223b71206888 Initial import
thib
parents:
diff changeset
9 *
223b71206888 Initial import
thib
parents:
diff changeset
10 * Copyright (C) 2000- Kazunori Ueno(JAGARL) <jagarl@creator.club.ne.jp>
223b71206888 Initial import
thib
parents:
diff changeset
11 *
223b71206888 Initial import
thib
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
223b71206888 Initial import
thib
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
223b71206888 Initial import
thib
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
223b71206888 Initial import
thib
parents:
diff changeset
15 * (at your option) any later version.
223b71206888 Initial import
thib
parents:
diff changeset
16 *
223b71206888 Initial import
thib
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
223b71206888 Initial import
thib
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
223b71206888 Initial import
thib
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223b71206888 Initial import
thib
parents:
diff changeset
20 * GNU General Public License for more details.
223b71206888 Initial import
thib
parents:
diff changeset
21 *
27
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
22 * You should have received a copy of the GNU General Public License along
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
23 * with this program; if not, write to the Free Software Foundation, Inc.,
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0
223b71206888 Initial import
thib
parents:
diff changeset
25 *
223b71206888 Initial import
thib
parents:
diff changeset
26 */
223b71206888 Initial import
thib
parents:
diff changeset
27
223b71206888 Initial import
thib
parents:
diff changeset
28 #ifndef __KANON_FILE_H__
223b71206888 Initial import
thib
parents:
diff changeset
29 #define __KANON_FILE_H__
223b71206888 Initial import
thib
parents:
diff changeset
30
223b71206888 Initial import
thib
parents:
diff changeset
31 #ifndef DIR_SPLIT
223b71206888 Initial import
thib
parents:
diff changeset
32 #define DIR_SPLIT '/' /* UNIX */
223b71206888 Initial import
thib
parents:
diff changeset
33 #endif
223b71206888 Initial import
thib
parents:
diff changeset
34
223b71206888 Initial import
thib
parents:
diff changeset
35 // read 'KANON' compressed file
223b71206888 Initial import
thib
parents:
diff changeset
36
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
37 #include <stdio.h>
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
38 #include <stdlib.h>
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
39 #include <string.h>
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
40 #include <sys/types.h>
0
223b71206888 Initial import
thib
parents:
diff changeset
41
223b71206888 Initial import
thib
parents:
diff changeset
42 #ifdef HAVE_CONFIG_H
223b71206888 Initial import
thib
parents:
diff changeset
43 # include "config.h"
223b71206888 Initial import
thib
parents:
diff changeset
44 #endif
223b71206888 Initial import
thib
parents:
diff changeset
45
223b71206888 Initial import
thib
parents:
diff changeset
46 #if defined(__sparc) || defined(sparc)
223b71206888 Initial import
thib
parents:
diff changeset
47 # if !defined(WORDS_BIGENDIAN)
223b71206888 Initial import
thib
parents:
diff changeset
48 # define WORDS_BIGENDIAN 1
223b71206888 Initial import
thib
parents:
diff changeset
49 # endif
223b71206888 Initial import
thib
parents:
diff changeset
50 #endif
223b71206888 Initial import
thib
parents:
diff changeset
51
223b71206888 Initial import
thib
parents:
diff changeset
52 #define INT_SIZE 4
223b71206888 Initial import
thib
parents:
diff changeset
53
223b71206888 Initial import
thib
parents:
diff changeset
54 static int read_little_endian_int(const char* buf) {
223b71206888 Initial import
thib
parents:
diff changeset
55 const unsigned char *p = (const unsigned char *) buf;
223b71206888 Initial import
thib
parents:
diff changeset
56 return (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
223b71206888 Initial import
thib
parents:
diff changeset
57 }
223b71206888 Initial import
thib
parents:
diff changeset
58
223b71206888 Initial import
thib
parents:
diff changeset
59 static int read_little_endian_short(const char* buf) {
223b71206888 Initial import
thib
parents:
diff changeset
60 const unsigned char *p = (const unsigned char *) buf;
223b71206888 Initial import
thib
parents:
diff changeset
61 return (p[1] << 8) | p[0];
223b71206888 Initial import
thib
parents:
diff changeset
62 }
223b71206888 Initial import
thib
parents:
diff changeset
63
223b71206888 Initial import
thib
parents:
diff changeset
64 static int write_little_endian_int(char* buf, int number) {
223b71206888 Initial import
thib
parents:
diff changeset
65 int c = read_little_endian_int(buf);
223b71206888 Initial import
thib
parents:
diff changeset
66 unsigned char *p = (unsigned char *) buf;
223b71206888 Initial import
thib
parents:
diff changeset
67 unsigned int unum = (unsigned int) number;
223b71206888 Initial import
thib
parents:
diff changeset
68 p[0] = unum & 255;
223b71206888 Initial import
thib
parents:
diff changeset
69 unum >>= 8;
223b71206888 Initial import
thib
parents:
diff changeset
70 p[1] = unum & 255;
223b71206888 Initial import
thib
parents:
diff changeset
71 unum >>= 8;
223b71206888 Initial import
thib
parents:
diff changeset
72 p[2] = unum & 255;
223b71206888 Initial import
thib
parents:
diff changeset
73 unum >>= 8;
223b71206888 Initial import
thib
parents:
diff changeset
74 p[3] = unum & 255;
223b71206888 Initial import
thib
parents:
diff changeset
75 return c;
223b71206888 Initial import
thib
parents:
diff changeset
76 }
223b71206888 Initial import
thib
parents:
diff changeset
77
223b71206888 Initial import
thib
parents:
diff changeset
78 static int write_little_endian_short(char* buf, int number) {
223b71206888 Initial import
thib
parents:
diff changeset
79 int c = read_little_endian_short(buf);
223b71206888 Initial import
thib
parents:
diff changeset
80 unsigned char *p = (unsigned char *) buf;
223b71206888 Initial import
thib
parents:
diff changeset
81 unsigned int unum = (unsigned int) number;
223b71206888 Initial import
thib
parents:
diff changeset
82 p[0] = unum & 255;
223b71206888 Initial import
thib
parents:
diff changeset
83 unum >>= 8;
223b71206888 Initial import
thib
parents:
diff changeset
84 p[1] = unum & 255;
223b71206888 Initial import
thib
parents:
diff changeset
85 return c;
223b71206888 Initial import
thib
parents:
diff changeset
86 }
223b71206888 Initial import
thib
parents:
diff changeset
87
223b71206888 Initial import
thib
parents:
diff changeset
88
223b71206888 Initial import
thib
parents:
diff changeset
89 /*********************************************
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
90 ** FileSearcher:
0
223b71206888 Initial import
thib
parents:
diff changeset
91 ** 書庫ファイル/ディレクトリを含め、
223b71206888 Initial import
thib
parents:
diff changeset
92 ** 全ファイルの管理を行う。
223b71206888 Initial import
thib
parents:
diff changeset
93 **
223b71206888 Initial import
thib
parents:
diff changeset
94 ** 最初に、設定ファイルからファイルの種類ごとに
223b71206888 Initial import
thib
parents:
diff changeset
95 ** 実際に入っているディレクトリ、書庫を設定する
223b71206888 Initial import
thib
parents:
diff changeset
96 **
223b71206888 Initial import
thib
parents:
diff changeset
97 ** 以降はFind() メソッドで実際のファイルの内容を得る
223b71206888 Initial import
thib
parents:
diff changeset
98 **
223b71206888 Initial import
thib
parents:
diff changeset
99 */
223b71206888 Initial import
thib
parents:
diff changeset
100
223b71206888 Initial import
thib
parents:
diff changeset
101 /* ARCFILE と DIRFILE はファイル種類ごとの情報 */
223b71206888 Initial import
thib
parents:
diff changeset
102 class ARCFILE;
223b71206888 Initial import
thib
parents:
diff changeset
103 class DIRFILE;
223b71206888 Initial import
thib
parents:
diff changeset
104 class SCN2kFILE;
223b71206888 Initial import
thib
parents:
diff changeset
105 /* ARCINFO はファイルを読み込むために必要 */
223b71206888 Initial import
thib
parents:
diff changeset
106 class ARCINFO;
223b71206888 Initial import
thib
parents:
diff changeset
107 class ARCFILE_ATOM;
35
2c574c3d50a9 * Moved XOR key related things to a proper location
thib
parents: 30
diff changeset
108
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
109 class KeyHolder {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
110 public:
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
111 static KeyHolder* GetInstance(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
112 static void Quit(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
113
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
114 void SetKey(char[16]);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
115 void SetKey2(char[33]);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
116 void GuessKey(char*);
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
117
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
118 private:
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
119 KeyHolder(){}
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
120 ~KeyHolder(){}
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
121
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
122 public:
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
123 const char* GetKey(void);
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
124
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
125 private:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
126 char key[16];
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
127 static KeyHolder* _singleton;
35
2c574c3d50a9 * Moved XOR key related things to a proper location
thib
parents: 30
diff changeset
128 };
2c574c3d50a9 * Moved XOR key related things to a proper location
thib
parents: 30
diff changeset
129
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
130 class FileSearcher {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
131 public:
0
223b71206888 Initial import
thib
parents:
diff changeset
132 #define TYPEMAX 14
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
133 enum FILETYPE {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
134 /* 一応、0 - 15 まで reserved */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
135 ALL = 1, /* dat/ 以下のファイル(デフォルトの検索先) */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
136 ROOT= 2, /* ゲームのインストールディレクトリ */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
137 PDT = 3, /* default: PDT/ */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
138 SCN = 4, /* default: DAT/SEEN.TXT */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
139 ANM = 5, /* default: DAT/ALLANM.ANL */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
140 ARD = 6, /* default: DAT/ALLARD.ARD */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
141 CUR = 7, /* default: DAT/ALLCUR.CUR */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
142 MID = 8, /* default: ALL */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
143 WAV = 9, /* default: ALL */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
144 KOE = 10, /* default: KOE/ */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
145 BGM = 11, /* default: BGM */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
146 MOV = 12, /* default : MOV */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
147 GAN = 13 /* default : MOV */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
148 };
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
149 enum ARCTYPE {ATYPE_DIR, ATYPE_ARC, ATYPE_SCN2k};
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
150
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
151 public:
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
152 static FileSearcher* GetInstance(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
153 static void Quit(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
154
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
155 /* 初めにゲームのデータがあるディレクトリを設定する必要がある */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
156 int InitRoot(char* root);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
157 /* ファイルの型ごとの情報をセットする */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
158 void SetFileInformation(FILETYPE type, ARCTYPE is_arc,
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
159 char* filename);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
160 /* 複数のファイルを一つの型に関連づける */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
161 void AppendFileInformation(FILETYPE type, ARCTYPE is_arc,
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
162 char* filename);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
163 ARCFILE* MakeARCFILE(ARCTYPE tp, const char* filename);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
164 /* fname で指定された名前のファイルを検索 */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
165 class ARCINFO* Find(FILETYPE type, const char* fname, const char* ext=0);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
166 /* ある種類のファイルをすべてリストアップ
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
167 ** 末尾は NULL pointer
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
168 */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
169 char** ListAll(FILETYPE type);
53
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
170
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
171 private:
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
172 FileSearcher(void);
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
173 ~FileSearcher();
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
174
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
175 private:
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
176 /* InitRoot() の時点で初期化される変数 */
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
177 DIRFILE* root_dir;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
178 DIRFILE* dat_dir;
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
179 ARCFILE* searcher[TYPEMAX];
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
180 /* ファイルの存在位置の information */
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
181 ARCTYPE is_archived[TYPEMAX];
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
182 const char* filenames[TYPEMAX];
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
183 /* デフォルトの information */
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
184 static ARCTYPE default_is_archived[TYPEMAX];
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
185 static const char* default_dirnames[TYPEMAX];
ddbcbd000206 * MuSys, AyuSysConfig, FileSearcher (former FILESEARCHER) and KeyHolder (former KEYHOLDER) are now singletons
thib
parents: 52
diff changeset
186 static FileSearcher *_singleton;
0
223b71206888 Initial import
thib
parents:
diff changeset
187 };
223b71206888 Initial import
thib
parents:
diff changeset
188
223b71206888 Initial import
thib
parents:
diff changeset
189 class ARCINFO {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
190 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
191 /* ファイルそのものの情報 */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
192 ARCFILE_ATOM& info;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
193 char* arcfile;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
194 /* mmap している場合、その情報 */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
195 bool use_mmap;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
196 char* mmapped_memory;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
197 int fd;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
198 /* ファイル内容の入っているバッファ */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
199 const char* data;
0
223b71206888 Initial import
thib
parents:
diff changeset
200
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
201 protected:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
202 ARCINFO(const char* arcfile, ARCFILE_ATOM& from); // only from ARCFILE
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
203 friend class ARCFILE;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
204 friend class DIRFILE;
0
223b71206888 Initial import
thib
parents:
diff changeset
205
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
206 virtual bool ExecExtract(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
207 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
208 /* dest は256byte 程度の余裕があること */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
209 static void Extract(char*& dest, char*& src, char* destend, char* srcend);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
210 static void Extract2k(char*& dest, char*& src, char* destend, char* srcend);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
211 virtual ~ARCINFO();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
212 /* 必要なら Read 前に呼ぶことで処理を分割できる */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
213 int Size(void) const;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
214 char* CopyRead(void); /* Read() して内容のコピーを返す */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
215 const char* Read(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
216 /* ファイルが regular file の場合、ファイル名を帰す */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
217 /* そうでないなら 0 を帰す */
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
218 const char* Path(void) const;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
219 FILE* OpenFile(int* length=0) const; /* 互換性のため:raw file の場合、ファイルを開く */
0
223b71206888 Initial import
thib
parents:
diff changeset
220 };
223b71206888 Initial import
thib
parents:
diff changeset
221
223b71206888 Initial import
thib
parents:
diff changeset
222 class GRPCONV {
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
223 public:
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
224 int width;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
225 int height;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
226 bool is_mask;
0
223b71206888 Initial import
thib
parents:
diff changeset
227
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
228 const char* filename;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
229 const char* data;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
230 int datalen;
0
223b71206888 Initial import
thib
parents:
diff changeset
231
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
232 int Width(void) { return width;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
233 int Height(void) { return height;}
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
234 bool IsMask(void) { return is_mask;}
0
223b71206888 Initial import
thib
parents:
diff changeset
235
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
236 GRPCONV(void);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
237 virtual ~GRPCONV();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
238 void Init(const char* fname, const char* data, int dlen, int width, int height, bool is_mask);
0
223b71206888 Initial import
thib
parents:
diff changeset
239
52
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
240 virtual bool Read(char* image) = 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
241 static GRPCONV* AssignConverter(const char* inbuf, int inlen, const char* fname);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
242 static GRPCONV* AssignConverter(ARCINFO* info) {
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
243 const char* dat = info->Read();
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
244 if (dat == 0) return 0;
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
245 return AssignConverter(dat, info->Size(), info->Path()); //FIXME: Is it really okay?
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
246 }
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
247 void CopyRGBA(char* image, const char* from);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
248 void CopyRGB(char* image, const char* from);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
249 void CopyRGBA_rev(char* image, const char* from);
15a18fbe6f21 * Known bugs added to the README
thib
parents: 47
diff changeset
250 void CopyRGB_rev(char* image, const char* from);
0
223b71206888 Initial import
thib
parents:
diff changeset
251 };
223b71206888 Initial import
thib
parents:
diff changeset
252
223b71206888 Initial import
thib
parents:
diff changeset
253 #endif // !defined(__KANON_FILE_H__)