Logo Search packages:      
Sourcecode: inkscape version File versions

void Inkscape::IO::GzipOutputStream::flush (  )  [virtual]

Flushes this output stream and forces any buffered output bytes to be written out.

Reimplemented from Inkscape::IO::BasicOutputStream.

Definition at line 305 of file gzipstream.cpp.

References Inkscape::IO::OutputStream::flush(), and Inkscape::IO::OutputStream::put().

Referenced by close().

{
    if (closed || inputBuf.size()<1)
        return;
    
    uLong srclen = inputBuf.size();
    Bytef *srcbuf = (Bytef *)malloc(srclen * sizeof(Byte));
    if (!srcbuf)
        {
        return;
        }
        
    uLong destlen = srclen;
    Bytef *destbuf = (Bytef *)malloc((destlen + (srclen/100) + 13) * sizeof(Byte));
    if (!destbuf)
        {
        free(srcbuf);
        return;
        }
        
    std::vector<unsigned char>::iterator iter;
    Bytef *p = srcbuf;
    for (iter=inputBuf.begin() ; iter != inputBuf.end() ; iter++)
        *p++ = *iter;
        
    crc = crc32(crc, (const Bytef *)srcbuf, srclen);
    
    int zerr = compress(destbuf, (uLongf *)&destlen, srcbuf, srclen);
    if (zerr != Z_OK)
        {
        printf("Some kind of problem\n");
        }

    totalOut += destlen;
    //skip the redundant zlib header and checksum
    for (uLong i=2; i<destlen-4 ; i++)
        {
        destination.put((int)destbuf[i]);
        }
        
    destination.flush();

    inputBuf.clear();
    free(srcbuf);
    free(destbuf);
    
    printf("done\n");
    
}


Generated by  Doxygen 1.6.0   Back to index