15 #define BIGBUFSIZE BUFSIZ
16 #define SMALLBUFSIZE 1
22 :
file(
NULL), io_mode(std::ios_base::openmode(0)), own_fd(
false),
26 this->disable_buffer();
52 std::ios_base::openmode
mode)
62 char char_mode[6] =
"\0\0\0\0\0";
80 std::ios_base::openmode
mode)
90 char char_mode[6] =
"\0\0\0\0\0";
115 if (this->
sync() == -1)
137 bool testt =
mode & std::ios_base::trunc;
138 bool testa =
mode & std::ios_base::app;
145 if (!testi && testo && !testt && !testa)
147 if (!testi && testo && !testt && testa)
149 if (!testi && testo && testt && !testa)
151 if (testi && !testo && !testt && !testa)
160 if (strlen(c_mode) == 0)
175 if (this->gptr() && (this->gptr() < this->egptr()))
176 return std::streamsize(this->egptr() - this->gptr());
188 if (this->gptr() && (this->gptr() < this->egptr()))
189 return traits_type::to_int_type(*(this->gptr()));
193 return traits_type::eof();
203 return traits_type::eof();
209 return traits_type::to_int_type(*(this->gptr()));
220 if (this->pptr() > this->epptr() || this->pptr() < this->pbase())
221 return traits_type::eof();
223 if (!traits_type::eq_int_type(
c, traits_type::eof()))
225 *(this->pptr()) = traits_type::to_char_type(
c);
229 int bytes_to_write = this->pptr() - this->pbase();
231 if (bytes_to_write > 0)
235 return traits_type::eof();
237 if (
gzwrite(
file, this->pbase(), bytes_to_write) != bytes_to_write)
238 return traits_type::eof();
240 this->pbump(-bytes_to_write);
244 else if (!traits_type::eq_int_type(
c, traits_type::eof()))
248 return traits_type::eof();
250 char_type last_char = traits_type::to_char_type(
c);
253 return traits_type::eof();
258 if (traits_type::eq_int_type(
c, traits_type::eof()))
259 return traits_type::not_eof(
c);
270 if (this->
sync() == -1)
301 return traits_type::eq_int_type(this->
overflow(), traits_type::eof()) ? -1 : 0;
375 : std::istream(
NULL),
sb()
380 std::ios_base::openmode
mode)
381 : std::istream(
NULL),
sb()
389 std::ios_base::openmode
mode)
390 : std::istream(
NULL),
sb()
399 std::ios_base::openmode
mode)
402 this->setstate(std::ios_base::failbit);
410 std::ios_base::openmode
mode)
413 this->setstate(std::ios_base::failbit);
423 this->setstate(std::ios_base::failbit);
430 : std::ostream(
NULL),
sb()
435 std::ios_base::openmode
mode)
436 : std::ostream(
NULL),
sb()
444 std::ios_base::openmode
mode)
445 : std::ostream(
NULL),
sb()
454 std::ios_base::openmode
mode)
457 this->setstate(std::ios_base::failbit);
465 std::ios_base::openmode
mode)
468 this->setstate(std::ios_base::failbit);
478 this->setstate(std::ios_base::failbit);
const lzma_allocator const uint8_t * in
const lzma_allocator const uint8_t size_t uint8_t * out
Gzipped file stream buffer class.
std::streamsize buffer_size
Stream buffer size.
std::ios_base::openmode io_mode
bool own_fd
True if this object owns file descriptor.
gzfilebuf * attach(int file_descriptor, int io_mode)
virtual int overflow(int=EOF)
virtual std::streambuf * setbuf(char_type *p, std::streamsize n)
Installs external stream buffer.
void disable_buffer()
Destroy internal buffer.
char_type * buffer
Stream buffer.
bool open_mode(std::ios_base::openmode mode, char *c_mode) const
Convert ios open mode int to mode string used by zlib.
bool own_buffer
True if this object owns stream buffer.
int setcompression(int comp_level, int comp_strategy=Z_DEFAULT_STRATEGY)
Set compression level and strategy on the fly.
void enable_buffer()
Allocate internal buffer.
gzfilebuf * open(const char *name, int io_mode)
virtual std::streamsize showmanyc()
Number of characters available in stream buffer.
void close()
Close gzipped file.
void attach(int fd, std::ios_base::openmode mode=std::ios_base::in)
Attach to already open gzipped file.
void open(const char *name, std::ios_base::openmode mode=std::ios_base::in)
Open gzipped file.
void close()
Close gzipped file.
void attach(int fd, std::ios_base::openmode mode=std::ios_base::out)
Attach to already open gzipped file.
void open(const char *name, std::ios_base::openmode mode=std::ios_base::out)
Open gzipped file.
int ZEXPORT gzclose(gzFile file)
gzFile ZEXPORT gzopen(char *path, const char *mode) const
gzFile ZEXPORT gzdopen(int fd, const char *mode)
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
int ZEXPORT gzsetparams(gzFile file, int level, int strategy)
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
static char * binary(unsigned int val, unsigned int bits)
static const z80_opcode fd[]
#define buffer_size(buffer)