1 /* This file is Copyright 2000-2013 Meyer Sound Laboratories Inc. See the included LICENSE.txt file for details. */ 2 3 #ifndef GZDataIO_h 4 #define GZDataIO_h 5 6 #ifdef MUSCLE_ENABLE_ZLIB_ENCODING 7 8 # include "dataio/DataIO.h" 9 # include "zlib/zlib/zlib.h" // for gzFile 10 11 namespace muscle { 12 13 /** This class wraps around zlib's gzread() and gzwrite() APIs so that you 14 * can use it to read or write .gz files. This is currently implemented for 15 * blocking I/O only. 16 */ 17 class GZDataIO : public DataIO 18 { 19 public: 20 /** Constructor 21 * @param filePath the path to the gz-compressed file to read or write 22 * @param mode the mode-string to pass to gzopen() (e.g. "wb9" to write with maximum compression) 23 */ 24 GZDataIO(const char * filePath, const char * mode); 25 26 /** Destructor */ 27 virtual ~GZDataIO(); 28 29 virtual int32 Read(void * buffer, uint32 size); 30 virtual int32 Write(const void * buffer, uint32 size); 31 virtual void FlushOutput(); 32 virtual void Shutdown(); 33 34 /** Returns a NULL ConstSocketRef -- selecting on this class is not currently supported */ 35 virtual const ConstSocketRef & GetReadSelectSocket() const; 36 37 /** Returns a NULL ConstSocketRef -- selecting on this class is not currently supported */ 38 virtual const ConstSocketRef & GetWriteSelectSocket() const; 39 40 private: 41 DECLARE_COUNTED_OBJECT(GZDataIO); 42 43 void ShutdownAux(); 44 45 gzFile _file; 46 }; 47 DECLARE_REFTYPES(GZDataIO); 48 49 } // end namespace muscle 50 51 #endif 52 53 #endif