7 #include "cheprep/ZipOutputStream.h"
8 #include "cheprep/ZipOutputStreamBuffer.h"
9 #include "cheprep/ZipEntry.h"
17 ZipOutputStreamBuffer::ZipOutputStreamBuffer(std::streambuf* aBuffer)
18 : DeflateOutputStreamBuffer(aBuffer),
24 entries =
new std::vector<ZipEntry*>();
27 int ZipOutputStreamBuffer::overflow(
int c) {
28 return DeflateOutputStreamBuffer::overflow(c);
31 void ZipOutputStreamBuffer::closeEntry() {
33 if (entry == NULL)
return;
37 entry->crc = getCRC();
39 entry->csize = (long)
pos() - entry->data;
40 entry->size = getSize();
49 void ZipOutputStreamBuffer::close() {
53 long dirStart =
pos();
54 for (std::vector<ZipEntry*>::iterator i=entries->begin(); i != entries->end(); i++) {
58 putUS(VERSIONEXTRACT);
66 putUS(entry->name.length());
80 long dirSize = (long)
pos() - dirStart;
84 putUS(entries->size());
85 putUS(entries->size());
88 putUS(comment.length());
96 void ZipOutputStreamBuffer::putNextEntry(
const std::string&
name,
bool compress) {
101 #ifdef CHEPREP_NO_ZLIB
106 entry =
new ZipEntry();
107 entries->push_back(entry);
110 entry->method = compress ? 8 : 0;
114 struct tm *utc = gmtime( <ime );
115 entry->date = (utc->tm_year - 80) << 9 | (utc->tm_mon + 1) << 5 | utc->tm_mday;
116 entry->time = utc->tm_hour << 11 | utc->tm_min << 5 | utc->tm_sec >> 1;
118 entry->offset = (long)
pos();
120 putUS(VERSIONEXTRACT);
122 putUS(entry->method);
128 putUS(entry->name.length());
131 entry->data = (long)
pos();
135 void ZipOutputStreamBuffer::setComment(
const std::string& c) {
140 ZipOutputStreamBuffer::~ZipOutputStreamBuffer() {
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
static const G4double pos