diff options
Diffstat (limited to 'src/corelib/io/qfsfileengine_unix.cpp')
-rw-r--r-- | src/corelib/io/qfsfileengine_unix.cpp | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 4ee5c68..3bc2616 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -394,7 +394,10 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - return unlink(d->nativeFilePath.constData()) == 0; + bool ret = unlink(d->nativeFilePath.constData()) == 0; + if (!ret) + setError(QFile::RemoveError, qt_error_string(errno)); + return ret; } bool QFSFileEngine::copy(const QString &newName) @@ -422,6 +425,7 @@ bool QFSFileEngine::copy(const QString &newName) return (err == KErrNone); #else // ### Add copy code for Unix here + setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); return false; #endif } @@ -429,13 +433,19 @@ bool QFSFileEngine::copy(const QString &newName) bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - return ::rename(d->nativeFilePath.constData(), QFile::encodeName(newName).constData()) == 0; + bool ret = ::rename(d->nativeFilePath.constData(), QFile::encodeName(newName).constData()) == 0; + if (!ret) + setError(QFile::RenameError, qt_error_string(errno)); + return ret; } bool QFSFileEngine::link(const QString &newName) { Q_D(QFSFileEngine); - return ::symlink(d->nativeFilePath.constData(), QFile::encodeName(newName).constData()) == 0; + bool ret = ::symlink(d->nativeFilePath.constData(), QFile::encodeName(newName).constData()) == 0; + if (!ret) + setError(QFile::RenameError, qt_error_string(errno)); + return ret; } qint64 QFSFileEnginePrivate::nativeSize() const @@ -1143,6 +1153,7 @@ QString QFSFileEngine::owner(FileOwner own) const bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); + bool ret = false; mode_t mode = 0; if (perms & ReadOwnerPerm) mode |= S_IRUSR; @@ -1169,18 +1180,27 @@ bool QFSFileEngine::setPermissions(uint perms) if (perms & ExeOtherPerm) mode |= S_IXOTH; if (d->fd != -1) - return !fchmod(d->fd, mode); - return !::chmod(d->nativeFilePath.constData(), mode); + ret = fchmod(d->fd, mode) == 0; + else + ret = ::chmod(d->nativeFilePath.constData(), mode) == 0; + if (!ret) + setError(QFile::PermissionsError, qt_error_string(errno)); + return ret; } bool QFSFileEngine::setSize(qint64 size) { Q_D(QFSFileEngine); + bool ret = false; if (d->fd != -1) - return !QT_FTRUNCATE(d->fd, size); - if (d->fh) - return !QT_FTRUNCATE(QT_FILENO(d->fh), size); - return !QT_TRUNCATE(d->nativeFilePath.constData(), size); + ret = QT_FTRUNCATE(d->fd, size) == 0; + else if (d->fh) + ret = QT_FTRUNCATE(QT_FILENO(d->fh), size) == 0; + else + ret = QT_TRUNCATE(d->nativeFilePath.constData(), size) == 0; + if (!ret) + setError(QFile::ResizeError, qt_error_string(errno)); + return ret; } QDateTime QFSFileEngine::fileTime(FileTime time) const @@ -1202,14 +1222,14 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla { Q_Q(QFSFileEngine); Q_UNUSED(flags); - if (offset < 0) { - q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); - return 0; - } if (openMode == QIODevice::NotOpen) { q->setError(QFile::PermissionsError, qt_error_string(int(EACCES))); return 0; } + if (offset < 0) { + q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL))); + return 0; + } int access = 0; if (openMode & QIODevice::ReadOnly) access |= PROT_READ; if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE; |