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

bool QFile::open ( OpenMode  mode  )  [virtual]

Opens the file using OpenMode mode.

The mode must be QIODevice::ReadOnly, QIODevice::WriteOnly, or QIODevice::ReadWrite. It may also have additional flags, such as QIODevice::Text and QIODevice::Unbuffered.

See also:
QIODevice::OpenMode

Reimplemented from QIODevice.

Reimplemented in QTemporaryFile.

Definition at line 855 of file qfile.cpp.

References QAbstractFileEngine::error(), QIODevice::errorString(), fileEngine(), QIODevice::isOpen(), seek(), QIODevice::setOpenMode(), size(), and unsetError().

Referenced by QFontDatabase::addApplicationFont(), QGLContext::bindTexture(), copy(), QTemporaryFile::createLocalFile(), QImageReader::imageFormat(), QTranslator::load(), QPicture::load(), Q3Picture::load(), QTextBrowser::loadResource(), QTemporaryFile::open(), Q3LocalFs::operationGet(), Q3LocalFs::operationPut(), QPictureIO::pictureFormat(), QTextStream::QTextStream(), QPictureIO::read(), rename(), QPicture::save(), and QPictureIO::write().

{
    Q_D(QFile);
    if (isOpen()) {
        qWarning("QFile::open: File already open");
        return false;
    }
    if (mode & Append)
        mode |= WriteOnly;

    unsetError();
    if ((mode & (ReadOnly | WriteOnly)) == 0) {
        qWarning("QIODevice::open: File access not specified");
        return false;
    }
    if (fileEngine()->open(mode)) {
        setOpenMode(mode);
        if (mode & Append)
            seek(size());
        return true;
    }
    QFile::FileError err = fileEngine()->error();
    if(err == QFile::UnspecifiedError)
        err = QFile::OpenError;
    d->setError(err, fileEngine()->errorString());
    return false;
}


Generated by  Doxygen 1.6.0   Back to index