33 #ifdef GZSTREAM_NAMESPACE
34 namespace GZSTREAM_NAMESPACE {
49 if ((mode & std::ios::ate) || (mode & std::ios::app) ||
50 ((mode & std::ios::in) && (mode & std::ios::out)))
53 char* fmodeptr = fmode;
54 if (mode & std::ios::in)
56 else if (mode & std::ios::out)
60 file = gzopen(name, fmode);
70 if (gzclose(file) == Z_OK)
return this;
76 if (gptr() && (gptr() < egptr()))
77 return *
reinterpret_cast<unsigned char*
>(gptr());
79 if (!(mode & std::ios::in) || !opened)
return EOF;
81 assert(gptr() != NULL);
82 int n_putback = (int)(gptr() - eback());
83 if (n_putback > 4) n_putback = 4;
84 memcpy(buffer + (4 - n_putback), gptr() - n_putback, n_putback);
86 int num = gzread(file, buffer + 4, bufferSize - 4);
91 setg(buffer + (4 - n_putback),
96 return *
reinterpret_cast<unsigned char*
>(gptr());
102 int w = (int)(pptr() - pbase());
103 if (gzwrite(file, pbase(),
w) !=
w)
return EOF;
109 if (!(mode & std::ios::out) || !opened)
return EOF;
114 if (flush_buffer() == EOF)
return EOF;
122 if (pptr() && pptr() > pbase()) {
123 if (flush_buffer() == EOF)
return -1;
140 if (!buf.open(name, gz_open_mode)) clear(rdstate() | std::ios::badbit);
145 if (!buf.close()) clear(rdstate() | std::ios::badbit);
148 #ifdef GZSTREAM_NAMESPACE