44 #ifdef GZSTREAM_NAMESPACE 45 namespace GZSTREAM_NAMESPACE {
56 gzstreambuf* gzstreambuf::open(
const char* _name,
int _open_mode) {
61 if ((
mode & std::ios::ate) || (
mode & std::ios::app)
62 || ((
mode & std::ios::in) && (
mode & std::ios::out)))
65 char* fmodeptr = fmode;
66 if (
mode & std::ios::in)
68 else if (
mode & std::ios::out)
72 file = gzopen( _name, fmode);
79 gzstreambuf * gzstreambuf::close() {
83 if ( gzclose( file) == Z_OK)
89 int gzstreambuf::underflow() {
90 if ( gptr() && ( gptr() < egptr()))
91 return *
reinterpret_cast<unsigned char *
>( gptr());
93 if ( ! (
mode & std::ios::in) || ! opened)
96 int n_putback = gptr() - eback();
99 std::memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback);
101 int num = gzread( file, buffer+4, bufferSize-4);
106 setg( buffer + (4 - n_putback),
111 return *
reinterpret_cast<unsigned char *
>( gptr());
114 int gzstreambuf::flush_buffer() {
117 int w = pptr() - pbase();
118 if ( gzwrite( file, pbase(), w) != w)
124 int gzstreambuf::overflow(
int c) {
125 if ( ! (
mode & std::ios::out) || ! opened)
131 if ( flush_buffer() == EOF)
136 int gzstreambuf::sync() {
140 if ( pptr() && pptr() > pbase()) {
141 if ( flush_buffer() == EOF)
151 gzstreambase::gzstreambase(
const char*
name,
int mode) {
156 gzstreambase::~gzstreambase() {
160 void gzstreambase::open(
const char* _name,
int _open_mode) {
161 if ( ! buf.open( _name, _open_mode))
162 setstate(std::ios::badbit);
166 void gzstreambase::close() {
169 setstate(std::ios::badbit);
173 #ifdef GZSTREAM_NAMESPACE word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
const dimensionedScalar c
Speed of light in a vacuum.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.