1 #ifdef SOPLEX_WITH_ZLIB 35 #ifdef GZSTREAM_NAMESPACE 36 namespace GZSTREAM_NAMESPACE
48 gzstreambuf* gzstreambuf::open(
const char* _name,
int _open_mode)
53 mode =
static_cast<unsigned int>(_open_mode);
56 if((mode & std::ios::ate) || (mode & std::ios::app)
57 || ((mode & std::ios::in) && (mode & std::ios::out)))
61 char* fmodeptr = fmode;
63 if(mode & std::ios::in)
65 else if(mode & std::ios::out)
70 file = gzopen(_name, fmode);
79 gzstreambuf* gzstreambuf::close()
86 if(gzclose(file) == Z_OK)
93 int gzstreambuf::underflow()
95 if(gptr() && (gptr() < egptr()))
96 return *
reinterpret_cast<unsigned char*
>(gptr());
98 if(!(mode & std::ios::in) || ! opened)
102 size_t n_putback = (size_t)(gptr() - eback());
107 memcpy(buffer + (4 - n_putback), gptr() - n_putback, n_putback);
109 int num = gzread(file, buffer + 4, bufferSize - 4);
115 setg(buffer + (4 - n_putback),
120 return *
reinterpret_cast<unsigned char*
>(gptr());
123 int gzstreambuf::flush_buffer()
127 int w =
static_cast<int>(pptr() - pbase());
129 if(gzwrite(file, pbase(), (
unsigned int) w) != w)
136 int gzstreambuf::overflow(
int c)
138 if(!(mode & std::ios::out) || ! opened)
143 *pptr() =
static_cast<char>(c);
147 if(flush_buffer() == EOF)
153 int gzstreambuf::sync()
158 if(pptr() && pptr() > pbase())
160 if(flush_buffer() == EOF)
171 gzstreambase::gzstreambase(
const char* name,
int mode)
177 gzstreambase::~gzstreambase()
182 void gzstreambase::open(
const char* _name,
int _open_mode)
184 if(! buf.open(_name, _open_mode))
185 setstate(std::ios::badbit);
190 void gzstreambase::close()
194 setstate(std::ios::badbit);
199 #ifdef GZSTREAM_NAMESPACE