Пример #1
0
bool QUnZip::getCurrentFile(QIODevice &d) {
    if (!isOpen()) {
        qWarning("QUnZip::locateFile File not open.");
        return false;
    }
    if (!d.isWritable()) {
        qWarning("QUnZip::getCurrentFile File not open for writing.");
        return false;
    }
    if (unzOpenCurrentFile(_d->_unzFile) != UNZ_OK) {
        qWarning("QUnZip::getCurrentFile unzOpenCurrentFile failed.");
        return false;
    }
    char * buf = new char[1024];
    Q_CHECK_PTR(buf);
    int len;
    while ((len = ::unzReadCurrentFile(_d->_unzFile,
                buf, 1024)) > 0) {
        d.writeBlock(buf, len);
    }
    delete []buf;
    ::unzCloseCurrentFile(_d->_unzFile);
    if (d.isBuffered())
        d.flush();
    if (len == 0) {
        return true;
    }
    qWarning("QUnZip::getCurrentFile unzReadCurrentFile failed.");
    return false;
}
Пример #2
0
static
void CALLBACK_CALL_TYPE qpiw_flush_fn( png_structp png_ptr )
{
    QPNGImageWriter* qpiw = (QPNGImageWriter*)png_get_io_ptr( png_ptr );
    QIODevice* out = qpiw->device();

    out->flush();
}
Пример #3
0
    static
    void qt_term_destination(j_compress_ptr cinfo)
    {
        my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest;
        QIODevice* dev = dest->iio->ioDevice();
        int n = max_buf - dest->free_in_buffer;

        if ( dev->writeBlock( (char*)dest->buffer, n ) != n )
            qt_exit_on_error(cinfo, dev);

        dev->flush();

        qt_exit_on_error(cinfo, dev);
    }
Пример #4
0
bool QUnZip::getCurrentFileRaw(QIODevice &d, int &method,
        unsigned long &crc, unsigned long &uncompressed_size) {
    if (!isOpen()) {
        qWarning("QUnZip::getCurrentFileRaw File not open.");
        return false;
    }
    if (!d.isWritable()) {
        qWarning("QUnZip::getCurrentFileRaw File not open for writing.");
        return false;
    }
    if (unzOpenCurrentFile2(_d->_unzFile, &method, NULL, 1) != UNZ_OK) {
        qWarning("QUnZip::getCurrentFileRaw unzOpenCurrentFile2 failed.");
        return false;
    }
    unz_file_info fi;
    if (::unzGetCurrentFileInfo(_d->_unzFile, &fi,
                NULL, 0 , NULL, 0, NULL, 0) != UNZ_OK) {
        qWarning("QUnZip::getCurrentFileRaw unzGetCurrentFileInfo failed.");
        return false;
    }
    crc = fi.crc;
    uncompressed_size = fi.uncompressed_size;

    char * buf = new char[1024];
    Q_CHECK_PTR(buf);
    int len;
    while ((len = ::unzReadCurrentFile(_d->_unzFile,
                buf, 1024)) > 0) {
        d.writeBlock(buf, len);
    }
    delete[] buf;
    ::unzCloseCurrentFile(_d->_unzFile);
    if (d.isBuffered())
        d.flush();
    if (len == 0) {
        return true;
    }
    qWarning("QUnZip::getCurrentFileRaw unzReadCurrentFile failed.");
    return false;
}