Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

qint64 QFile::writeData ( const char *  data,
qint64  len 
) [protected, virtual, inherited]

Implements QIODevice.

Definition at line 1585 of file qfile.cpp.

References QAbstractFileEngine::error(), QIODevice::errorString(), QFile::fileEngine(), QFile::flush(), and QAbstractFileEngine::write().

{
    Q_D(QFile);
    d->error = NoError;
    d->lastWasWrite = true;
    bool buffered = !(d->openMode & Unbuffered);

    // Flush buffered data if this read will overflow.
    if (buffered && (d->writeBuffer.size() + len) > QFILE_WRITEBUFFER_SIZE) {
        if (!flush())
            return -1;
    }

    // Write directly to the engine if the block size is larger than
    // the write buffer size.
    if (!buffered || len > QFILE_WRITEBUFFER_SIZE) {
        QAbstractFileEngine *fe = d->fileEngine ? d->fileEngine : fileEngine();
        qint64 ret = fe->write(data, len);
        if(ret < 0) {
            QFile::FileError err = fileEngine()->error();
            if(err == QFile::UnspecifiedError)
                err = QFile::WriteError;
            d->setError(err, fileEngine()->errorString());
        }
        return ret;
    }

    // Write to the buffer.
    char *writePointer = d->writeBuffer.reserve(len);
    if (len == 1)
        *writePointer = *data;
    else
        ::memcpy(writePointer, data, len);
    return len;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index