// Try open file stream bool FXBZFileStream::open(const FXString& filename,FXStreamDirection save_or_load,FXuval size){ if(FXFileStream::open(filename,save_or_load,size)){ if(FXCALLOC(&bz,BZBlock,1)){ int bzerror; bz->stream.next_in=NULL; bz->stream.avail_in=0; bz->stream.next_out=NULL; bz->stream.avail_out=0; ac=BZ_RUN; if(save_or_load==FXStreamLoad){ bzerror=BZ2_bzDecompressInit(&bz->stream,VERBOSITY,0); if(bzerror==BZ_OK) return true; code=FXStreamNoRead; } else{ bzerror=BZ2_bzCompressInit(&bz->stream,BLOCKSIZE100K,VERBOSITY,WORKFACTOR); if(bzerror==BZ_OK) return true; code=FXStreamNoWrite; } FXFREE(&bz); } FXFileStream::close(); } return false; }
// Try open file stream bool FXGZFileStream::open(const FXString& filename,FXStreamDirection save_or_load,FXuval size){ if(FXFileStream::open(filename,save_or_load,size)){ if(FXCALLOC(&z,ZBlock,1)){ int zerror; z->stream.next_in=NULL; z->stream.avail_in=0; z->stream.next_out=NULL; z->stream.avail_out=0; f=Z_NO_FLUSH; if(save_or_load==FXStreamLoad){ zerror=inflateInit(&z->stream); if(zerror==Z_OK) return true; code=FXStreamNoRead; } else{ zerror=deflateInit(&z->stream,Z_DEFAULT_COMPRESSION); if(zerror==Z_OK) return true; code=FXStreamNoWrite; } FXFREE(&z); } FXFileStream::close(); } return false; }