Exemplo n.º 1
0
void KBzip2Filter::terminate()
{
    if ( m_mode == IO_ReadOnly )
    {
        int result = bzDecompressEnd(&d->zStream);
        kdDebug(7118) << "bzDecompressEnd returned " << result << endl;
    } else if ( m_mode == IO_WriteOnly )
    {
        int result = bzCompressEnd(&d->zStream);
        kdDebug(7118) << "bzCompressEnd returned " << result << endl;
    } else
        kdWarning(7118) << "Unsupported mode " << m_mode << ". Only IO_ReadOnly and IO_WriteOnly supported" << endl;
}
Exemplo n.º 2
0
Compressor::~Compressor()
   // The deconstructor
{
   if(isinitialized)
      // We finish compression, if there has been some data in the queue
   {
#ifdef USE_BZIP
      bzCompressEnd(&state);
#else
      deflateEnd(&state);
#endif

//      deflateReset(&state);
      isinitialized=0;
   }
}
Exemplo n.º 3
0
bool KBzip2Filter::terminate()
{
    if (d->mode == QIODevice::ReadOnly) {
        const int result = bzDecompressEnd(&d->zStream);
        if (result != BZ_OK) {
            //qDebug() << "bzDecompressEnd returned " << result;
            return false;
        }
    } else if (d->mode == QIODevice::WriteOnly) {
        const int result = bzCompressEnd(&d->zStream);
        if (result != BZ_OK) {
            //qDebug() << "bzCompressEnd returned " << result;
            return false;
        }
    } else {
        //qWarning() << "Unsupported mode " << d->mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported";
        return false;
    }
    d->isInitialized = false;
    return true;
}
Exemplo n.º 4
0
void Compressor::FinishCompress(unsigned long *uncompressedsize,unsigned long *compressedsize)
   // Finishes the compression and stores the input data size and
   // the output data size in 'uncompressedsize' and 'compressedsize'
{
   char err;
   int   saveavail;

   do
   {
      // Let's get more space in the output buffer
#ifdef USE_BZIP
      state.next_out=output->GetBufPtr((int *)&state.avail_out);
#else
      state.next_out=(unsigned char *)output->GetBufPtr((int *)&state.avail_out);
#endif

      saveavail=state.avail_out;

#ifdef USE_BZIP
      err=bzCompress(&state,BZ_FINISH);
#else
      err=deflate(&state,Z_FINISH);
#endif

      output->SaveBytes(saveavail-state.avail_out);

#ifdef USE_BZIP
      if(err==BZ_STREAM_END)
         break;
      if(err!=BZ_FINISH_OK)
#else
      if(err==Z_STREAM_END)
         break;
      if(err!=Z_OK)
#endif
      {
         Error("Error while compressing container!");
         Exit();
      }

      // Z_OK means that the output buffer is full ! ==> We flush
      output->Flush();
   }
   while(1);

   // Let's store the input and output size
   if(uncompressedsize!=NULL) *uncompressedsize =state.total_in;
   if(compressedsize!=NULL)   *compressedsize   =state.total_out;

   state.total_out=0;
   state.total_in=0;

   // Finally, we release the internal memory
#ifdef USE_BZIP
   if(bzCompressEnd(&state)!=BZ_OK)
#else
   if(deflateReset(&state)!=Z_OK)
#endif
   {  
      Error("Error while compressing container!");
      Exit();
   }
#ifdef USE_BZIP
   // bzip must be reinitialized
   isinitialized=0;
#endif
}