1/************** filamzip H Declares Source Code File (.H) **************/
2/* Name: filamzip.h Version 1.2 */
3/* */
4/* (C) Copyright to the author Olivier BERTRAND 2016-2017 */
5/* */
6/* This file contains the ZIP file access method classes declares. */
7/***********************************************************************/
8#ifndef __FILAMZIP_H
9#define __FILAMZIP_H
10
11#include "block.h"
12#include "filamap.h"
13#include "filamfix.h"
14#include "zip.h"
15#include "unzip.h"
16
17#define DLLEXPORT extern "C"
18
19typedef class UNZFAM *PUNZFAM;
20typedef class UZXFAM *PUZXFAM;
21typedef class ZIPFAM *PZIPFAM;
22typedef class ZPXFAM *PZPXFAM;
23
24/***********************************************************************/
25/* This is the ZIP utility fonctions class. */
26/***********************************************************************/
27class DllExport ZIPUTIL : public BLOCK {
28 public:
29 // Constructor
30 ZIPUTIL(PCSZ tgt);
31 //ZIPUTIL(ZIPUTIL *zutp);
32
33 // Methods
34 bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn, bool append);
35 bool open(PGLOBAL g, PCSZ fn, bool append);
36 bool addEntry(PGLOBAL g, PCSZ entry);
37 void close(void);
38 void closeEntry(void);
39 int writeEntry(PGLOBAL g, char *buf, int len);
40 void getTime(tm_zip& tmZip);
41
42 // Members
43 zipFile zipfile; // The ZIP container file
44 PCSZ target; // The target file name
45 PCSZ pwd; // The ZIP file password
46 PFBLOCK fp;
47 bool entryopen; // True when open current entry
48}; // end of ZIPUTIL
49
50/***********************************************************************/
51/* This is the unZIP utility fonctions class. */
52/***********************************************************************/
53class DllExport UNZIPUTL : public BLOCK {
54 public:
55 // Constructor
56 UNZIPUTL(PCSZ tgt, bool mul);
57 UNZIPUTL(PDOSDEF tdp);
58
59 // Implementation
60//PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UNZFAM(this); }
61
62 // Methods
63 bool OpenTable(PGLOBAL g, MODE mode, PCSZ fn);
64 bool open(PGLOBAL g, PCSZ fn);
65 bool openEntry(PGLOBAL g);
66 void close(void);
67 void closeEntry(void);
68 bool WildMatch(PCSZ pat, PCSZ str);
69 int findEntry(PGLOBAL g, bool next);
70 int nextEntry(PGLOBAL g);
71 bool IsInsertOk(PGLOBAL g, PCSZ fn);
72
73 // Members
74 unzFile zipfile; // The ZIP container file
75 PCSZ target; // The target file name
76 PCSZ pwd; // The ZIP file password
77 unz_file_info finfo; // The current file info
78 PFBLOCK fp;
79 char *memory;
80 uint size;
81 int multiple; // Multiple targets
82 bool entryopen; // True when open current entry
83 char fn[FILENAME_MAX]; // The current entry file name
84 char mapCaseTable[256];
85}; // end of UNZIPUTL
86
87/***********************************************************************/
88/* This is the unzip file access method. */
89/***********************************************************************/
90class DllExport UNZFAM : public MAPFAM {
91//friend class UZXFAM;
92 public:
93 // Constructors
94 UNZFAM(PDOSDEF tdp);
95 UNZFAM(PUNZFAM txfp);
96
97 // Implementation
98 virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
99 virtual PTXF Duplicate(PGLOBAL g) {return (PTXF) new(g) UNZFAM(this);}
100
101 // Methods
102 virtual int Cardinality(PGLOBAL g);
103 virtual int GetFileLength(PGLOBAL g);
104 //virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
105 virtual bool OpenTableFile(PGLOBAL g);
106 virtual bool DeferReading(void) { return false; }
107 virtual int GetNext(PGLOBAL g);
108 //virtual int ReadBuffer(PGLOBAL g);
109 //virtual int WriteBuffer(PGLOBAL g);
110 //virtual int DeleteRecords(PGLOBAL g, int irc);
111 //virtual void CloseTableFile(PGLOBAL g, bool abort);
112
113 protected:
114 // Members
115 UNZIPUTL *zutp;
116 PDOSDEF tdfp;
117}; // end of UNZFAM
118
119/***********************************************************************/
120/* This is the fixed unzip file access method. */
121/***********************************************************************/
122class DllExport UZXFAM : public MPXFAM {
123//friend class UNZFAM;
124 public:
125 // Constructors
126 UZXFAM(PDOSDEF tdp);
127 UZXFAM(PUZXFAM txfp);
128
129 // Implementation
130 virtual AMT GetAmType(void) { return TYPE_AM_ZIP; }
131 virtual PTXF Duplicate(PGLOBAL g) { return (PTXF) new(g)UZXFAM(this); }
132
133 // Methods
134 virtual int GetFileLength(PGLOBAL g);
135 virtual int Cardinality(PGLOBAL g);
136 virtual bool OpenTableFile(PGLOBAL g);
137 virtual int GetNext(PGLOBAL g);
138 //virtual int ReadBuffer(PGLOBAL g);
139
140 protected:
141 // Members
142 UNZIPUTL *zutp;
143 PDOSDEF tdfp;
144}; // end of UZXFAM
145
146/***********************************************************************/
147/* This is the zip file access method. */
148/***********************************************************************/
149class DllExport ZIPFAM : public DOSFAM {
150 public:
151 // Constructors
152 ZIPFAM(PDOSDEF tdp);
153
154 // Implementation
155 virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
156
157 // Methods
158 virtual int Cardinality(PGLOBAL g) {return 0;}
159 virtual int GetFileLength(PGLOBAL g) {return g ? 0 : 1;}
160 //virtual int MaxBlkSize(PGLOBAL g, int s) {return s;}
161 virtual bool OpenTableFile(PGLOBAL g);
162 virtual int ReadBuffer(PGLOBAL g);
163 virtual int WriteBuffer(PGLOBAL g);
164 //virtual int DeleteRecords(PGLOBAL g, int irc);
165 virtual void CloseTableFile(PGLOBAL g, bool abort);
166
167 protected:
168 // Members
169 ZIPUTIL *zutp;
170 PCSZ target;
171 bool append;
172//bool replace;
173}; // end of ZIPFAM
174
175/***********************************************************************/
176/* This is the fixed zip file access method. */
177/***********************************************************************/
178class DllExport ZPXFAM : public FIXFAM {
179 public:
180 // Constructors
181 ZPXFAM(PDOSDEF tdp);
182
183 // Implementation
184 virtual AMT GetAmType(void) {return TYPE_AM_ZIP;}
185
186 // Methods
187 virtual int Cardinality(PGLOBAL g) {return 0;}
188 virtual int GetFileLength(PGLOBAL g) {return g ? 0 : 1;}
189 virtual bool OpenTableFile(PGLOBAL g);
190 virtual int WriteBuffer(PGLOBAL g);
191 virtual void CloseTableFile(PGLOBAL g, bool abort);
192
193 protected:
194 // Members
195 ZIPUTIL *zutp;
196 PCSZ target;
197 bool append;
198}; // end of ZPXFAM
199
200#endif // __FILAMZIP_H
201