33 #ifdef GZSTREAM_NAMESPACE 34 namespace GZSTREAM_NAMESPACE {
45 gzstreambuf* gzstreambuf::open(
const char* _name,
int _open_mode) {
50 if ((
mode & std::ios::ate) || (
mode & std::ios::app)
51 || ((
mode & std::ios::in) && (
mode & std::ios::out)))
54 char* fmodeptr = fmode;
55 if (
mode & std::ios::in)
57 else if (
mode & std::ios::out)
61 file = gzopen( _name, fmode);
68 gzstreambuf * gzstreambuf::close() {
72 if ( gzclose( file) == Z_OK)
78 int gzstreambuf::underflow() {
79 if ( gptr() && ( gptr() < egptr()))
80 return *
reinterpret_cast<unsigned char *
>( gptr());
82 if ( ! (
mode & std::ios::in) || ! opened)
85 int n_putback = gptr() - eback();
88 memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback);
90 int num = gzread( file, buffer+4, bufferSize-4);
95 setg( buffer + (4 - n_putback),
100 return *
reinterpret_cast<unsigned char *
>( gptr());
103 int gzstreambuf::flush_buffer() {
106 int w = pptr() - pbase();
107 if ( gzwrite( file, pbase(), w) != w)
113 int gzstreambuf::overflow(
int c) {
114 if ( ! (
mode & std::ios::out) || ! opened)
120 if ( flush_buffer() == EOF)
125 int gzstreambuf::sync() {
129 if ( pptr() && pptr() > pbase()) {
130 if ( flush_buffer() == EOF)
140 gzstreambase::gzstreambase(
const char*
name,
int mode) {
145 gzstreambase::~gzstreambase() {
149 void gzstreambase::open(
const char* _name,
int _open_mode) {
150 if ( ! buf.open( _name, _open_mode))
151 setstate(std::ios::badbit);
155 void gzstreambase::close() {
158 setstate(std::ios::badbit);
162 #ifdef GZSTREAM_NAMESPACE mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
const dimensionedScalar c
Speed of light in a vacuum.
word name(const complex &)
Return a string representation of a complex.