comparison system/file_impl.h @ 52:15a18fbe6f21

* Known bugs added to the README * Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author thib
date Sat, 18 Apr 2009 18:35:39 +0000
parents 35ce1a30f3f9
children 4416cfac86ae
comparison
equal deleted inserted replaced
51:cbb301016a4e 52:15a18fbe6f21
28 28
29 29
30 #ifndef __FILE_IMPL_H__ 30 #ifndef __FILE_IMPL_H__
31 #define __FILE_IMPL_H__ 31 #define __FILE_IMPL_H__
32 32
33 #include<vector> 33 #include <vector>
34 34
35 struct ARCFILE_ATOM { 35 struct ARCFILE_ATOM {
36 char* filename; 36 char* filename;
37 char* filename_lower; 37 char* filename_lower;
38 off_t offset; 38 off_t offset;
46 return strcmp(filename_lower, to) < 0; 46 return strcmp(filename_lower, to) < 0;
47 } 47 }
48 }; 48 };
49 49
50 class ARCFILE { 50 class ARCFILE {
51 protected: 51 protected:
52 char* arcname; 52 char* arcname;
53 char* filenames_orig; 53 char* filenames_orig;
54 int list_point; 54 int list_point;
55 std::vector<ARCFILE_ATOM> arc_atom; 55 std::vector<ARCFILE_ATOM> arc_atom;
56 typedef std::vector<ARCFILE_ATOM>::iterator iterator; 56 typedef std::vector<ARCFILE_ATOM>::iterator iterator;
57 ARCFILE* next; /* FILESEARCH の一つの型が複数の ARCFILE を持つとき、リストをつくる */ 57 ARCFILE* next; /* FILESEARCH の一つの型が複数の ARCFILE を持つとき、リストをつくる */
58 /* arcname に指定されたファイル/ディレクトリの内容チェック */ 58 /* arcname に指定されたファイル/ディレクトリの内容チェック */
59 virtual int CheckFileDeal(void); 59 virtual int CheckFileDeal(void);
60 virtual void ListupFiles(int fname_len); 60 virtual void ListupFiles(int fname_len);
61 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM&); 61 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM&);
62 iterator SearchName(const char* f, const char* ext=0); 62 iterator SearchName(const char* f, const char* ext=0);
63 public: 63 public:
64 ARCFILE(const char* fname); 64 ARCFILE(const char* fname);
65 void SetNext(ARCFILE* _next) { delete next; next = _next;} 65 void SetNext(ARCFILE* _next) { delete next; next = _next;}
66 ARCFILE* Next(void) { return next; } 66 ARCFILE* Next(void) { return next; }
67 void Init(void); 67 void Init(void);
68 virtual ~ARCFILE(); 68 virtual ~ARCFILE();
69 /* ファイル検索 */ 69 /* ファイル検索 */
70 class ARCINFO* Find(const char* fname, const char* ext); 70 class ARCINFO* Find(const char* fname, const char* ext);
71 /* ファイルリストの出力 */ 71 /* ファイルリストの出力 */
72 int Deal(void) { Init(); return arc_atom.size(); } 72 int Deal(void) { Init(); return arc_atom.size(); }
73 void ListFiles(FILE* out); 73 void ListFiles(FILE* out);
74 void InitList(void); 74 void InitList(void);
75 char* ListItem(void); 75 char* ListItem(void);
76 }; 76 };
77 77
78 class SCN2kFILE : public ARCFILE { 78 class SCN2kFILE : public ARCFILE {
79 protected: 79 protected:
80 virtual int CheckFileDeal(void); 80 virtual int CheckFileDeal(void);
81 virtual void ListupFiles(int fname_len); 81 virtual void ListupFiles(int fname_len);
82 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom); 82 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom);
83 public: 83 public:
84 SCN2kFILE(char* fname) : ARCFILE(fname) {} 84 SCN2kFILE(char* fname) : ARCFILE(fname) {}
85 virtual ~SCN2kFILE() {} 85 virtual ~SCN2kFILE() {}
86 }; 86 };
87 87
88 class CattleyaFILE : public ARCFILE { 88 class CattleyaFILE : public ARCFILE {
89 bool is_compress; 89 private:
90 /* header の Huffman 木構築用 */ 90 bool is_compress;
91 char* bitbuf; 91 /* header の Huffman 木構築用 */
92 char* bitbuf_end; 92 char* bitbuf;
93 int ltree[0x400]; 93 char* bitbuf_end;
94 int rtree[0x400]; 94 int ltree[0x400];
95 int treecnt; 95 int rtree[0x400];
96 int bitcnt; 96 int treecnt;
97 int GetBit(void); 97 int bitcnt;
98 int GetCh(void); 98 int GetBit(void);
99 void SetBuf(char* buf, int len); 99 int GetCh(void);
100 int MakeTree(void); 100 void SetBuf(char* buf, int len);
101 int Decode(int seed); 101 int MakeTree(void);
102 int Decode(int seed);
102 103
103 protected: 104 protected:
104 virtual int CheckFileDeal(void); 105 virtual int CheckFileDeal(void);
105 virtual void ListupFiles(int fname_len); 106 virtual void ListupFiles(int fname_len);
106 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom); 107 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom);
107 public: 108
108 CattleyaFILE(char* fname) : ARCFILE(fname) {is_compress = false;} 109 public:
109 virtual ~CattleyaFILE() {} 110 CattleyaFILE(char* fname) : ARCFILE(fname) {is_compress = false;}
111 virtual ~CattleyaFILE() {}
110 }; 112 };
111 113
112 class NULFILE : public ARCFILE { 114 class NULFILE : public ARCFILE {
113 protected: 115 protected:
114 virtual int CheckFileDeal(void); 116 virtual int CheckFileDeal(void);
115 virtual void ListupFiles(int fname_len); 117 virtual void ListupFiles(int fname_len);
116 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom); 118 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom);
117 public: 119 public:
118 NULFILE() : ARCFILE("") {} 120 NULFILE() : ARCFILE("") {}
119 virtual ~NULFILE() {} 121 virtual ~NULFILE() {}
120 }; 122 };
123
121 class DIRFILE : public ARCFILE { 124 class DIRFILE : public ARCFILE {
122 protected: 125 protected:
123 virtual int CheckFileDeal(void); 126 virtual int CheckFileDeal(void);
124 virtual void ListupFiles(int fname_len); 127 virtual void ListupFiles(int fname_len);
125 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom); 128 virtual ARCINFO* MakeARCINFO(ARCFILE_ATOM& atom);
126 public: 129 public:
127 DIRFILE(char* fname) : ARCFILE(fname) {} 130 DIRFILE(char* fname) : ARCFILE(fname) {}
128 virtual ~DIRFILE() {} 131 virtual ~DIRFILE() {}
129 FILE* Open(const char* fname); /* FILE* を開く */ 132 FILE* Open(const char* fname); /* FILE* を開く */
130 char* SearchFile(const char* dirname); /* ファイル検索 */ 133 char* SearchFile(const char* dirname); /* ファイル検索 */
131 }; 134 };
135
132 class ARCINFO_AVG32 : public ARCINFO { 136 class ARCINFO_AVG32 : public ARCINFO {
133 ARCINFO_AVG32(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name, atom) { 137 protected:
134 } 138 ARCINFO_AVG32(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name, atom) {
135 virtual bool ExecExtract(void); 139 }
136 friend class ARCFILE; 140 virtual bool ExecExtract(void);
141 friend class ARCFILE;
137 }; 142 };
143
138 class ARCINFO2k : public ARCINFO { 144 class ARCINFO2k : public ARCINFO {
139 static char decode_seed[256]; 145 private:
140 static char decode_seed2[16]; 146 static char decode_seed[256];
141 protected: 147 static char decode_seed2[16];
142 ARCINFO2k(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name,atom) { 148 protected:
143 } 149 ARCINFO2k(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name,atom) {
144 virtual bool ExecExtract(void); 150 }
145 friend class SCN2kFILE; 151 virtual bool ExecExtract(void);
152 friend class SCN2kFILE;
146 }; 153 };
147 154
148 class ARCINFOZ : public ARCINFO { 155 class ARCINFOZ : public ARCINFO {
149 protected: 156 protected:
150 ARCINFOZ(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name, atom) { 157 ARCINFOZ(const char* name, ARCFILE_ATOM& atom) : ARCINFO(name, atom) {
151 } 158 }
152 virtual bool ExecExtract(void); 159 virtual bool ExecExtract(void);
153 friend class DaemonBaneFILE; 160 friend class DaemonBaneFILE;
154 friend class CattleyaFILE; 161 friend class CattleyaFILE;
155 }; 162 };
156 163
157 #endif /* __FILE_IMPL_H__ */ 164 #endif /* __FILE_IMPL_H__ */