Rizin
unix-like reverse engineering framework and cli tools
gzifstream Class Reference

Gzipped file input stream class. More...

#include <zfstream.h>

Inheritance diagram for gzifstream:
gzfilestream_common

Public Member Functions

 gzifstream ()
 
 gzifstream (const char *name, int io_mode=ios::in)
 
 gzifstream (int fd, int io_mode=ios::in)
 
virtual ~gzifstream ()
 
 gzifstream ()
 
 gzifstream (const char *name, std::ios_base::openmode mode=std::ios_base::in)
 Construct stream on gzipped file to be opened. More...
 
 gzifstream (int fd, std::ios_base::openmode mode=std::ios_base::in)
 Construct stream on already open gzipped file. More...
 
gzfilebufrdbuf () const
 
bool is_open ()
 Check if file is open. More...
 
void open (const char *name, std::ios_base::openmode mode=std::ios_base::in)
 Open gzipped file. More...
 
void attach (int fd, std::ios_base::openmode mode=std::ios_base::in)
 Attach to already open gzipped file. More...
 
void close ()
 Close gzipped file. More...
 
- Public Member Functions inherited from gzfilestream_common
virtual ~gzfilestream_common ()
 
void attach (int fd, int io_mode)
 
void open (const char *name, int io_mode)
 
void close ()
 

Private Attributes

gzfilebuf sb
 

Additional Inherited Members

- Protected Member Functions inherited from gzfilestream_common
 gzfilestream_common ()
 

Detailed Description

Gzipped file input stream class.

This class implements ifstream for gzipped files. Seeking and putback is not supported yet.

Definition at line 68 of file zfstream.h.

Constructor & Destructor Documentation

◆ gzifstream() [1/6]

gzifstream::gzifstream ( )

Definition at line 291 of file zfstream.cpp.

291  :
293 {
294  clear( ios::badbit );
295 }
gzfilebuf * rdbuf()
Definition: zfstream.cpp:286

◆ gzifstream() [2/6]

gzifstream::gzifstream ( const char *  name,
int  io_mode = ios::in 
)

Definition at line 297 of file zfstream.cpp.

297  :
299 {
300  gzfilestream_common::open( name, io_mode );
301 }
void open(const char *name, int io_mode)
Definition: zfstream.cpp:270
Definition: z80asm.h:102

References gzfilestream_common::open().

◆ gzifstream() [3/6]

gzifstream::gzifstream ( int  fd,
int  io_mode = ios::in 
)

Definition at line 303 of file zfstream.cpp.

303  :
305 {
306  gzfilestream_common::attach( fd, io_mode );
307 }
void attach(int fd, int io_mode)
Definition: zfstream.cpp:261
static const z80_opcode fd[]
Definition: z80_tab.h:997

References gzfilestream_common::attach(), and fd.

◆ ~gzifstream()

gzifstream::~gzifstream ( )
virtual

Definition at line 309 of file zfstream.cpp.

309 { }

◆ gzifstream() [4/6]

gzifstream::gzifstream ( )

◆ gzifstream() [5/6]

gzifstream::gzifstream ( const char *  name,
std::ios_base::openmode  mode = std::ios_base::in 
)
explicit

Construct stream on gzipped file to be opened.

Parameters
nameFile name.
modeOpen mode flags (forced to contain ios::in).

Definition at line 379 of file zfstream.cc.

381 : std::istream(NULL), sb()
382 {
383  this->init(&sb);
384  this->open(name, mode);
385 }
gzfilebuf sb
Definition: zfstream.h:312
void open(const char *name, std::ios_base::openmode mode=std::ios_base::in)
Open gzipped file.
Definition: zfstream.cc:398
#define NULL
Definition: cris-opc.c:27
const char int mode
Definition: ioapi.h:137
bool init
Definition: core.c:77

References init, open(), and sb.

◆ gzifstream() [6/6]

gzifstream::gzifstream ( int  fd,
std::ios_base::openmode  mode = std::ios_base::in 
)
explicit

Construct stream on already open gzipped file.

Parameters
fdFile descriptor.
modeOpen mode flags (forced to contain ios::in).

Definition at line 388 of file zfstream.cc.

390 : std::istream(NULL), sb()
391 {
392  this->init(&sb);
393  this->attach(fd, mode);
394 }
void attach(int fd, std::ios_base::openmode mode=std::ios_base::in)
Attach to already open gzipped file.
Definition: zfstream.cc:409

References attach(), init, and sb.

Member Function Documentation

◆ attach()

void gzifstream::attach ( int  fd,
std::ios_base::openmode  mode = std::ios_base::in 
)

Attach to already open gzipped file.

Parameters
fdFile descriptor.
modeOpen mode flags (forced to contain ios::in).

Stream will be in state good() if attach succeeded; otherwise in state fail().

Definition at line 409 of file zfstream.cc.

411 {
412  if (!sb.attach(fd, mode | std::ios_base::in))
413  this->setstate(std::ios_base::failbit);
414  else
415  this->clear();
416 }
const lzma_allocator const uint8_t * in
Definition: block.h:527
gzfilebuf * attach(int file_descriptor, int io_mode)
Definition: zfstream.cpp:60

References gzfilebuf::attach(), fd, in, and sb.

Referenced by gzifstream().

◆ close()

void gzifstream::close ( )

Close gzipped file.

Stream will be in state fail() if close failed.

Definition at line 420 of file zfstream.cc.

421 {
422  if (!sb.close())
423  this->setstate(std::ios_base::failbit);
424 }
gzfilebuf * close()
Definition: zfstream.cpp:102

References gzfilebuf::close(), and sb.

◆ is_open()

bool gzifstream::is_open ( )
inline

Check if file is open.

Returns
True if file is open.

Definition at line 270 of file zfstream.h.

270 { return sb.is_open(); }
int is_open() const
Definition: zfstream.h:22

References gzfilebuf::is_open(), and sb.

◆ open()

void gzifstream::open ( const char *  name,
std::ios_base::openmode  mode = std::ios_base::in 
)

Open gzipped file.

Parameters
nameFile name.
modeOpen mode flags (forced to contain ios::in).

Stream will be in state good() if file opens successfully; otherwise in state fail(). This differs from the behavior of ifstream, which never sets the state to good() and therefore won't allow you to reuse the stream for a second file unless you manually clear() the state. The choice is a matter of convenience.

Definition at line 398 of file zfstream.cc.

400 {
401  if (!sb.open(name, mode | std::ios_base::in))
402  this->setstate(std::ios_base::failbit);
403  else
404  this->clear();
405 }
gzfilebuf * open(const char *name, int io_mode)
Definition: zfstream.cpp:18

References in, gzfilebuf::open(), and sb.

Referenced by gzifstream().

◆ rdbuf()

gzfilebuf* gzifstream::rdbuf ( ) const
inline

Obtain underlying stream buffer.

Definition at line 262 of file zfstream.h.

263  { return const_cast<gzfilebuf*>(&sb); }
Gzipped file stream buffer class.
Definition: zfstream.h:8

References sb.

Member Data Documentation

◆ sb

gzfilebuf gzifstream::sb
private

Underlying stream buffer.

Definition at line 312 of file zfstream.h.

Referenced by attach(), close(), gzifstream(), is_open(), open(), and rdbuf().


The documentation for this class was generated from the following files: