/* Flushes all pending input if necessary, closes the compressed file *anddeallocatesallthe(de)compressionstate.Thereturnvalueis *thezliberrornumber(seefunctionerror()below).
*/ int close() { int r = ::gzclose(m_fp);
m_fp = 0; return r;
}
/* Binary read the given number of bytes from the compressed file.
*/ int read(void* buf, size_t len) { return ::gzread(m_fp, buf, len);
}
/* Returns the error message for the last error which occurred on the *givencompressedfile.errnumissettozliberrornumber.Ifan *erroroccurredinthefilesystemandnotinthecompressionlibrary, *errnumissettoZ_ERRNOandtheapplicationmayconsulterrno *togettheexacterrorcode.
*/ constchar* error(int* errnum) { return ::gzerror(m_fp, errnum);
}
/* Opens a gzip (.gz) file for writing. *Thecompressionlevelparametershouldbein0..9 *errnocanbecheckedtodistinguishtwoerrorcases *(iferrnoiszero,thezliberrorisZ_MEM_ERROR).
*/ void open(constchar* name, int level = Z_DEFAULT_COMPRESSION) { char mode[4] = "wb\0"; if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; if (m_fp) close();
m_fp = ::gzopen(name, mode);
}
/* open from a FILE pointer.
*/ void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) {
SET_BINARY_MODE(fp); char mode[4] = "wb\0"; if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; if (m_fp) close();
m_fp = ::gzdopen(fileno(fp), mode);
}
/* Flushes all pending output if necessary, closes the compressed file *anddeallocatesallthe(de)compressionstate.Thereturnvalueis *thezliberrornumber(seefunctionerror()below).
*/ int close() { if (m_os) {
::gzwrite(m_fp, m_os->str(), m_os->pcount()); delete[] m_os->str(); delete m_os; m_os = 0;
} int r = ::gzclose(m_fp); m_fp = 0; return r;
}
/* Binary write the given number of bytes into the compressed file.
*/ int write(constvoid* buf, size_t len) { return ::gzwrite(m_fp, (voidp) buf, len);
}
/* Flushes all pending output into the compressed file. The parameter *_flushisasinthedeflate()function.Thereturnvalueisthezlib *errornumber(seefunctiongzerrorbelow).flush()returnsZ_OKif *theflush_parameterisZ_FINISHandalloutputcouldbeflushed. *flush()shouldbecalledonlywhenstrictlynecessarybecauseitcan *degradecompression.
*/ int flush(int _flush) {
os_flush(); return ::gzflush(m_fp, _flush);
}
/* Returns the error message for the last error which occurred on the *givencompressedfile.errnumissettozliberrornumber.Ifan *erroroccurredinthefilesystemandnotinthecompressionlibrary, *errnumissettoZ_ERRNOandtheapplicationmayconsulterrno *togettheexacterrorcode.
*/ constchar* error(int* errnum) { return ::gzerror(m_fp, errnum);
}
gzFile fp() { return m_fp; }
ostream& os() { if (m_os == 0) m_os = new ostrstream; return *m_os;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.