コード例 #1
0
ファイル: qunzip.cpp プロジェクト: acassis/lintouch
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
ファイル: bstring.cpp プロジェクト: serghei/kde3-kdenetwork
bool BString::writeToDevice(QIODevice &device)
{
    if (!m_valid)
        return false;

    QString str = QString("%1:").
        arg(get_len());

    QCString utfString = str.utf8();

    /* Don't write null terminator */
    device.writeBlock (utfString.data(), utfString.size() - 1);

    // Output the actual data
    device.writeBlock (m_data.data(), m_data.size() - 1);

    // Done
    return true;
}
コード例 #3
0
ファイル: qpngio.cpp プロジェクト: AliYousuf/univ-aca-mips
static
void CALLBACK_CALL_TYPE qpiw_write_fn( png_structp png_ptr, png_bytep data, png_size_t length )
{
    QPNGImageWriter* qpiw = (QPNGImageWriter*)png_get_io_ptr( png_ptr );
    QIODevice* out = qpiw->device();

    uint nr = out->writeBlock( (char*)data, length );
    if ( nr != length ) {
	png_error( png_ptr, "Write Error" );
	return;
    }
}
コード例 #4
0
ファイル: blist.cpp プロジェクト: serghei/kde3-kdenetwork
bool BList::writeToDevice(QIODevice &device)
{
    if (!m_valid)
        return false;

    const char *l_str = "l";
    const char *e_str = "e";
    Q_LONG written = 0, result = 0;
    
    written = device.writeBlock (l_str, 1);
    while (written < 1)
    {
        if (written < 0 || result < 0)
            return false;
            
        result = device.writeBlock (l_str, 1);
        written += result;
    }
    
    BBaseVectorIterator iter;
    for (iter = begin(); iter != end(); ++iter)
    {
        if (!((*iter)->writeToDevice (device)))
            return false;
    }
    
    written = device.writeBlock (e_str, 1);
    while (written < 1)
    {
        if (written < 0 || result < 0)
            return false;
            
        result = device.writeBlock (e_str, 1);
        written += result;
    }
    
    return true;
}
コード例 #5
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);
    }
コード例 #6
0
    static
    boolean qt_empty_output_buffer(j_compress_ptr cinfo)
    {
        my_jpeg_destination_mgr* dest = (my_jpeg_destination_mgr*)cinfo->dest;
        QIODevice* dev = dest->iio->ioDevice();

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

        dest->next_output_byte = dest->buffer;
        dest->free_in_buffer = max_buf;

#if defined(_OS_UNIXWARE7_)
        return B_TRUE;
#else
        return TRUE;
#endif
    }
コード例 #7
0
ファイル: qunzip.cpp プロジェクト: acassis/lintouch
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;
}
コード例 #8
0
void test_block_write(const QString &fileName)
{
    QIODevice *dev = KFilterDev::deviceForFile(fileName);
    if(!dev)
    {
        kdWarning() << "dev=0" << endl;
        return;
    }
    if(!dev->open(IO_WriteOnly))
    {
        kdWarning() << "open failed " << endl;
        return;
    }

    QCString s("hello\n");
    int ret = dev->writeBlock(s, s.size() - 1);
    kdDebug() << "writeBlock ret=" << ret << endl;
    // ret = dev->writeBlock( s, s.size()-1 );
    // kdDebug() << "writeBlock ret=" << ret << endl;
    dev->close();
    delete dev;
}