4#include "zipios++/zipios-config.h"
6#include "zipios++/meta-iostreams.h"
23 friend istream &operator>> ( istream &is,
ZipLocalEntry &zcdh ) ;
24 friend ostream &operator<< ( ostream &os,
const ZipLocalEntry &zlh ) ;
28 const vector< unsigned char > &_extra_field =
29 vector< unsigned char >() )
37 void setDefaultExtract() ;
41 virtual uint32
getCrc()
const ;
42 virtual vector< unsigned char >
getExtra()
const ;
44 virtual string getName()
const ;
46 virtual uint32
getSize()
const ;
52 virtual void setComment(
const string &comment ) ;
54 virtual void setCrc( uint32 crc ) ;
55 virtual void setExtra(
const vector< unsigned char > &extra ) ;
57 virtual void setName(
const string &name ) ;
58 virtual void setSize( uint32 size ) ;
59 virtual void setTime(
int time ) ;
63 int getLocalHeaderSize()
const ;
65 bool trailingDataDescriptor()
const ;
71 static const uint32 signature ;
72 uint16 extract_version ;
74 uint16 compress_method ;
75 uint16 last_mod_ftime ;
76 uint16 last_mod_fdate ;
78 uint32 compress_size ;
79 uint32 uncompress_size ;
81 uint16 extra_field_len ;
84 vector< unsigned char > extra_field ;
95 uint32 compress_size ;
96 uint32 uncompress_size ;
103friend istream &operator>> ( istream &is,
ZipCDirEntry &zcdh ) ;
104friend ostream &operator<< ( ostream &os,
const ZipCDirEntry &zcdh ) ;
109 const string &_file_comment =
"",
110 const vector< unsigned char > &_extra_field =
111 vector< unsigned char >() )
113 disk_num_start ( 0x0 ),
114 intern_file_attr( 0x0 ),
115 extern_file_attr( 0x81B40000 )
124 void setDefaultWriter() ;
131 virtual void setComment(
const string &comment ) ;
133 virtual uint32 getLocalHeaderOffset()
const ;
134 virtual void setLocalHeaderOffset( uint32 offset ) ;
136 int getCDirHeaderSize()
const ;
142 static const uint32 signature ;
143 uint16 writer_version ;
145 uint16 file_comment_len ;
146 uint16 disk_num_start ;
147 uint16 intern_file_attr ;
148 uint32 extern_file_attr ;
150 uint32 rel_offset_loc_head ;
152 string file_comment ;
163 uint16 _disk_num = 0, uint16 _cdir_disk_num = 0,
164 uint16 _cdir_entries = 0,
165 uint16 _cdir_tot_entries = 0,
166 uint32 _cdir_size = 0, uint32 _cdir_offset = 0 )
167 : disk_num ( _disk_num ),
168 cdir_disk_num ( _cdir_disk_num ),
169 cdir_entries ( _cdir_entries ),
170 cdir_tot_entries ( _cdir_tot_entries ),
171 cdir_size ( _cdir_size ),
172 cdir_offset ( _cdir_offset ),
173 zip_comment_len ( _zip_comment.size() ),
174 zip_comment ( _zip_comment ) {}
176 uint32 offset()
const {
return cdir_offset ; }
177 uint16 totalCount()
const {
return cdir_tot_entries ; }
178 void setCDirSize( uint32 size ) { cdir_size = size ; }
179 void setOffset( uint32 offset ) { cdir_offset = offset ; }
181 void setTotalCount( uint16 c ) { cdir_entries = c ; cdir_tot_entries = c ; }
182 int eocdOffSetFromEnd()
const {
return eocd_offset_from_end ; }
183 bool read( vector<unsigned char> &buf,
int pos ) ;
185 static const uint32 signature;
187 uint16 cdir_disk_num ;
188 uint16 cdir_entries ;
189 uint16 cdir_tot_entries ;
192 uint16 zip_comment_len ;
194 streampos eocd_offset_from_end ;
196 bool checkSignature(
unsigned char *buf )
const ;
197 inline bool checkSignature( uint32 sig )
const ;
205inline bool operator!= (
const ZipLocalEntry &zlh,
const ZipCDirEntry &ze ) {
206 return ! ( zlh == ze ) ;
208inline bool operator!= (
const ZipCDirEntry &ze,
const ZipLocalEntry &zlh ) {
209 return ! ( zlh == ze ) ;
214ZipCDirEntry &ZipCDirEntry::operator=(
const class ZipCDirEntry &src ) {
215 writer_version = src.writer_version ;
216 extract_version = src.extract_version ;
217 gp_bitfield = src.gp_bitfield ;
218 compress_method = src.compress_method ;
219 last_mod_ftime = src.last_mod_ftime ;
220 last_mod_fdate = src.last_mod_fdate ;
221 crc_32 = src.crc_32 ;
222 compress_size = src.compress_size ;
223 uncompress_size = src.uncompress_size ;
224 filename_len = src.filename_len ;
225 extra_field_len = src.extra_field_len ;
226 file_comment_len = src.file_comment_len ;
227 disk_num_start = src.disk_num_start ;
228 intern_file_attr = src.intern_file_attr ;
229 extern_file_attr = src.extern_file_attr ;
230 rel_offset_loc_head = src.rel_offset_loc_head ;
232 filename = src.filename ;
233 extra_field = src.extra_field ;
234 file_comment = src.file_comment ;
239bool EndOfCentralDirectory::checkSignature ( uint32 sig )
const {
240 return signature == sig ;
The end of the Central directory structure.
A FileEntry represents an entry in a FileCollection.
Specialization of ZipLocalEntry, that add fields for storing the extra information,...
virtual FileEntry * clone() const
Create a heap allocated clone of the object this method is called for.
virtual string getComment() const
Returns the comment of the entry, if it has one.
virtual void setComment(const string &comment)
Sets the comment field for the FileEntry.
virtual string toString() const
Returns a human-readable string representation of the entry.
A concrete implementation of the abstract FileEntry base class for ZipFile entries,...
virtual StorageMethod getMethod() const
Returns the method used to store the entry in the FileCollection.
virtual vector< unsigned char > getExtra() const
Returns a vector of bytes of extra data that may be stored with the entry.
virtual void setExtra(const vector< unsigned char > &extra)
Sets the extra field.
virtual int getTime() const
Returns the date and time of FIXME: what?
virtual string getFileName() const
Returns the filename of the entry.
virtual void setComment(const string &comment)
Sets the comment field for the FileEntry.
virtual bool isValid() const
Any method or operator that initializes a FileEntry may set a flag, that specifies whether the read e...
virtual void setSize(uint32 size)
Sets the size field for the entry.
virtual void setTime(int time)
Sets the time field for the entry.
virtual uint32 getCompressedSize() const
Returns the compressed size of the entry.
virtual void setMethod(StorageMethod method)
Sets the storage method field for the entry.
virtual string getComment() const
Returns the comment of the entry, if it has one.
virtual string getName() const
Returns the full filename of the entry, including a path if the entry is stored in a subfolder.
virtual string toString() const
Returns a human-readable string representation of the entry.
virtual FileEntry * clone() const
Create a heap allocated clone of the object this method is called for.
virtual uint32 getCrc() const
Returns the Crc for the entry, if it has one.
virtual bool isDirectory() const
Returns true if the entry is a directory.
virtual void setCrc(uint32 crc)
Sets the crc field.
virtual void setCompressedSize(uint32 size)
Set the compressed size field of the entry.
virtual uint32 getSize() const
Returns the (uncompressed) size of the entry data.
virtual void setName(const string &name)
Sets the name field for the entry.
Header file that defines FileEntry.
StorageMethod
The types used with FileEntry::setMethod and FileEntry::getMethod.
A struct containing fields for the entries in a zip file data descriptor, that trails the compressed ...
Header file that defines some simple data types.