From a4e8b396bf6e4b4531b4bcf7b7901cfcd0002219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 24 Aug 2010 11:07:28 +0200 Subject: Adding placeholder for internal QFileSystemEntry class Reviewed-by: Thomas Zander --- src/corelib/io/io.pri | 6 ++-- src/corelib/io/qfilesystementry.cpp | 41 ++++++++++++++++++++++++ src/corelib/io/qfilesystementry_p.h | 64 +++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 src/corelib/io/qfilesystementry.cpp create mode 100644 src/corelib/io/qfilesystementry_p.h diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 3d964c6..bb38f42 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -29,7 +29,8 @@ HEADERS += \ io/qfsfileengine_p.h \ io/qfsfileengine_iterator_p.h \ io/qfilesystemwatcher.h \ - io/qfilesystemwatcher_p.h + io/qfilesystemwatcher_p.h \ + io/qfilesystementry_p.h SOURCES += \ io/qabstractfileengine.cpp \ @@ -52,7 +53,8 @@ SOURCES += \ io/qsettings.cpp \ io/qfsfileengine.cpp \ io/qfsfileengine_iterator.cpp \ - io/qfilesystemwatcher.cpp + io/qfilesystemwatcher.cpp \ + io/qfilesystementry.cpp win32 { SOURCES += io/qsettings_win.cpp diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp new file mode 100644 index 0000000..36ec012 --- /dev/null +++ b/src/corelib/io/qfilesystementry.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h new file mode 100644 index 0000000..2054f62 --- /dev/null +++ b/src/corelib/io/qfilesystementry_p.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFILESYSTEMENTRY_P_H_INCLUDED +#define QFILESYSTEMENTRY_P_H_INCLUDED + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QFileSystemEntry +{ +}; + +QT_END_NAMESPACE + +#endif // include guard -- cgit v0.12 From 68f5623c6efcc76163fc3c5f8154aecf90c618f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 24 Aug 2010 11:18:35 +0200 Subject: Adding internal classes QFileSystem{Engine,MetaData} Empty for now. Reviewed-by: Thomas Zander --- src/corelib/io/io.pri | 4 ++- src/corelib/io/qfilesystemengine_p.h | 64 ++++++++++++++++++++++++++++++++++ src/corelib/io/qfilesystemmetadata_p.h | 64 ++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 src/corelib/io/qfilesystemengine_p.h create mode 100644 src/corelib/io/qfilesystemmetadata_p.h diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index bb38f42..0334534 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -30,7 +30,9 @@ HEADERS += \ io/qfsfileengine_iterator_p.h \ io/qfilesystemwatcher.h \ io/qfilesystemwatcher_p.h \ - io/qfilesystementry_p.h + io/qfilesystementry_p.h \ + io/qfilesystemengine_p.h \ + io/qfilesystemmetadata_p.h SOURCES += \ io/qabstractfileengine.cpp \ diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h new file mode 100644 index 0000000..817f925 --- /dev/null +++ b/src/corelib/io/qfilesystemengine_p.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFILESYSTEMENGINE_P_H_INCLUDED +#define QFILESYSTEMENGINE_P_H_INCLUDED + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QFileSystemEngine +{ +}; + +QT_END_NAMESPACE + +#endif // include guard diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h new file mode 100644 index 0000000..c051bc5 --- /dev/null +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFILESYSTEMMETADATA_P_H_INCLUDED +#define QFILESYSTEMMETADATA_P_H_INCLUDED + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +QT_BEGIN_NAMESPACE + +class QFileSystemMetaData +{ +}; + +QT_END_NAMESPACE + +#endif // include guard -- cgit v0.12 From b5905172d3c68f9b64334d9a2796bdf1df65e607 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 24 Aug 2010 12:23:44 +0200 Subject: Add constructors and basic getters to QFilesystemEntry Reviewed-by: Prasanth Ullattil --- src/corelib/io/qfilesystementry.cpp | 67 +++++++++++++++++++++++++++++++++++++ src/corelib/io/qfilesystementry_p.h | 24 +++++++++++++ 2 files changed, 91 insertions(+) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 36ec012..1cc82ef 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -39,3 +39,70 @@ ** ****************************************************************************/ +#include "qfilesystementry_p.h" +#include "qdir.h" + +QFileSystemEntry::QFileSystemEntry(const QString &filePath) + : m_filePath(filePath), + m_lastSeparator(-2) +{ +} + +QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath) + : m_nativeFilePath(nativeFilePath), + m_lastSeparator(-2) +{ +} + +QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath, const QString &filePath) + : m_filePath(filePath), + m_nativeFilePath(nativeFilePath), + m_lastSeparator(-2) +{ +} + +QString QFileSystemEntry::filePath() const +{ + resolveFilePath(); + return m_filePath; +} + +QByteArray QFileSystemEntry::nativeFileName() const +{ + resolveNativeFilePath(); + return m_nativeFilePath; +} + +void QFileSystemEntry::resolveFilePath() const +{ + if (m_filePath.isEmpty() && !m_nativeFilePath.isEmpty()) { + m_filePath = QDir::fromNativeSeparators(QString::fromLocal8Bit(m_nativeFilePath)); + } +} + +void QFileSystemEntry::resolveNativeFilePath() const +{ + if (!m_filePath.isEmpty() && m_nativeFilePath.isEmpty()) { + m_nativeFilePath = m_filePath.toLocal8Bit(); + } +} + +QString QFileSystemEntry::fileName() const +{ + findLastSeparator(); + return m_filePath.mid(m_lastSeparator + 1); +} + +void QFileSystemEntry::findLastSeparator() const +{ + resolveFilePath(); + if (m_lastSeparator == -2) { + m_lastSeparator = -1; + for (int i = m_filePath.size() - 1; i >= 0; --i) { + if (m_filePath[i].unicode() == '/') { + m_lastSeparator = i; + break; + } + } + } +} diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 2054f62..3e67174 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -53,10 +53,34 @@ // We mean it. // +#include +#include + QT_BEGIN_NAMESPACE class QFileSystemEntry { + QFileSystemEntry(const QString &filePath); + QFileSystemEntry(const QByteArray &nativeFilePath); + QFileSystemEntry(const QByteArray &nativeFilePath, const QString &filePath); + + QString filePath() const; + QString fileName() const; + QByteArray nativeFileName() const; + +private: + // creates the QString version out of the bytearray version + void resolveFilePath() const; + // creates the bytearray version out of the QString version + void resolveNativeFilePath() const; + void findLastSeparator() const; + + mutable QString m_filePath; // always has slashes as separator + mutable QByteArray m_nativeFilePath; // native encoding and separators + + mutable int m_lastSeparator : 16; + + int dummy : 16; }; QT_END_NAMESPACE -- cgit v0.12 From a5c215ac09e9ede853024fc69a0b74a7af820ea4 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 24 Aug 2010 13:54:05 +0200 Subject: Add some more methods to the QFileSystemEntry --- src/corelib/io/qfilesystementry.cpp | 87 ++++++++++++++++++++++++++++++++++--- src/corelib/io/qfilesystementry_p.h | 15 +++++-- 2 files changed, 94 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 1cc82ef..3e8b8b2 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -44,20 +44,26 @@ QFileSystemEntry::QFileSystemEntry(const QString &filePath) : m_filePath(filePath), - m_lastSeparator(-2) + m_lastSeparator(-2), + m_firstDotInFileName(-2), + m_lastDotInFileName(0) { } QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath) : m_nativeFilePath(nativeFilePath), - m_lastSeparator(-2) + m_lastSeparator(-2), + m_firstDotInFileName(-2), + m_lastDotInFileName(0) { } QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath, const QString &filePath) : m_filePath(filePath), m_nativeFilePath(nativeFilePath), - m_lastSeparator(-2) + m_lastSeparator(-2), + m_firstDotInFileName(-2), + m_lastDotInFileName(0) { } @@ -83,7 +89,7 @@ void QFileSystemEntry::resolveFilePath() const void QFileSystemEntry::resolveNativeFilePath() const { if (!m_filePath.isEmpty() && m_nativeFilePath.isEmpty()) { - m_nativeFilePath = m_filePath.toLocal8Bit(); + m_nativeFilePath = QDir::toNativeSeparators(m_filePath).toLocal8Bit(); } } @@ -93,10 +99,37 @@ QString QFileSystemEntry::fileName() const return m_filePath.mid(m_lastSeparator + 1); } -void QFileSystemEntry::findLastSeparator() const +QString QFileSystemEntry::suffix() const +{ + findFileNameSeparators(); + + if (m_lastDotInFileName == -1) + return QString(); + + return m_filePath.mid(m_lastSeparator + m_lastDotInFileName + 1); +} + +QString QFileSystemEntry::completeSuffix() const +{ + findFileNameSeparators(); + if (m_firstDotInFileName == -1) + return QString(); + + return m_filePath.mid(m_lastSeparator + m_firstDotInFileName + 1); +} + +bool QFileSystemEntry::isAbsolute() const { resolveFilePath(); + return !m_filePath.isEmpty() && (m_filePath[0].unicode() == '/' /*|| hasScheme()*/); +} + +// private methods + +void QFileSystemEntry::findLastSeparator() const +{ if (m_lastSeparator == -2) { + resolveFilePath(); m_lastSeparator = -1; for (int i = m_filePath.size() - 1; i >= 0; --i) { if (m_filePath[i].unicode() == '/') { @@ -106,3 +139,47 @@ void QFileSystemEntry::findLastSeparator() const } } } + +void QFileSystemEntry::findFileNameSeparators() const +{ + if (m_firstDotInFileName == -2) { + resolveFilePath(); + int firstDotInFileName = -1; + int lastDotInFileName = -1; + int lastSeparator = m_lastSeparator; + + int stop; + if (lastSeparator < 0) { + lastSeparator = -1; + stop = 0; + } else { + stop = lastSeparator; + } + + int i = m_filePath.size() - 1; + for (; i >= stop; --i) { + if (m_filePath[i].unicode() == '.') { + firstDotInFileName = lastDotInFileName = i; + break; + } else if (m_filePath[i].unicode() == '/') { + lastSeparator = i; + break; + } + } + + if (lastSeparator != i) { + for (--i; i >= stop; --i) { + if (m_filePath[i].unicode() == '.') + firstDotInFileName = i; + else if (m_filePath[i].unicode() == '/') { + lastSeparator = i; + break; + } + } + } + + m_lastSeparator = lastSeparator; + m_firstDotInFileName = firstDotInFileName == -1 ? -1 : firstDotInFileName - lastSeparator; + m_lastDotInFileName = lastDotInFileName == -1 ? -1 : lastDotInFileName - firstDotInFileName - lastSeparator; + } +} diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 3e67174..1812b9f 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -67,20 +67,29 @@ class QFileSystemEntry QString filePath() const; QString fileName() const; QByteArray nativeFileName() const; + QString suffix() const; + QString completeSuffix() const; + bool isAbsolute() const; + bool isRelative() const { + return !isAbsolute(); + } private: // creates the QString version out of the bytearray version void resolveFilePath() const; // creates the bytearray version out of the QString version void resolveNativeFilePath() const; + // resolves the separator void findLastSeparator() const; + /// resolves the dots and the separator + void findFileNameSeparators() const; mutable QString m_filePath; // always has slashes as separator mutable QByteArray m_nativeFilePath; // native encoding and separators - mutable int m_lastSeparator : 16; - - int dummy : 16; + mutable int m_lastSeparator : 16; // index in m_filePath of last separator + mutable int m_firstDotInFileName : 11; // index after m_filePath for first dot (.) + mutable int m_lastDotInFileName : 5; // index after m_firstDotInFileName for last dot (.) }; QT_END_NAMESPACE -- cgit v0.12 From e6ad5637e5a482e81461166170d8327f896bcbc6 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 24 Aug 2010 14:47:41 +0200 Subject: Move QFileInfoPrivate methods to QFileInfoPrivate::Data (1st Round) Reviewed-by: Joao --- src/corelib/io/qfileinfo.cpp | 154 ++++++++++++++++++++++--------------------- src/corelib/io/qfileinfo_p.h | 25 ++++--- 2 files changed, 90 insertions(+), 89 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 61f7180..4671d8c 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -64,46 +64,45 @@ QFileInfoPrivate::~QFileInfoPrivate() data = 0; } -void QFileInfoPrivate::initFileEngine(const QString &file) +void QFileInfoPrivate::Data::initFileEngine(const QString &file) { - detach(); - delete data->fileEngine; - data->fileEngine = 0; - data->clear(); - data->fileEngine = QAbstractFileEngine::create(file); - data->fileName = file; + delete fileEngine; + fileEngine = 0; + clear(); + fileEngine = QAbstractFileEngine::create(file); + fileName = file; } -void QFileInfoPrivate::detach() +void QFileInfoPrivate::Data::detach(QFileInfoPrivate::Data *&data) { qAtomicDetach(data); } -QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const +QString QFileInfoPrivate::Data::getFileName(QAbstractFileEngine::FileName name) const { - if (data->cache_enabled && !data->fileNames[(int)name].isNull()) - return data->fileNames[(int)name]; - QString ret = data->fileEngine->fileName(name); + if (cache_enabled && !fileNames[(int)name].isNull()) + return fileNames[(int)name]; + QString ret = fileEngine->fileName(name); if (ret.isNull()) ret = QLatin1String(""); - if (data->cache_enabled) - data->fileNames[(int)name] = ret; + if (cache_enabled) + fileNames[(int)name] = ret; return ret; } -QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const +QString QFileInfoPrivate::Data::getFileOwner(QAbstractFileEngine::FileOwner own) const { - if (data->cache_enabled && !data->fileOwners[(int)own].isNull()) - return data->fileOwners[(int)own]; - QString ret = data->fileEngine->owner(own); + if (cache_enabled && !fileOwners[(int)own].isNull()) + return fileOwners[(int)own]; + QString ret = fileEngine->owner(own); if (ret.isNull()) ret = QLatin1String(""); - if (data->cache_enabled) - data->fileOwners[(int)own] = ret; + if (cache_enabled) + fileOwners[(int)own] = ret; return ret; } -uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const +uint QFileInfoPrivate::Data::getFileFlags(QAbstractFileEngine::FileFlags request) const { // We split the testing into tests for for LinkType, BundleType, PermsMask // and the rest. @@ -118,7 +117,7 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons uint cachedFlags = 0; if (request & (QAbstractFileEngine::FlagsMask | QAbstractFileEngine::TypesMask)) { - if (!data->getCachedFlag(CachedFileFlags)) { + if (!getCachedFlag(CachedFileFlags)) { req |= QAbstractFileEngine::FlagsMask; req |= QAbstractFileEngine::TypesMask; req &= (~QAbstractFileEngine::LinkType); @@ -128,14 +127,14 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons } if (request & QAbstractFileEngine::LinkType) { - if (!data->getCachedFlag(CachedLinkTypeFlag)) { + if (!getCachedFlag(CachedLinkTypeFlag)) { req |= QAbstractFileEngine::LinkType; cachedFlags |= CachedLinkTypeFlag; } } if (request & QAbstractFileEngine::BundleType) { - if (!data->getCachedFlag(CachedBundleTypeFlag)) { + if (!getCachedFlag(CachedBundleTypeFlag)) { req |= QAbstractFileEngine::BundleType; cachedFlags |= CachedBundleTypeFlag; } @@ -143,30 +142,30 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons } if (request & QAbstractFileEngine::PermsMask) { - if (!data->getCachedFlag(CachedPerms)) { + if (!getCachedFlag(CachedPerms)) { req |= QAbstractFileEngine::PermsMask; cachedFlags |= CachedPerms; } } if (req) { - if (data->cache_enabled) + if (cache_enabled) req &= (~QAbstractFileEngine::Refresh); else req |= QAbstractFileEngine::Refresh; - QAbstractFileEngine::FileFlags flags = data->fileEngine->fileFlags(req); - data->fileFlags |= uint(flags); - data->setCachedFlag(cachedFlags); + QAbstractFileEngine::FileFlags flags = fileEngine->fileFlags(req); + fileFlags |= uint(flags); + setCachedFlag(cachedFlags); } - return data->fileFlags & request; + return fileFlags & request; } -QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const +QDateTime &QFileInfoPrivate::Data::getFileTime(QAbstractFileEngine::FileTime request) const { - if (!data->cache_enabled) - data->clearFlags(); + if (!cache_enabled) + clearFlags(); uint cf; if (request == QAbstractFileEngine::CreationTime) cf = CachedCTime; @@ -174,11 +173,11 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) cf = CachedMTime; else cf = CachedATime; - if (!data->getCachedFlag(cf)) { - data->fileTimes[request] = data->fileEngine->fileTime(request); - data->setCachedFlag(cf); + if (!getCachedFlag(cf)) { + fileTimes[request] = fileEngine->fileTime(request); + setCachedFlag(cf); } - return data->fileTimes[request]; + return fileTimes[request]; } //************* QFileInfo @@ -287,7 +286,8 @@ QFileInfo::QFileInfo() : d_ptr(new QFileInfoPrivate()) */ QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate()) { - d_ptr->initFileEngine(file); + QFileInfoPrivate::Data::detach(d_ptr->data); + d_ptr->data->initFileEngine(file); } /*! @@ -301,7 +301,8 @@ QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate()) */ QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate()) { - d_ptr->initFileEngine(file.fileName()); + QFileInfoPrivate::Data::detach(d_ptr->data); + d_ptr->data->initFileEngine(file.fileName()); } /*! @@ -318,7 +319,8 @@ QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate()) */ QFileInfo::QFileInfo(const QDir &dir, const QString &file) : d_ptr(new QFileInfoPrivate()) { - d_ptr->initFileEngine(dir.filePath(file)); + QFileInfoPrivate::Data::detach(d_ptr->data); + d_ptr->data->initFileEngine(dir.filePath(file)); } /*! @@ -490,7 +492,7 @@ QString QFileInfo::absoluteFilePath() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::AbsoluteName); + return d->data->getFileName(QAbstractFileEngine::AbsoluteName); } /*! @@ -507,7 +509,7 @@ QString QFileInfo::canonicalFilePath() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::CanonicalName); + return d->data->getFileName(QAbstractFileEngine::CanonicalName); } @@ -538,7 +540,7 @@ QString QFileInfo::absolutePath() const qWarning("QFileInfo::absolutePath: Constructed with empty filename"); return QLatin1String(""); } - return d->getFileName(QAbstractFileEngine::AbsolutePathName); + return d->data->getFileName(QAbstractFileEngine::AbsolutePathName); } /*! @@ -554,7 +556,7 @@ QString QFileInfo::canonicalPath() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::CanonicalPathName); + return d->data->getFileName(QAbstractFileEngine::CanonicalPathName); } /*! @@ -571,7 +573,7 @@ QString QFileInfo::path() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::PathName); + return d->data->getFileName(QAbstractFileEngine::PathName); } /*! @@ -610,8 +612,9 @@ bool QFileInfo::makeAbsolute() Q_D(QFileInfo); if (!d->data->fileEngine || !d->data->fileEngine->isRelativePath()) return false; - QString absFileName = d->getFileName(QAbstractFileEngine::AbsoluteName); - d->initFileEngine(absFileName); + QString absFileName = d->data->getFileName(QAbstractFileEngine::AbsoluteName); + QFileInfoPrivate::Data::detach(d_ptr->data); + d->data->initFileEngine(absFileName); return true; } @@ -626,7 +629,7 @@ bool QFileInfo::exists() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::ExistsFlag); + return d->data->getFileFlags(QAbstractFileEngine::ExistsFlag); } /*! @@ -639,7 +642,8 @@ bool QFileInfo::exists() const void QFileInfo::refresh() { Q_D(QFileInfo); - d->reset(); + QFileInfoPrivate::Data::detach(d->data); + d->data->clear(); } /*! @@ -653,7 +657,7 @@ QString QFileInfo::filePath() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::DefaultName); + return d->data->getFileName(QAbstractFileEngine::DefaultName); } /*! @@ -672,7 +676,7 @@ QString QFileInfo::fileName() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::BaseName); + return d->data->getFileName(QAbstractFileEngine::BaseName); } /*! @@ -692,7 +696,7 @@ QString QFileInfo::bundleName() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::BundleName); + return d->data->getFileName(QAbstractFileEngine::BundleName); } /*! @@ -716,7 +720,7 @@ QString QFileInfo::baseName() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0); + return d->data->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0); } /*! @@ -735,7 +739,7 @@ QString QFileInfo::completeBaseName() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - QString name = d->getFileName(QAbstractFileEngine::BaseName); + QString name = d->data->getFileName(QAbstractFileEngine::BaseName); int index = name.lastIndexOf(QLatin1Char('.')); return (index == -1) ? name : name.left(index); } @@ -756,7 +760,7 @@ QString QFileInfo::completeSuffix() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - QString fileName = d->getFileName(QAbstractFileEngine::BaseName); + QString fileName = d->data->getFileName(QAbstractFileEngine::BaseName); int firstDot = fileName.indexOf(QLatin1Char('.')); if (firstDot == -1) return QLatin1String(""); @@ -783,7 +787,7 @@ QString QFileInfo::suffix() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - QString fileName = d->getFileName(QAbstractFileEngine::BaseName); + QString fileName = d->data->getFileName(QAbstractFileEngine::BaseName); int lastDot = fileName.lastIndexOf(QLatin1Char('.')); if (lastDot == -1) return QLatin1String(""); @@ -848,7 +852,7 @@ bool QFileInfo::isReadable() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::ReadUserPerm); + return d->data->getFileFlags(QAbstractFileEngine::ReadUserPerm); } /*! @@ -861,7 +865,7 @@ bool QFileInfo::isWritable() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::WriteUserPerm); + return d->data->getFileFlags(QAbstractFileEngine::WriteUserPerm); } /*! @@ -874,7 +878,7 @@ bool QFileInfo::isExecutable() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::ExeUserPerm); + return d->data->getFileFlags(QAbstractFileEngine::ExeUserPerm); } /*! @@ -888,7 +892,7 @@ bool QFileInfo::isHidden() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::HiddenFlag); + return d->data->getFileFlags(QAbstractFileEngine::HiddenFlag); } /*! @@ -903,7 +907,7 @@ bool QFileInfo::isFile() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::FileType); + return d->data->getFileFlags(QAbstractFileEngine::FileType); } /*! @@ -917,7 +921,7 @@ bool QFileInfo::isDir() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::DirectoryType); + return d->data->getFileFlags(QAbstractFileEngine::DirectoryType); } @@ -933,7 +937,7 @@ bool QFileInfo::isBundle() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::BundleType); + return d->data->getFileFlags(QAbstractFileEngine::BundleType); } /*! @@ -958,7 +962,7 @@ bool QFileInfo::isSymLink() const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::LinkType); + return d->data->getFileFlags(QAbstractFileEngine::LinkType); } /*! @@ -971,7 +975,7 @@ bool QFileInfo::isRoot() const Q_D(const QFileInfo); if (!d->data->fileEngine) return true; - return d->getFileFlags(QAbstractFileEngine::RootFlag); + return d->data->getFileFlags(QAbstractFileEngine::RootFlag); } /*! @@ -999,7 +1003,7 @@ QString QFileInfo::readLink() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::LinkName); + return d->data->getFileName(QAbstractFileEngine::LinkName); } /*! @@ -1017,7 +1021,7 @@ QString QFileInfo::owner() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileOwner(QAbstractFileEngine::OwnerUser); + return d->data->getFileOwner(QAbstractFileEngine::OwnerUser); } /*! @@ -1051,7 +1055,7 @@ QString QFileInfo::group() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QLatin1String(""); - return d->getFileOwner(QAbstractFileEngine::OwnerGroup); + return d->data->getFileOwner(QAbstractFileEngine::OwnerGroup); } /*! @@ -1088,7 +1092,7 @@ bool QFileInfo::permission(QFile::Permissions permissions) const Q_D(const QFileInfo); if (!d->data->fileEngine) return false; - return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions; + return d->data->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions; } /*! @@ -1100,7 +1104,7 @@ QFile::Permissions QFileInfo::permissions() const Q_D(const QFileInfo); if (!d->data->fileEngine) return 0; - return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask); + return QFile::Permissions(d->data->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask); } @@ -1140,7 +1144,7 @@ QDateTime QFileInfo::created() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QDateTime(); - return d->getFileTime(QAbstractFileEngine::CreationTime); + return d->data->getFileTime(QAbstractFileEngine::CreationTime); } /*! @@ -1153,7 +1157,7 @@ QDateTime QFileInfo::lastModified() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QDateTime(); - return d->getFileTime(QAbstractFileEngine::ModificationTime); + return d->data->getFileTime(QAbstractFileEngine::ModificationTime); } /*! @@ -1169,7 +1173,7 @@ QDateTime QFileInfo::lastRead() const Q_D(const QFileInfo); if (!d->data->fileEngine) return QDateTime(); - return d->getFileTime(QAbstractFileEngine::AccessTime); + return d->data->getFileTime(QAbstractFileEngine::AccessTime); } /*! \internal @@ -1178,7 +1182,7 @@ QDateTime QFileInfo::lastRead() const void QFileInfo::detach() { Q_D(QFileInfo); - d->detach(); + QFileInfoPrivate::Data::detach(d->data); } /*! @@ -1207,7 +1211,7 @@ bool QFileInfo::caching() const void QFileInfo::setCaching(bool enable) { Q_D(QFileInfo); - detach(); + QFileInfoPrivate::Data::detach(d->data); d->data->cache_enabled = enable; } diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 306ffe1..a1f5419 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -66,13 +66,6 @@ public: QFileInfoPrivate(const QFileInfo *copy=0); ~QFileInfoPrivate(); - void initFileEngine(const QString &); - - uint getFileFlags(QAbstractFileEngine::FileFlags) const; - QDateTime &getFileTime(QAbstractFileEngine::FileTime) const; - QString getFileName(QAbstractFileEngine::FileName) const; - QString getFileOwner(QAbstractFileEngine::FileOwner own) const; - enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, CachedSize =0x08, CachedPerms=0x80 }; @@ -87,7 +80,7 @@ public: cachedFlags(0), cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) {} inline ~Data() { delete fileEngine; } - inline void clearFlags() { + inline void clearFlags() const { fileFlags = 0; cachedFlags = 0; if (fileEngine) @@ -100,6 +93,15 @@ public: fileOwners[1].clear(); fileOwners[0].clear(); } + void initFileEngine(const QString &); + + uint getFileFlags(QAbstractFileEngine::FileFlags) const; + QDateTime &getFileTime(QAbstractFileEngine::FileTime) const; + QString getFileName(QAbstractFileEngine::FileName) const; + QString getFileOwner(QAbstractFileEngine::FileOwner own) const; + + static void detach(QFileInfoPrivate::Data *&data); + mutable QAtomicInt ref; QAbstractFileEngine *fileEngine; @@ -114,14 +116,9 @@ public: mutable QDateTime fileTimes[3]; inline bool getCachedFlag(uint c) const { return cache_enabled ? (cachedFlags & c) : 0; } - inline void setCachedFlag(uint c) + inline void setCachedFlag(uint c) const { if (cache_enabled) cachedFlags |= c; } } *data; - inline void reset() { - detach(); - data->clear(); - } - void detach(); }; QT_END_NAMESPACE -- cgit v0.12 From 46237ec0e73ce11bb55086a4917c2138ba529c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 24 Aug 2010 14:32:43 +0200 Subject: Refactoring QDirPrivate::Data There was an unnecessary split of QDir's private data between QDirPrivate and QDirPrivate::Data. As a stepping stone towards merging the two, this moves everything into QDirPrivate::Data. Reviewed-by: Thomas Zander --- src/corelib/io/qdir.cpp | 182 ++++++++++++++++++++++++++---------------------- 1 file changed, 98 insertions(+), 84 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index ed51c5d..5d56529 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -89,46 +89,73 @@ public: QDirPrivate(const QDir *copy = 0); ~QDirPrivate(); - void updateFileLists() const; - void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *) const; - -#ifdef QT3_SUPPORT - QChar filterSepChar; - bool matchAllDirs; -#endif - static inline QChar getFilterSepChar(const QString &nameFilter) - { - QChar sep(QLatin1Char(';')); - int i = nameFilter.indexOf(sep, 0); - if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1) - sep = QChar(QLatin1Char(' ')); - return sep; - } - static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0) { - if (sep == 0) - sep = getFilterSepChar(nameFilter); - QStringList ret = nameFilter.split(sep); - for (int i = 0; i < ret.count(); ++i) - ret[i] = ret[i].trimmed(); - return ret; - } - struct Data { inline Data() - : ref(1), fileEngine(0), listsDirty(1) + : ref(1), +#ifdef QT3_SUPPORT + filterSepChar(0), matchAllDirs(false), +#endif + fileEngine(0), listsDirty(1) {} inline Data(const Data ©) : ref(1), path(copy.path), nameFilters(copy.nameFilters), sort(copy.sort), - filters(copy.filters), fileEngine(0), listsDirty(1) + filters(copy.filters), +#ifdef QT3_SUPPORT + filterSepChar(copy.filterSepChar), matchAllDirs(copy.matchAllDirs), +#endif + fileEngine(0), listsDirty(1) {} inline ~Data() { delete fileEngine; } + void updateFileLists() const; + static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *); + + static inline QChar getFilterSepChar(const QString &nameFilter) + { + QChar sep(QLatin1Char(';')); + int i = nameFilter.indexOf(sep, 0); + if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1) + sep = QChar(QLatin1Char(' ')); + return sep; + } + + static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0) + { + if (sep == 0) + sep = getFilterSepChar(nameFilter); + QStringList ret = nameFilter.split(sep); + for (int i = 0; i < ret.count(); ++i) + ret[i] = ret[i].trimmed(); + return ret; + } + + static void detach(QDirPrivate::Data *&data, bool createFileEngine = true); + + inline void setPath(QString p) + { + if ((p.endsWith(QLatin1Char('/')) || p.endsWith(QLatin1Char('\\'))) + && p.length() > 1) { +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + if (!(p.length() == 3 && p.at(1) == QLatin1Char(':'))) +#endif + p.truncate(p.length() - 1); + } + + delete fileEngine; + fileEngine = QAbstractFileEngine::create(p); + + // set the path to be the qt friendly version so then we can operate on it using just / + path = fileEngine->fileName(QAbstractFileEngine::DefaultName); + clear(); + } + inline void clear() { listsDirty = 1; files.clear(); fileInfos.clear(); } + mutable QAtomicInt ref; QString path; @@ -136,42 +163,20 @@ public: QDir::SortFlags sort; QDir::Filters filters; +#ifdef QT3_SUPPORT + QChar filterSepChar; + bool matchAllDirs; +#endif mutable QAbstractFileEngine *fileEngine; mutable uint listsDirty : 1; mutable QStringList files; mutable QFileInfoList fileInfos; } *data; - inline void setPath(const QString &p) - { - detach(false); - QString path = p; - if ((path.endsWith(QLatin1Char('/')) || path.endsWith(QLatin1Char('\\'))) - && path.length() > 1) { -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - if (!(path.length() == 3 && path.at(1) == QLatin1Char(':'))) -#endif - path.truncate(path.length() - 1); - } - - delete data->fileEngine; - data->fileEngine = QAbstractFileEngine::create(path); - // set the path to be the qt friendly version so then we can operate on it using just / - data->path = data->fileEngine->fileName(QAbstractFileEngine::DefaultName); - data->clear(); - } - inline void reset() { - detach(); - data->clear(); - } - void detach(bool createFileEngine = true); }; QDirPrivate::QDirPrivate(const QDir *copy) -#ifdef QT3_SUPPORT - : filterSepChar(0), matchAllDirs(false) -#endif { if (copy) { copy->d_func()->data->ref.ref(); @@ -268,8 +273,8 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt return r < 0; } -inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, - QStringList *names, QFileInfoList *infos) const +inline void QDirPrivate::Data::sortFileList(QDir::SortFlags sort, QFileInfoList &l, + QStringList *names, QFileInfoList *infos) { // names and infos are always empty lists or 0 here int n = l.size(); @@ -299,21 +304,21 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, } } -inline void QDirPrivate::updateFileLists() const +inline void QDirPrivate::Data::updateFileLists() const { - if (data->listsDirty) { + if (listsDirty) { QFileInfoList l; - QDirIterator it(data->path, data->nameFilters, data->filters); + QDirIterator it(path, nameFilters, filters); while (it.hasNext()) { it.next(); l.append(it.fileInfo()); } - sortFileList(data->sort, l, &data->files, &data->fileInfos); - data->listsDirty = 0; + sortFileList(sort, l, &files, &fileInfos); + listsDirty = 0; } } -void QDirPrivate::detach(bool createFileEngine) +void QDirPrivate::Data::detach(QDirPrivate::Data *&data, bool createFileEngine) { qAtomicDetach(data); if (createFileEngine) { @@ -507,7 +512,8 @@ void QDirPrivate::detach(bool createFileEngine) QDir::QDir(const QString &path) : d_ptr(new QDirPrivate) { Q_D(QDir); - d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); + QDirPrivate::Data::detach(d->data, false); + d->data->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); d->data->nameFilters = QStringList(QString::fromLatin1("*")); d->data->filters = AllEntries; d->data->sort = SortFlags(Name | IgnoreCase); @@ -535,7 +541,8 @@ QDir::QDir(const QString &path, const QString &nameFilter, SortFlags sort, Filters filters) : d_ptr(new QDirPrivate) { Q_D(QDir); - d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); + QDirPrivate::Data::detach(d->data, false); + d->data->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); d->data->nameFilters = QDir::nameFiltersFromString(nameFilter); bool empty = d->data->nameFilters.isEmpty(); if (!empty) { @@ -590,7 +597,8 @@ QDir::~QDir() void QDir::setPath(const QString &path) { Q_D(QDir); - d->setPath(path); + QDirPrivate::Data::detach(d->data, false); + d->data->setPath(path); } /*! @@ -954,7 +962,8 @@ void QDir::setNameFilters(const QStringList &nameFilters) { Q_D(QDir); - d->reset(); + QDirPrivate::Data::detach(d->data); + d->data->clear(); d->data->nameFilters = nameFilters; } @@ -1143,7 +1152,8 @@ void QDir::setFilter(Filters filters) { Q_D(QDir); - d->reset(); + QDirPrivate::Data::detach(d->data); + d->data->clear(); d->data->filters = filters; } @@ -1201,7 +1211,8 @@ void QDir::setSorting(SortFlags sort) { Q_D(QDir); - d->reset(); + QDirPrivate::Data::detach(d->data); + d->data->clear(); d->data->sort = sort; } @@ -1216,7 +1227,7 @@ uint QDir::count() const { Q_D(const QDir); - d->updateFileLists(); + d->data->updateFileLists(); return d->data->files.count(); } @@ -1231,7 +1242,7 @@ QString QDir::operator[](int pos) const { Q_D(const QDir); - d->updateFileLists(); + d->data->updateFileLists(); return d->data->files[pos]; } @@ -1309,14 +1320,14 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, if (filters == NoFilter) filters = d->data->filters; #ifdef QT3_SUPPORT - if (d->matchAllDirs) + if (d->data->matchAllDirs) filters |= AllDirs; #endif if (sort == NoSort) sort = d->data->sort; if (filters == d->data->filters && sort == d->data->sort && nameFilters == d->data->nameFilters) { - d->updateFileLists(); + d->data->updateFileLists(); return d->data->files; } @@ -1327,7 +1338,7 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, l.append(it.fileInfo()); } QStringList ret; - d->sortFileList(sort, l, &ret, 0); + d->data->sortFileList(sort, l, &ret, 0); return ret; } @@ -1355,14 +1366,14 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter if (filters == NoFilter) filters = d->data->filters; #ifdef QT3_SUPPORT - if (d->matchAllDirs) + if (d->data->matchAllDirs) filters |= AllDirs; #endif if (sort == NoSort) sort = d->data->sort; if (filters == d->data->filters && sort == d->data->sort && nameFilters == d->data->nameFilters) { - d->updateFileLists(); + d->data->updateFileLists(); return d->data->fileInfos; } @@ -1373,7 +1384,7 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter l.append(it.fileInfo()); } QFileInfoList ret; - d->sortFileList(sort, l, 0, &ret); + d->data->sortFileList(sort, l, 0, &ret); return ret; } @@ -1595,7 +1606,7 @@ bool QDir::makeAbsolute() // ### What do the return values signify? QString absolutePath = d->data->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); if (QDir::isRelativePath(absolutePath)) return false; - d->detach(); + QDirPrivate::Data::detach(d->data); d->data->path = absolutePath; d->data->fileEngine->setFileName(absolutePath); if (!(d->data->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) @@ -1661,7 +1672,8 @@ QDir &QDir::operator=(const QString &path) { Q_D(QDir); - d->setPath(path); + QDirPrivate::Data::detach(d->data, false); + d->data->setPath(path); return *this; } @@ -2153,7 +2165,8 @@ void QDir::refresh() const { Q_D(const QDir); - const_cast(d)->reset(); + QDirPrivate::Data::detach(const_cast(d)->data); + d->data->clear(); } /*! @@ -2165,7 +2178,7 @@ void QDir::refresh() const */ QStringList QDir::nameFiltersFromString(const QString &nameFilter) { - return QDirPrivate::splitFilters(nameFilter); + return QDirPrivate::Data::splitFilters(nameFilter); } /*! @@ -2230,7 +2243,7 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter) bool QDir::matchAllDirs() const { Q_D(const QDir); - return d->matchAllDirs; + return d->data->matchAllDirs; } @@ -2243,8 +2256,9 @@ void QDir::setMatchAllDirs(bool on) { Q_D(QDir); - d->reset(); - d->matchAllDirs = on; + QDirPrivate::Data::detach(d->data); + d->data->clear(); + d->data->matchAllDirs = on; } /*! @@ -2254,7 +2268,7 @@ QString QDir::nameFilter() const { Q_D(const QDir); - return nameFilters().join(QString(d->filterSepChar)); + return nameFilters().join(QString(d->data->filterSepChar)); } /*! @@ -2281,8 +2295,8 @@ void QDir::setNameFilter(const QString &nameFilter) { Q_D(QDir); - d->filterSepChar = QDirPrivate::getFilterSepChar(nameFilter); - setNameFilters(QDirPrivate::splitFilters(nameFilter, d->filterSepChar)); + d->data->filterSepChar = QDirPrivate::Data::getFilterSepChar(nameFilter); + setNameFilters(QDirPrivate::Data::splitFilters(nameFilter, d->data->filterSepChar)); } /*! -- cgit v0.12 From dba66b94d255c7cd0d3c9d2717f250194e4edac9 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 25 Aug 2010 10:30:39 +0200 Subject: Add unit test for qfilesystementry Reviewed-by: Joao --- src/corelib/io/qfilesystementry.cpp | 11 +- src/corelib/io/qfilesystementry_p.h | 3 +- tests/auto/corelib.pro | 1 + tests/auto/qfilesystementry/qfilesystementry.pro | 7 + .../auto/qfilesystementry/tst_qfilesystementry.cpp | 154 +++++++++++++++++++++ 5 files changed, 172 insertions(+), 4 deletions(-) create mode 100644 tests/auto/qfilesystementry/qfilesystementry.pro create mode 100644 tests/auto/qfilesystementry/tst_qfilesystementry.cpp diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 3e8b8b2..d3b3225 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -73,7 +73,7 @@ QString QFileSystemEntry::filePath() const return m_filePath; } -QByteArray QFileSystemEntry::nativeFileName() const +QByteArray QFileSystemEntry::nativeFilePath() const { resolveNativeFilePath(); return m_nativeFilePath; @@ -106,7 +106,7 @@ QString QFileSystemEntry::suffix() const if (m_lastDotInFileName == -1) return QString(); - return m_filePath.mid(m_lastSeparator + m_lastDotInFileName + 1); + return m_filePath.mid(m_lastSeparator + m_firstDotInFileName + m_lastDotInFileName + 1); } QString QFileSystemEntry::completeSuffix() const @@ -180,6 +180,11 @@ void QFileSystemEntry::findFileNameSeparators() const m_lastSeparator = lastSeparator; m_firstDotInFileName = firstDotInFileName == -1 ? -1 : firstDotInFileName - lastSeparator; - m_lastDotInFileName = lastDotInFileName == -1 ? -1 : lastDotInFileName - firstDotInFileName - lastSeparator; + if (lastDotInFileName == -1) + m_lastDotInFileName = -1; + else if (firstDotInFileName == lastDotInFileName) + m_lastDotInFileName = 0; + else + m_lastDotInFileName = firstDotInFileName - lastSeparator; } } diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 1812b9f..68af24d 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -60,13 +60,14 @@ QT_BEGIN_NAMESPACE class QFileSystemEntry { +public: QFileSystemEntry(const QString &filePath); QFileSystemEntry(const QByteArray &nativeFilePath); QFileSystemEntry(const QByteArray &nativeFilePath, const QString &filePath); QString filePath() const; QString fileName() const; - QByteArray nativeFileName() const; + QByteArray nativeFilePath() const; QString suffix() const; QString completeSuffix() const; bool isAbsolute() const; diff --git a/tests/auto/corelib.pro b/tests/auto/corelib.pro index d1d0940..5ac0c81 100644 --- a/tests/auto/corelib.pro +++ b/tests/auto/corelib.pro @@ -101,6 +101,7 @@ SUBDIRS=\ qwritelocker \ selftests \ utf8 \ + qfilesystementry \ symbian:SUBDIRS -= \ qtconcurrentfilter \ diff --git a/tests/auto/qfilesystementry/qfilesystementry.pro b/tests/auto/qfilesystementry/qfilesystementry.pro new file mode 100644 index 0000000..9f75388 --- /dev/null +++ b/tests/auto/qfilesystementry/qfilesystementry.pro @@ -0,0 +1,7 @@ +load(qttest_p4) + +SOURCES += tst_qfilesystementry.cpp \ + ../../../src/corelib/io/qfilesystementry.cpp +HEADERS += ../../../src/corelib/io/qfilesystementry_p.h +QT = core + diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp new file mode 100644 index 0000000..081beb6 --- /dev/null +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +#include + +#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN) +# define WIN_STUFF +#endif + +//TESTED_CLASS= +//TESTED_FILES= + +class tst_QFileSystemEntry : public QObject +{ + Q_OBJECT + +private slots: + void getSetCheck_data(); + void getSetCheck(); +}; + +void tst_QFileSystemEntry::getSetCheck_data() +{ + QTest::addColumn("nativeFilePath"); + QTest::addColumn("filepath"); + QTest::addColumn("filename"); + QTest::addColumn("suffix"); + QTest::addColumn("completeSuffix"); + QTest::addColumn("absolute"); + + QTest::newRow("simple") +#if defined(WIN_STUFF) + << QByteArray("A:\\home\\qt\\in\\a\\dir.tar.gz") + << "A:/home/qt/in/a/dir.tar.gz" +#else + << QByteArray("/home/qt/in/a/dir.tar.gz") + << "/home/qt/in/a/dir.tar.gz" +#endif + << "dir.tar.gz" << "gz" << "tar.gz" << true; + + QTest::newRow("relative") +#if defined(WIN_STUFF) + << QByteArray("\\in\\a\\dir.tar.gz") + << "/in/a/dir.tar.gz" +#else + << QByteArray("in/a/dir.tar.gz") + << "in/a/dir.tar.gz" +#endif + << "dir.tar.gz" << "gz" << "tar.gz" << false; + + QTest::newRow("noSuffix") +#if defined(WIN_STUFF) + << QByteArray("myDir\\myfile") +#else + << QByteArray("myDir/myfile") +#endif + << "myDir/myfile" << "myfile" << "" << "" << false; + + QTest::newRow("noLongSuffix") +#if defined(WIN_STUFF) + << QByteArray("myDir\\myfile.txt") +#else + << QByteArray("myDir/myfile.txt") +#endif + << "myDir/myfile.txt" << "myfile.txt" << "txt" << "txt" << false; + + QTest::newRow("endingSlash") +#if defined(WIN_STUFF) + << QByteArray("myDir\\myfile.bla\\") +#else + << QByteArray("myDir/myfile.bla/") +#endif + << "myDir/myfile.bla/" << "" << "" << "" << false; + +#if defined(WIN_STUFF) + QTest::newRow("absolutePath") + << QByteArray("A:dir\\without\\leading\\backslash.bat") + << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << true; +#else + QTest::newRow("relativePath") + << QByteArray("A:dir/without/leading/backslash.bat") + << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << false; +#endif +} + +void tst_QFileSystemEntry::getSetCheck() +{ + QFETCH(QByteArray, nativeFilePath); + QFETCH(QString, filepath); + QFETCH(QString, filename); + QFETCH(QString, suffix); + QFETCH(QString, completeSuffix); + QFETCH(bool, absolute); + + QFileSystemEntry entry1(filepath); + QCOMPARE(entry1.filePath(), filepath); + QCOMPARE(entry1.nativeFilePath(), nativeFilePath); + QCOMPARE(entry1.fileName(), filename); + QCOMPARE(entry1.suffix(), suffix); + QCOMPARE(entry1.completeSuffix(), completeSuffix); + QCOMPARE(entry1.isAbsolute(), absolute); + QCOMPARE(entry1.isRelative(), !absolute); + + QFileSystemEntry entry2(nativeFilePath); + QCOMPARE(entry2.suffix(), suffix); + QCOMPARE(entry2.completeSuffix(), completeSuffix); + QCOMPARE(entry2.isAbsolute(), absolute); + QCOMPARE(entry2.isRelative(), !absolute); + QCOMPARE(entry2.filePath(), filepath); + QCOMPARE(entry2.nativeFilePath(), nativeFilePath); + QCOMPARE(entry2.fileName(), filename); +} + +QTEST_MAIN(tst_QFileSystemEntry) +#include -- cgit v0.12 From 931d47db10ca8b8ebf564c4b6537e31370b7f53c Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 25 Aug 2010 13:19:32 +0200 Subject: Fix the unit test on Windows --- src/corelib/io/qfilesystementry.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index d3b3225..2d6740e 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -121,7 +121,14 @@ QString QFileSystemEntry::completeSuffix() const bool QFileSystemEntry::isAbsolute() const { resolveFilePath(); - return !m_filePath.isEmpty() && (m_filePath[0].unicode() == '/' /*|| hasScheme()*/); + return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/') +#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN) + || (m_filePath.length() >= 2 + && ((m_filePath[0].isLetter() && m_filePath[1] == QLatin1Char(':')) + || (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/')))) +#endif + ); + } // private methods -- cgit v0.12 From f9b040556368001b367731e7ea65227956952e25 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 25 Aug 2010 13:43:10 +0200 Subject: Fix QFileSystemEntry autotests for Windows Reviewed-by: Thomas Zander --- src/corelib/io/qfilesystementry.cpp | 2 +- tests/auto/qfilesystementry/tst_qfilesystementry.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 2d6740e..bed5435 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -122,7 +122,7 @@ bool QFileSystemEntry::isAbsolute() const { resolveFilePath(); return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/') -#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN) +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) || (m_filePath.length() >= 2 && ((m_filePath[0].isLetter() && m_filePath[1] == QLatin1Char(':')) || (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/')))) diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 081beb6..58b7c6f 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -42,7 +42,7 @@ #include -#if defined(Q_FS_FAT) || defined(Q_OS_OS2EMX) || defined(Q_OS_SYMBIAN) +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) # define WIN_STUFF #endif @@ -79,8 +79,8 @@ void tst_QFileSystemEntry::getSetCheck_data() QTest::newRow("relative") #if defined(WIN_STUFF) - << QByteArray("\\in\\a\\dir.tar.gz") - << "/in/a/dir.tar.gz" + << QByteArray("in\\a\\dir.tar.gz") + << "in/a/dir.tar.gz" #else << QByteArray("in/a/dir.tar.gz") << "in/a/dir.tar.gz" -- cgit v0.12 From c31cd0ecb46f1005d212a528ab74e16f2d138331 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 25 Aug 2010 14:35:10 +0200 Subject: Refactor QFileInfoPrivate::Data (Round 2) The QFileInfoPrivate::Data member class is removed now. All the methods moved to QFileInfoPrivate. QFileInfoPrivate becomes a QSharedData type. Reviewed-by: Joao --- src/corelib/io/qfileinfo.cpp | 223 ++++++++++++++------------------- src/corelib/io/qfileinfo.h | 16 ++- src/corelib/io/qfileinfo_p.h | 100 ++++++++------- tests/auto/qfileinfo/tst_qfileinfo.cpp | 17 +-- 4 files changed, 170 insertions(+), 186 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 4671d8c..fe557d0 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -47,24 +47,7 @@ QT_BEGIN_NAMESPACE -QFileInfoPrivate::QFileInfoPrivate(const QFileInfo *copy) -{ - if (copy) { - copy->d_func()->data->ref.ref(); - data = copy->d_func()->data; - } else { - data = new QFileInfoPrivate::Data; - } -} - -QFileInfoPrivate::~QFileInfoPrivate() -{ - if (!data->ref.deref()) - delete data; - data = 0; -} - -void QFileInfoPrivate::Data::initFileEngine(const QString &file) +void QFileInfoPrivate::initFileEngine(const QString &file) { delete fileEngine; fileEngine = 0; @@ -73,12 +56,7 @@ void QFileInfoPrivate::Data::initFileEngine(const QString &file) fileName = file; } -void QFileInfoPrivate::Data::detach(QFileInfoPrivate::Data *&data) -{ - qAtomicDetach(data); -} - -QString QFileInfoPrivate::Data::getFileName(QAbstractFileEngine::FileName name) const +QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const { if (cache_enabled && !fileNames[(int)name].isNull()) return fileNames[(int)name]; @@ -90,7 +68,7 @@ QString QFileInfoPrivate::Data::getFileName(QAbstractFileEngine::FileName name) return ret; } -QString QFileInfoPrivate::Data::getFileOwner(QAbstractFileEngine::FileOwner own) const +QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const { if (cache_enabled && !fileOwners[(int)own].isNull()) return fileOwners[(int)own]; @@ -102,7 +80,7 @@ QString QFileInfoPrivate::Data::getFileOwner(QAbstractFileEngine::FileOwner own) return ret; } -uint QFileInfoPrivate::Data::getFileFlags(QAbstractFileEngine::FileFlags request) const +uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const { // We split the testing into tests for for LinkType, BundleType, PermsMask // and the rest. @@ -162,7 +140,7 @@ uint QFileInfoPrivate::Data::getFileFlags(QAbstractFileEngine::FileFlags request return fileFlags & request; } -QDateTime &QFileInfoPrivate::Data::getFileTime(QAbstractFileEngine::FileTime request) const +QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const { if (!cache_enabled) clearFlags(); @@ -284,10 +262,8 @@ QFileInfo::QFileInfo() : d_ptr(new QFileInfoPrivate()) \sa setFile(), isRelative(), QDir::setCurrent(), QDir::isRelativePath() */ -QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate()) +QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate(file)) { - QFileInfoPrivate::Data::detach(d_ptr->data); - d_ptr->data->initFileEngine(file); } /*! @@ -299,10 +275,8 @@ QFileInfo::QFileInfo(const QString &file) : d_ptr(new QFileInfoPrivate()) \sa isRelative() */ -QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate()) +QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate(file.fileName())) { - QFileInfoPrivate::Data::detach(d_ptr->data); - d_ptr->data->initFileEngine(file.fileName()); } /*! @@ -317,16 +291,16 @@ QFileInfo::QFileInfo(const QFile &file) : d_ptr(new QFileInfoPrivate()) \sa isRelative() */ -QFileInfo::QFileInfo(const QDir &dir, const QString &file) : d_ptr(new QFileInfoPrivate()) +QFileInfo::QFileInfo(const QDir &dir, const QString &file) + : d_ptr(new QFileInfoPrivate(dir.filePath(file))) { - QFileInfoPrivate::Data::detach(d_ptr->data); - d_ptr->data->initFileEngine(dir.filePath(file)); } /*! Constructs a new QFileInfo that is a copy of the given \a fileinfo. */ -QFileInfo::QFileInfo(const QFileInfo &fileinfo) : d_ptr(new QFileInfoPrivate(&fileinfo)) +QFileInfo::QFileInfo(const QFileInfo &fileinfo) + : d_ptr(fileinfo.d_ptr) { } @@ -361,17 +335,17 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const Q_D(const QFileInfo); // ### Qt 5: understand long and short file names on Windows // ### (GetFullPathName()). - if (fileinfo.d_func()->data == d->data) + if (fileinfo.d_ptr == d_ptr) return true; - if (!d->data->fileEngine || !fileinfo.d_func()->data->fileEngine) + if (!d->fileEngine || !fileinfo.d_ptr->fileEngine) return false; - if (d->data->fileEngine->caseSensitive() != fileinfo.d_func()->data->fileEngine->caseSensitive()) + if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive()) return false; if (fileinfo.size() == size()) { //if the size isn't the same... QString file1 = canonicalFilePath(), file2 = fileinfo.canonicalFilePath(); if (file1.length() == file2.length()) { - if (!fileinfo.d_func()->data->fileEngine->caseSensitive()) { + if (!fileinfo.d_ptr->fileEngine->caseSensitive()) { for (int i = 0; i < file1.length(); i++) { if (file1.at(i).toLower() != file2.at(i).toLower()) return false; @@ -409,8 +383,7 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) */ QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo) { - Q_D(QFileInfo); - qAtomicAssign(d->data, fileinfo.d_func()->data); + d_ptr = fileinfo.d_ptr; return *this; } @@ -490,9 +463,9 @@ void QFileInfo::setFile(const QDir &dir, const QString &file) QString QFileInfo::absoluteFilePath() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::AbsoluteName); + return d->getFileName(QAbstractFileEngine::AbsoluteName); } /*! @@ -507,9 +480,9 @@ QString QFileInfo::absoluteFilePath() const QString QFileInfo::canonicalFilePath() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::CanonicalName); + return d->getFileName(QAbstractFileEngine::CanonicalName); } @@ -534,13 +507,13 @@ QString QFileInfo::absolutePath() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) { + if (!d->fileEngine) { return QLatin1String(""); - } else if (d->data->fileName.isEmpty()) { + } else if (d->fileName.isEmpty()) { qWarning("QFileInfo::absolutePath: Constructed with empty filename"); return QLatin1String(""); } - return d->data->getFileName(QAbstractFileEngine::AbsolutePathName); + return d->getFileName(QAbstractFileEngine::AbsolutePathName); } /*! @@ -554,9 +527,9 @@ QString QFileInfo::absolutePath() const QString QFileInfo::canonicalPath() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::CanonicalPathName); + return d->getFileName(QAbstractFileEngine::CanonicalPathName); } /*! @@ -571,9 +544,9 @@ QString QFileInfo::canonicalPath() const QString QFileInfo::path() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::PathName); + return d->getFileName(QAbstractFileEngine::PathName); } /*! @@ -595,9 +568,9 @@ QString QFileInfo::path() const bool QFileInfo::isRelative() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return true; - return d->data->fileEngine->isRelativePath(); + return d->fileEngine->isRelativePath(); } /*! @@ -609,12 +582,11 @@ bool QFileInfo::isRelative() const */ bool QFileInfo::makeAbsolute() { - Q_D(QFileInfo); - if (!d->data->fileEngine || !d->data->fileEngine->isRelativePath()) + if (!d_ptr.constData()->fileEngine || !d_ptr.constData()->fileEngine->isRelativePath()) return false; - QString absFileName = d->data->getFileName(QAbstractFileEngine::AbsoluteName); - QFileInfoPrivate::Data::detach(d_ptr->data); - d->data->initFileEngine(absFileName); + QString absFileName = d_ptr.constData()->getFileName(QAbstractFileEngine::AbsoluteName); + // QSharedDataPointer::operator->() will detach. + d_ptr->initFileEngine(absFileName); return true; } @@ -627,9 +599,9 @@ bool QFileInfo::makeAbsolute() bool QFileInfo::exists() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::ExistsFlag); + return d->getFileFlags(QAbstractFileEngine::ExistsFlag); } /*! @@ -642,8 +614,7 @@ bool QFileInfo::exists() const void QFileInfo::refresh() { Q_D(QFileInfo); - QFileInfoPrivate::Data::detach(d->data); - d->data->clear(); + d->clear(); } /*! @@ -655,9 +626,9 @@ void QFileInfo::refresh() QString QFileInfo::filePath() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::DefaultName); + return d->getFileName(QAbstractFileEngine::DefaultName); } /*! @@ -674,9 +645,9 @@ QString QFileInfo::filePath() const QString QFileInfo::fileName() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::BaseName); + return d->getFileName(QAbstractFileEngine::BaseName); } /*! @@ -694,9 +665,9 @@ QString QFileInfo::fileName() const QString QFileInfo::bundleName() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::BundleName); + return d->getFileName(QAbstractFileEngine::BundleName); } /*! @@ -718,9 +689,9 @@ QString QFileInfo::bundleName() const QString QFileInfo::baseName() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0); + return d->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0); } /*! @@ -737,9 +708,9 @@ QString QFileInfo::baseName() const QString QFileInfo::completeBaseName() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - QString name = d->data->getFileName(QAbstractFileEngine::BaseName); + QString name = d->getFileName(QAbstractFileEngine::BaseName); int index = name.lastIndexOf(QLatin1Char('.')); return (index == -1) ? name : name.left(index); } @@ -758,9 +729,9 @@ QString QFileInfo::completeBaseName() const QString QFileInfo::completeSuffix() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - QString fileName = d->data->getFileName(QAbstractFileEngine::BaseName); + QString fileName = d->getFileName(QAbstractFileEngine::BaseName); int firstDot = fileName.indexOf(QLatin1Char('.')); if (firstDot == -1) return QLatin1String(""); @@ -785,9 +756,9 @@ QString QFileInfo::completeSuffix() const QString QFileInfo::suffix() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - QString fileName = d->data->getFileName(QAbstractFileEngine::BaseName); + QString fileName = d->getFileName(QAbstractFileEngine::BaseName); int lastDot = fileName.lastIndexOf(QLatin1Char('.')); if (lastDot == -1) return QLatin1String(""); @@ -850,9 +821,9 @@ QDir QFileInfo::dir(bool absPath) const bool QFileInfo::isReadable() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::ReadUserPerm); + return d->getFileFlags(QAbstractFileEngine::ReadUserPerm); } /*! @@ -863,9 +834,9 @@ bool QFileInfo::isReadable() const bool QFileInfo::isWritable() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::WriteUserPerm); + return d->getFileFlags(QAbstractFileEngine::WriteUserPerm); } /*! @@ -876,9 +847,9 @@ bool QFileInfo::isWritable() const bool QFileInfo::isExecutable() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::ExeUserPerm); + return d->getFileFlags(QAbstractFileEngine::ExeUserPerm); } /*! @@ -890,9 +861,9 @@ bool QFileInfo::isExecutable() const bool QFileInfo::isHidden() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::HiddenFlag); + return d->getFileFlags(QAbstractFileEngine::HiddenFlag); } /*! @@ -905,9 +876,9 @@ bool QFileInfo::isHidden() const bool QFileInfo::isFile() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::FileType); + return d->getFileFlags(QAbstractFileEngine::FileType); } /*! @@ -919,9 +890,9 @@ bool QFileInfo::isFile() const bool QFileInfo::isDir() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::DirectoryType); + return d->getFileFlags(QAbstractFileEngine::DirectoryType); } @@ -935,9 +906,9 @@ bool QFileInfo::isDir() const bool QFileInfo::isBundle() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::BundleType); + return d->getFileFlags(QAbstractFileEngine::BundleType); } /*! @@ -960,9 +931,9 @@ bool QFileInfo::isBundle() const bool QFileInfo::isSymLink() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::LinkType); + return d->getFileFlags(QAbstractFileEngine::LinkType); } /*! @@ -973,9 +944,9 @@ bool QFileInfo::isSymLink() const bool QFileInfo::isRoot() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return true; - return d->data->getFileFlags(QAbstractFileEngine::RootFlag); + return d->getFileFlags(QAbstractFileEngine::RootFlag); } /*! @@ -1001,9 +972,9 @@ bool QFileInfo::isRoot() const QString QFileInfo::readLink() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileName(QAbstractFileEngine::LinkName); + return d->getFileName(QAbstractFileEngine::LinkName); } /*! @@ -1019,9 +990,9 @@ QString QFileInfo::readLink() const QString QFileInfo::owner() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileOwner(QAbstractFileEngine::OwnerUser); + return d->getFileOwner(QAbstractFileEngine::OwnerUser); } /*! @@ -1035,9 +1006,9 @@ QString QFileInfo::owner() const uint QFileInfo::ownerId() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return 0; - return d->data->fileEngine->ownerId(QAbstractFileEngine::OwnerUser); + return d->fileEngine->ownerId(QAbstractFileEngine::OwnerUser); } /*! @@ -1053,9 +1024,9 @@ uint QFileInfo::ownerId() const QString QFileInfo::group() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return d->data->getFileOwner(QAbstractFileEngine::OwnerGroup); + return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } /*! @@ -1069,9 +1040,9 @@ QString QFileInfo::group() const uint QFileInfo::groupId() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return 0; - return d->data->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup); + return d->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup); } /*! @@ -1090,9 +1061,9 @@ uint QFileInfo::groupId() const bool QFileInfo::permission(QFile::Permissions permissions) const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions; + return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions; } /*! @@ -1102,9 +1073,9 @@ bool QFileInfo::permission(QFile::Permissions permissions) const QFile::Permissions QFileInfo::permissions() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return 0; - return QFile::Permissions(d->data->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask); + return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask); } @@ -1117,13 +1088,13 @@ QFile::Permissions QFileInfo::permissions() const qint64 QFileInfo::size() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return 0; - if (!d->data->getCachedFlag(QFileInfoPrivate::CachedSize)) { - d->data->setCachedFlag(QFileInfoPrivate::CachedSize); - d->data->fileSize = d->data->fileEngine->size(); + if (!d->getCachedFlag(QFileInfoPrivate::CachedSize)) { + d->setCachedFlag(QFileInfoPrivate::CachedSize); + d->fileSize = d->fileEngine->size(); } - return d->data->fileSize; + return d->fileSize; } /*! @@ -1142,9 +1113,9 @@ qint64 QFileInfo::size() const QDateTime QFileInfo::created() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QDateTime(); - return d->data->getFileTime(QAbstractFileEngine::CreationTime); + return d->getFileTime(QAbstractFileEngine::CreationTime); } /*! @@ -1155,9 +1126,9 @@ QDateTime QFileInfo::created() const QDateTime QFileInfo::lastModified() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QDateTime(); - return d->data->getFileTime(QAbstractFileEngine::ModificationTime); + return d->getFileTime(QAbstractFileEngine::ModificationTime); } /*! @@ -1171,9 +1142,9 @@ QDateTime QFileInfo::lastModified() const QDateTime QFileInfo::lastRead() const { Q_D(const QFileInfo); - if (!d->data->fileEngine) + if (!d->fileEngine) return QDateTime(); - return d->data->getFileTime(QAbstractFileEngine::AccessTime); + return d->getFileTime(QAbstractFileEngine::AccessTime); } /*! \internal @@ -1181,8 +1152,7 @@ QDateTime QFileInfo::lastRead() const */ void QFileInfo::detach() { - Q_D(QFileInfo); - QFileInfoPrivate::Data::detach(d->data); + d_ptr.detach(); } /*! @@ -1193,7 +1163,7 @@ void QFileInfo::detach() bool QFileInfo::caching() const { Q_D(const QFileInfo); - return d->data->cache_enabled; + return d->cache_enabled; } /*! @@ -1211,8 +1181,7 @@ bool QFileInfo::caching() const void QFileInfo::setCaching(bool enable) { Q_D(QFileInfo); - QFileInfoPrivate::Data::detach(d->data); - d->data->cache_enabled = enable; + d->cache_enabled = enable; } /*! diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index 7e82aed..f0128b1 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -44,7 +44,7 @@ #include #include -#include +#include QT_BEGIN_HEADER @@ -166,10 +166,20 @@ public: #endif protected: - QScopedPointer d_ptr; + QSharedDataPointer d_ptr; private: - Q_DECLARE_PRIVATE(QFileInfo) + inline QFileInfoPrivate* d_func() + { + detach(); + return const_cast(d_ptr.constData()); + } + + inline const QFileInfoPrivate* d_func() const + { + return d_ptr.constData(); + } }; + Q_DECLARE_TYPEINFO(QFileInfo, Q_MOVABLE_TYPE); #ifdef QT3_SUPPORT diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index a1f5419..138116e 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -57,68 +57,72 @@ #include "qabstractfileengine.h" #include "qdatetime.h" #include "qatomic.h" +#include "qshareddata.h" QT_BEGIN_NAMESPACE -class QFileInfoPrivate +class QFileInfoPrivate : public QSharedData { public: - QFileInfoPrivate(const QFileInfo *copy=0); - ~QFileInfoPrivate(); enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, CachedSize =0x08, CachedPerms=0x80 }; - struct Data { - inline Data() - : ref(1), fileEngine(0), - cachedFlags(0), cache_enabled(1), fileFlags(0), fileSize(0) - {} - inline Data(const Data ©) - : ref(1), fileEngine(QAbstractFileEngine::create(copy.fileName)), - fileName(copy.fileName), - cachedFlags(0), cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) - {} - inline ~Data() { delete fileEngine; } - inline void clearFlags() const { - fileFlags = 0; - cachedFlags = 0; - if (fileEngine) - (void)fileEngine->fileFlags(QAbstractFileEngine::Refresh); - } - inline void clear() { - clearFlags(); - for (int i = QAbstractFileEngine::NFileNames - 1 ; i >= 0 ; --i) - fileNames[i].clear(); - fileOwners[1].clear(); - fileOwners[0].clear(); - } - void initFileEngine(const QString &); - uint getFileFlags(QAbstractFileEngine::FileFlags) const; - QDateTime &getFileTime(QAbstractFileEngine::FileTime) const; - QString getFileName(QAbstractFileEngine::FileName) const; - QString getFileOwner(QAbstractFileEngine::FileOwner own) const; + inline QFileInfoPrivate() + : QSharedData(), fileEngine(0), + cachedFlags(0), cache_enabled(1), fileFlags(0), fileSize(0) + {} + inline QFileInfoPrivate(const QFileInfoPrivate ©) + : QSharedData(copy), fileEngine(QAbstractFileEngine::create(copy.fileName)), + fileName(copy.fileName), + cachedFlags(0), cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) + {} + inline QFileInfoPrivate(const QString &file) + : QSharedData(), fileEngine(0), + cachedFlags(0), cache_enabled(1), fileFlags(0), fileSize(0) + { + initFileEngine(file); + } + inline ~QFileInfoPrivate() + { + delete fileEngine; + } + void initFileEngine(const QString &); - static void detach(QFileInfoPrivate::Data *&data); + inline void clearFlags() const { + fileFlags = 0; + cachedFlags = 0; + if (fileEngine) + (void)fileEngine->fileFlags(QAbstractFileEngine::Refresh); + } + inline void clear() { + clearFlags(); + for (int i = QAbstractFileEngine::NFileNames - 1 ; i >= 0 ; --i) + fileNames[i].clear(); + fileOwners[1].clear(); + fileOwners[0].clear(); + } - mutable QAtomicInt ref; + uint getFileFlags(QAbstractFileEngine::FileFlags) const; + QDateTime &getFileTime(QAbstractFileEngine::FileTime) const; + QString getFileName(QAbstractFileEngine::FileName) const; + QString getFileOwner(QAbstractFileEngine::FileOwner own) const; - QAbstractFileEngine *fileEngine; - mutable QString fileName; - mutable QString fileNames[QAbstractFileEngine::NFileNames]; - mutable QString fileOwners[2]; + QAbstractFileEngine *fileEngine; + mutable QString fileName; + mutable QString fileNames[QAbstractFileEngine::NFileNames]; + mutable QString fileOwners[2]; - mutable uint cachedFlags : 31; - mutable uint cache_enabled : 1; - mutable uint fileFlags; - mutable qint64 fileSize; - mutable QDateTime fileTimes[3]; - inline bool getCachedFlag(uint c) const - { return cache_enabled ? (cachedFlags & c) : 0; } - inline void setCachedFlag(uint c) const - { if (cache_enabled) cachedFlags |= c; } - } *data; + mutable uint cachedFlags : 31; + mutable uint cache_enabled : 1; + mutable uint fileFlags; + mutable qint64 fileSize; + mutable QDateTime fileTimes[3]; + inline bool getCachedFlag(uint c) const + { return cache_enabled ? (cachedFlags & c) : 0; } + inline void setCachedFlag(uint c) const + { if (cache_enabled) cachedFlags |= c; } }; QT_END_NAMESPACE diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index a074f4b..32aa671 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -247,13 +247,13 @@ void tst_QFileInfo::copy() QFileInfo info2(info); QFileInfoPrivate *privateInfo = getPrivate(info); QFileInfoPrivate *privateInfo2 = getPrivate(info2); - QCOMPARE(privateInfo->data, privateInfo2->data); + QCOMPARE(privateInfo, privateInfo2); //operator = QFileInfo info3 = info; QFileInfoPrivate *privateInfo3 = getPrivate(info3); - QCOMPARE(privateInfo->data, privateInfo3->data); - QCOMPARE(privateInfo2->data, privateInfo3->data); + QCOMPARE(privateInfo, privateInfo3); + QCOMPARE(privateInfo2, privateInfo3); //refreshing info3 will detach it QFile file(info.absoluteFilePath()); @@ -275,9 +275,10 @@ void tst_QFileInfo::copy() QTest::qWait(5000); #endif info3.refresh(); - QVERIFY(privateInfo->data != privateInfo3->data); - QVERIFY(privateInfo2->data != privateInfo3->data); - QCOMPARE(privateInfo->data, privateInfo2->data); + privateInfo3 = getPrivate(info3); + QVERIFY(privateInfo != privateInfo3); + QVERIFY(privateInfo2 != privateInfo3); + QCOMPARE(privateInfo, privateInfo2); } void tst_QFileInfo::isFile_data() @@ -1241,8 +1242,8 @@ void tst_QFileInfo::isLocalFs() QFileInfo info(path); QFileInfoPrivate *privateInfo = getPrivate(info); - QVERIFY(privateInfo->data->fileEngine); - QCOMPARE(bool(privateInfo->data->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag) + QVERIFY(privateInfo->fileEngine); + QCOMPARE(bool(privateInfo->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag) & QAbstractFileEngine::LocalDiskFlag), isLocalFs); } -- cgit v0.12 From c4181bf7422a6b6c58d87b449a7066ae9e65e87a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 25 Aug 2010 13:38:32 +0200 Subject: Removed QDirPrivate layer of indirection Merged QDirPrivate with QDirPrivate::Data, as QDirPrivate served no purpose by itself, only adding an additional layer of indirection to the potentially shared private data, and an unnecessary allocation. Now, QDir holds a QSharedDataPointer to its private data. Private data will be shared among copied instances with COW semantics. Still, this sharing is very limited as plenty of regular use cases will cause the shared data to detach, such as refreshing the file lists. As the use QSharedDataPointer breaks usage of the Q_DECLARE_PRIVATE macro, we manually define the d_func'tions. Non-const d_func detaches on shared data. A detach function was added to the public interface to support this. (On a side note, QFileInfo already exposes a similar detach function). As much as possible, detach is handled implicitly inside the Q_D macro, through the d_func() non-const overload. On the other hand, implicit creation of file engines through detach was made explicit with a call to a new initFileEngine function. Reviewed-by: Thomas Zander --- src/corelib/io/qdir.cpp | 427 +++++++++++++++++++++++------------------------- src/corelib/io/qdir.h | 18 +- 2 files changed, 216 insertions(+), 229 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 5d56529..3e64de9 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -82,117 +82,105 @@ static QString driveSpec(const QString &path) //************* QDirPrivate class QDirPrivate + : public QSharedData { - friend struct QScopedPointerDeleter; - public: - QDirPrivate(const QDir *copy = 0); - ~QDirPrivate(); - - struct Data { - inline Data() - : ref(1), + QDirPrivate() + : QSharedData() #ifdef QT3_SUPPORT - filterSepChar(0), matchAllDirs(false), + , filterSepChar(0) + , matchAllDirs(false) #endif - fileEngine(0), listsDirty(1) - {} - inline Data(const Data ©) - : ref(1), path(copy.path), nameFilters(copy.nameFilters), sort(copy.sort), - filters(copy.filters), + , fileEngine(0) + , listsDirty(1) + { + } + + QDirPrivate(const QDirPrivate ©) + : QSharedData(copy) + , path(copy.path) + , nameFilters(copy.nameFilters) + , sort(copy.sort) + , filters(copy.filters) #ifdef QT3_SUPPORT - filterSepChar(copy.filterSepChar), matchAllDirs(copy.matchAllDirs), + , filterSepChar(copy.filterSepChar) + , matchAllDirs(copy.matchAllDirs) #endif - fileEngine(0), listsDirty(1) - {} - inline ~Data() - { delete fileEngine; } - - void updateFileLists() const; - static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *); - - static inline QChar getFilterSepChar(const QString &nameFilter) - { - QChar sep(QLatin1Char(';')); - int i = nameFilter.indexOf(sep, 0); - if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1) - sep = QChar(QLatin1Char(' ')); - return sep; - } + , fileEngine(0) + , listsDirty(1) + { + } - static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0) - { - if (sep == 0) - sep = getFilterSepChar(nameFilter); - QStringList ret = nameFilter.split(sep); - for (int i = 0; i < ret.count(); ++i) - ret[i] = ret[i].trimmed(); - return ret; - } + ~QDirPrivate() + { + delete fileEngine; + } - static void detach(QDirPrivate::Data *&data, bool createFileEngine = true); + void initFileEngine(); + void updateFileLists() const; - inline void setPath(QString p) - { - if ((p.endsWith(QLatin1Char('/')) || p.endsWith(QLatin1Char('\\'))) - && p.length() > 1) { -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - if (!(p.length() == 3 && p.at(1) == QLatin1Char(':'))) -#endif - p.truncate(p.length() - 1); - } + static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *); - delete fileEngine; - fileEngine = QAbstractFileEngine::create(p); + static inline QChar getFilterSepChar(const QString &nameFilter) + { + QChar sep(QLatin1Char(';')); + int i = nameFilter.indexOf(sep, 0); + if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1) + sep = QChar(QLatin1Char(' ')); + return sep; + } - // set the path to be the qt friendly version so then we can operate on it using just / - path = fileEngine->fileName(QAbstractFileEngine::DefaultName); - clear(); - } + static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0) + { + if (sep == 0) + sep = getFilterSepChar(nameFilter); + QStringList ret = nameFilter.split(sep); + for (int i = 0; i < ret.count(); ++i) + ret[i] = ret[i].trimmed(); + return ret; + } - inline void clear() { - listsDirty = 1; - files.clear(); - fileInfos.clear(); + inline void setPath(QString p) + { + if ((p.endsWith(QLatin1Char('/')) || p.endsWith(QLatin1Char('\\'))) + && p.length() > 1) { +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + if (!(p.length() == 3 && p.at(1) == QLatin1Char(':'))) +#endif + p.truncate(p.length() - 1); } - mutable QAtomicInt ref; + delete fileEngine; + fileEngine = QAbstractFileEngine::create(p); + + // set the path to be the qt friendly version so then we can operate on it using just / + path = fileEngine->fileName(QAbstractFileEngine::DefaultName); + clear(); + } - QString path; - QStringList nameFilters; - QDir::SortFlags sort; - QDir::Filters filters; + inline void clear() { + listsDirty = 1; + files.clear(); + fileInfos.clear(); + } + + QString path; + QStringList nameFilters; + QDir::SortFlags sort; + QDir::Filters filters; #ifdef QT3_SUPPORT - QChar filterSepChar; - bool matchAllDirs; + QChar filterSepChar; + bool matchAllDirs; #endif - mutable QAbstractFileEngine *fileEngine; - mutable uint listsDirty : 1; - mutable QStringList files; - mutable QFileInfoList fileInfos; - } *data; + QAbstractFileEngine *fileEngine; + mutable uint listsDirty : 1; + mutable QStringList files; + mutable QFileInfoList fileInfos; }; -QDirPrivate::QDirPrivate(const QDir *copy) -{ - if (copy) { - copy->d_func()->data->ref.ref(); - data = copy->d_func()->data; - } else { - data = new QDirPrivate::Data; - } -} - -QDirPrivate::~QDirPrivate() -{ - if (!data->ref.deref()) - delete data; - data = 0; -} - /* For sorting */ struct QDirSortItem { @@ -273,7 +261,7 @@ bool QDirSortItemComparator::operator()(const QDirSortItem &n1, const QDirSortIt return r < 0; } -inline void QDirPrivate::Data::sortFileList(QDir::SortFlags sort, QFileInfoList &l, +inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, QStringList *names, QFileInfoList *infos) { // names and infos are always empty lists or 0 here @@ -304,7 +292,7 @@ inline void QDirPrivate::Data::sortFileList(QDir::SortFlags sort, QFileInfoList } } -inline void QDirPrivate::Data::updateFileLists() const +inline void QDirPrivate::updateFileLists() const { if (listsDirty) { QFileInfoList l; @@ -318,14 +306,11 @@ inline void QDirPrivate::Data::updateFileLists() const } } -void QDirPrivate::Data::detach(QDirPrivate::Data *&data, bool createFileEngine) +void QDirPrivate::initFileEngine() { - qAtomicDetach(data); - if (createFileEngine) { - QAbstractFileEngine *newFileEngine = QAbstractFileEngine::create(data->path); - delete data->fileEngine; - data->fileEngine = newFileEngine; - } + QAbstractFileEngine *newFileEngine = QAbstractFileEngine::create(path); + delete fileEngine; + fileEngine = newFileEngine; } /*! @@ -512,11 +497,10 @@ void QDirPrivate::Data::detach(QDirPrivate::Data *&data, bool createFileEngine) QDir::QDir(const QString &path) : d_ptr(new QDirPrivate) { Q_D(QDir); - QDirPrivate::Data::detach(d->data, false); - d->data->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); - d->data->nameFilters = QStringList(QString::fromLatin1("*")); - d->data->filters = AllEntries; - d->data->sort = SortFlags(Name | IgnoreCase); + d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); + d->nameFilters = QStringList(QString::fromLatin1("*")); + d->filters = AllEntries; + d->sort = SortFlags(Name | IgnoreCase); } /*! @@ -541,23 +525,22 @@ QDir::QDir(const QString &path, const QString &nameFilter, SortFlags sort, Filters filters) : d_ptr(new QDirPrivate) { Q_D(QDir); - QDirPrivate::Data::detach(d->data, false); - d->data->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); - d->data->nameFilters = QDir::nameFiltersFromString(nameFilter); - bool empty = d->data->nameFilters.isEmpty(); + d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); + d->nameFilters = QDir::nameFiltersFromString(nameFilter); + bool empty = d->nameFilters.isEmpty(); if (!empty) { empty = true; - for (int i = 0; i < d->data->nameFilters.size(); ++i) { - if (!d->data->nameFilters.at(i).isEmpty()) { + for (int i = 0; i < d->nameFilters.size(); ++i) { + if (!d->nameFilters.at(i).isEmpty()) { empty = false; break; } } } if (empty) - d->data->nameFilters = QStringList(QString::fromLatin1("*")); - d->data->sort = sort; - d->data->filters = filters; + d->nameFilters = QStringList(QString::fromLatin1("*")); + d->sort = sort; + d->filters = filters; } /*! @@ -566,7 +549,8 @@ QDir::QDir(const QString &path, const QString &nameFilter, \sa operator=() */ -QDir::QDir(const QDir &dir) : d_ptr(new QDirPrivate(&dir)) +QDir::QDir(const QDir &dir) + : d_ptr(dir.d_ptr) { } @@ -578,6 +562,11 @@ QDir::~QDir() { } +void QDir::detach() +{ + d_ptr.detach(); +} + /*! Sets the path of the directory to \a path. The path is cleaned of redundant ".", ".." and of multiple separators. No check is made @@ -596,9 +585,7 @@ QDir::~QDir() */ void QDir::setPath(const QString &path) { - Q_D(QDir); - QDirPrivate::Data::detach(d->data, false); - d->data->setPath(path); + d_ptr->setPath(path); } /*! @@ -614,7 +601,7 @@ void QDir::setPath(const QString &path) QString QDir::path() const { Q_D(const QDir); - return d->data->path; + return d->path; } /*! @@ -628,7 +615,7 @@ QString QDir::path() const QString QDir::absolutePath() const { Q_D(const QDir); - QString ret = d->data->path; + QString ret = d->path; if (QDir::isRelativePath(ret)) ret = absoluteFilePath(QString::fromLatin1("")); return cleanPath(ret); @@ -654,9 +641,9 @@ QString QDir::canonicalPath() const { Q_D(const QDir); - if (!d->data->fileEngine) + if (!d->fileEngine) return QLatin1String(""); - return cleanPath(d->data->fileEngine->fileName(QAbstractFileEngine::CanonicalName)); + return cleanPath(d->fileEngine->fileName(QAbstractFileEngine::CanonicalName)); } /*! @@ -673,10 +660,10 @@ QString QDir::canonicalPath() const QString QDir::dirName() const { Q_D(const QDir); - int pos = d->data->path.lastIndexOf(QLatin1Char('/')); + int pos = d->path.lastIndexOf(QLatin1Char('/')); if (pos == -1) - return d->data->path; - return d->data->path.mid(pos + 1); + return d->path; + return d->path.mid(pos + 1); } /*! @@ -694,7 +681,7 @@ QString QDir::filePath(const QString &fileName) const if (isAbsolutePath(fileName)) return QString(fileName); - QString ret = d->data->path; + QString ret = d->path; if (!fileName.isEmpty()) { if (!ret.isEmpty() && ret[(int)ret.length()-1] != QLatin1Char('/') && fileName[0] != QLatin1Char('/')) ret += QLatin1Char('/'); @@ -716,18 +703,18 @@ QString QDir::absoluteFilePath(const QString &fileName) const Q_D(const QDir); if (isAbsolutePath(fileName)) return fileName; - if (!d->data->fileEngine) + if (!d->fileEngine) return fileName; QString ret; #ifndef QT_NO_FSFILEENGINE - if (isRelativePath(d->data->path)) //get pwd + if (isRelativePath(d->path)) //get pwd ret = QFSFileEngine::currentPath(fileName); #endif - if (!d->data->path.isEmpty() && d->data->path != QLatin1String(".")) { + if (!d->path.isEmpty() && d->path != QLatin1String(".")) { if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) ret += QLatin1Char('/'); - ret += d->data->path; + ret += d->path; } if (!fileName.isEmpty()) { if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) @@ -875,11 +862,12 @@ QString QDir::fromNativeSeparators(const QString &pathName) */ bool QDir::cd(const QString &dirName) { - Q_D(QDir); + // Don't detach just yet. + const QDirPrivate * const d = d_ptr.constData(); if (dirName.isEmpty() || dirName == QLatin1String(".")) return true; - QString newPath = d->data->path; + QString newPath = d->path; if (isAbsolutePath(dirName)) { newPath = cleanPath(dirName); } else { @@ -892,7 +880,7 @@ bool QDir::cd(const QString &dirName) newPath += dirName; if (dirName.indexOf(QLatin1Char('/')) >= 0 - || d->data->path == QLatin1String(".") + || d->path == QLatin1String(".") || dirName == QLatin1String("..")) { newPath = cleanPath(newPath); /* @@ -939,8 +927,7 @@ bool QDir::cdUp() QStringList QDir::nameFilters() const { Q_D(const QDir); - - return d->data->nameFilters; + return d->nameFilters; } /*! @@ -961,10 +948,10 @@ QStringList QDir::nameFilters() const void QDir::setNameFilters(const QStringList &nameFilters) { Q_D(QDir); + d->initFileEngine(); + d->clear(); - QDirPrivate::Data::detach(d->data); - d->data->clear(); - d->data->nameFilters = nameFilters; + d->nameFilters = nameFilters; } /*! @@ -1068,8 +1055,7 @@ QStringList QDir::searchPaths(const QString &prefix) QDir::Filters QDir::filter() const { Q_D(const QDir); - - return d->data->filters; + return d->filters; } /*! @@ -1151,10 +1137,10 @@ QDir::Filters QDir::filter() const void QDir::setFilter(Filters filters) { Q_D(QDir); + d->initFileEngine(); + d->clear(); - QDirPrivate::Data::detach(d->data); - d->data->clear(); - d->data->filters = filters; + d->filters = filters; } /*! @@ -1165,8 +1151,7 @@ void QDir::setFilter(Filters filters) QDir::SortFlags QDir::sorting() const { Q_D(const QDir); - - return d->data->sort; + return d->sort; } /*! @@ -1210,10 +1195,10 @@ QDir::SortFlags QDir::sorting() const void QDir::setSorting(SortFlags sort) { Q_D(QDir); + d->initFileEngine(); + d->clear(); - QDirPrivate::Data::detach(d->data); - d->data->clear(); - d->data->sort = sort; + d->sort = sort; } /*! @@ -1226,9 +1211,8 @@ void QDir::setSorting(SortFlags sort) uint QDir::count() const { Q_D(const QDir); - - d->data->updateFileLists(); - return d->data->files.count(); + d->updateFileLists(); + return d->files.count(); } /*! @@ -1241,9 +1225,8 @@ uint QDir::count() const QString QDir::operator[](int pos) const { Q_D(const QDir); - - d->data->updateFileLists(); - return d->data->files[pos]; + d->updateFileLists(); + return d->files[pos]; } /*! @@ -1268,8 +1251,7 @@ QString QDir::operator[](int pos) const QStringList QDir::entryList(Filters filters, SortFlags sort) const { Q_D(const QDir); - - return entryList(d->data->nameFilters, filters, sort); + return entryList(d->nameFilters, filters, sort); } @@ -1292,8 +1274,7 @@ QStringList QDir::entryList(Filters filters, SortFlags sort) const QFileInfoList QDir::entryInfoList(Filters filters, SortFlags sort) const { Q_D(const QDir); - - return entryInfoList(d->data->nameFilters, filters, sort); + return entryInfoList(d->nameFilters, filters, sort); } /*! @@ -1318,27 +1299,27 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, Q_D(const QDir); if (filters == NoFilter) - filters = d->data->filters; + filters = d->filters; #ifdef QT3_SUPPORT - if (d->data->matchAllDirs) + if (d->matchAllDirs) filters |= AllDirs; #endif if (sort == NoSort) - sort = d->data->sort; + sort = d->sort; - if (filters == d->data->filters && sort == d->data->sort && nameFilters == d->data->nameFilters) { - d->data->updateFileLists(); - return d->data->files; + if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) { + d->updateFileLists(); + return d->files; } QFileInfoList l; - QDirIterator it(d->data->path, nameFilters, filters); + QDirIterator it(d->path, nameFilters, filters); while (it.hasNext()) { it.next(); l.append(it.fileInfo()); } QStringList ret; - d->data->sortFileList(sort, l, &ret, 0); + d->sortFileList(sort, l, &ret, 0); return ret; } @@ -1364,27 +1345,27 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter Q_D(const QDir); if (filters == NoFilter) - filters = d->data->filters; + filters = d->filters; #ifdef QT3_SUPPORT - if (d->data->matchAllDirs) + if (d->matchAllDirs) filters |= AllDirs; #endif if (sort == NoSort) - sort = d->data->sort; + sort = d->sort; - if (filters == d->data->filters && sort == d->data->sort && nameFilters == d->data->nameFilters) { - d->data->updateFileLists(); - return d->data->fileInfos; + if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) { + d->updateFileLists(); + return d->fileInfos; } QFileInfoList l; - QDirIterator it(d->data->path, nameFilters, filters); + QDirIterator it(d->path, nameFilters, filters); while (it.hasNext()) { it.next(); l.append(it.fileInfo()); } QFileInfoList ret; - d->data->sortFileList(sort, l, 0, &ret); + d->sortFileList(sort, l, 0, &ret); return ret; } @@ -1403,11 +1384,11 @@ bool QDir::mkdir(const QString &dirName) const qWarning("QDir::mkdir: Empty or null file name(s)"); return false; } - if (!d->data->fileEngine) + if (!d->fileEngine) return false; QString fn = filePath(dirName); - return d->data->fileEngine->mkdir(fn, false); + return d->fileEngine->mkdir(fn, false); } /*! @@ -1427,11 +1408,11 @@ bool QDir::rmdir(const QString &dirName) const qWarning("QDir::rmdir: Empty or null file name(s)"); return false; } - if (!d->data->fileEngine) + if (!d->fileEngine) return false; QString fn = filePath(dirName); - return d->data->fileEngine->rmdir(fn, false); + return d->fileEngine->rmdir(fn, false); } /*! @@ -1452,11 +1433,11 @@ bool QDir::mkpath(const QString &dirPath) const qWarning("QDir::mkpath: Empty or null file name(s)"); return false; } - if (!d->data->fileEngine) + if (!d->fileEngine) return false; QString fn = filePath(dirPath); - return d->data->fileEngine->mkdir(fn, true); + return d->fileEngine->mkdir(fn, true); } /*! @@ -1478,11 +1459,11 @@ bool QDir::rmpath(const QString &dirPath) const qWarning("QDir::rmpath: Empty or null file name(s)"); return false; } - if (!d->data->fileEngine) + if (!d->fileEngine) return false; QString fn = filePath(dirPath); - return d->data->fileEngine->rmdir(fn, true); + return d->fileEngine->rmdir(fn, true); } /*! @@ -1498,10 +1479,10 @@ bool QDir::isReadable() const { Q_D(const QDir); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; const QAbstractFileEngine::FileFlags info = - d->data->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType + d->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType | QAbstractFileEngine::PermsMask); if (!(info & QAbstractFileEngine::DirectoryType)) return false; @@ -1523,10 +1504,10 @@ bool QDir::exists() const { Q_D(const QDir); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; const QAbstractFileEngine::FileFlags info = - d->data->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType + d->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType | QAbstractFileEngine::ExistsFlag | QAbstractFileEngine::Refresh); if (!(info & QAbstractFileEngine::DirectoryType)) @@ -1550,9 +1531,9 @@ bool QDir::isRoot() const { Q_D(const QDir); - if (!d->data->fileEngine) + if (!d->fileEngine) return true; - return d->data->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag; + return d->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag; } /*! @@ -1584,9 +1565,9 @@ bool QDir::isRelative() const { Q_D(const QDir); - if (!d->data->fileEngine) + if (!d->fileEngine) return false; - return d->data->fileEngine->isRelativePath(); + return d->fileEngine->isRelativePath(); } @@ -1599,17 +1580,19 @@ bool QDir::isRelative() const */ bool QDir::makeAbsolute() // ### What do the return values signify? { - Q_D(QDir); - - if (!d->data->fileEngine) + if (!d_ptr.constData()->fileEngine) return false; - QString absolutePath = d->data->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); + QString absolutePath = d_ptr.constData()->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); if (QDir::isRelativePath(absolutePath)) return false; - QDirPrivate::Data::detach(d->data); - d->data->path = absolutePath; - d->data->fileEngine->setFileName(absolutePath); - if (!(d->data->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) + + Q_D(QDir); + + d->path = absolutePath; + d->initFileEngine(); + d->clear(); + + if (!(d->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) return false; return true; } @@ -1628,16 +1611,16 @@ bool QDir::operator==(const QDir &dir) const const QDirPrivate *d = d_func(); const QDirPrivate *other = dir.d_func(); - if (d->data == other->data) + if (d == other) return true; - Q_ASSERT(d->data->fileEngine && other->data->fileEngine); - if (d->data->fileEngine->caseSensitive() != other->data->fileEngine->caseSensitive()) + Q_ASSERT(d->fileEngine && other->fileEngine); + if (d->fileEngine->caseSensitive() != other->fileEngine->caseSensitive()) return false; - if (d->data->filters == other->data->filters - && d->data->sort == other->data->sort - && d->data->nameFilters == other->data->nameFilters) { + if (d->filters == other->filters + && d->sort == other->sort + && d->nameFilters == other->nameFilters) { QString dir1 = absolutePath(), dir2 = dir.absolutePath(); - if (!other->data->fileEngine->caseSensitive()) + if (!other->fileEngine->caseSensitive()) return (dir1.toLower() == dir2.toLower()); return (dir1 == dir2); @@ -1655,8 +1638,7 @@ QDir &QDir::operator=(const QDir &dir) if (this == &dir) return *this; - Q_D(QDir); - qAtomicAssign(d->data, dir.d_func()->data); + d_ptr = dir.d_ptr; return *this; } @@ -1670,10 +1652,7 @@ QDir &QDir::operator=(const QDir &dir) */ QDir &QDir::operator=(const QString &path) { - Q_D(QDir); - - QDirPrivate::Data::detach(d->data, false); - d->data->setPath(path); + d_ptr->setPath(path); return *this; } @@ -1717,13 +1696,12 @@ bool QDir::remove(const QString &fileName) */ bool QDir::rename(const QString &oldName, const QString &newName) { - Q_D(QDir); - if (oldName.isEmpty() || newName.isEmpty()) { qWarning("QDir::rename: Empty or null file name(s)"); return false; } - if (!d->data->fileEngine) + + if (!d_ptr.constData()->fileEngine) return false; QFile file(filePath(oldName)); @@ -2163,10 +2141,9 @@ bool QDir::isRelativePath(const QString &path) */ void QDir::refresh() const { - Q_D(const QDir); - - QDirPrivate::Data::detach(const_cast(d)->data); - d->data->clear(); + QDirPrivate *d = const_cast(this)->d_func(); + d->initFileEngine(); + d->clear(); } /*! @@ -2178,7 +2155,7 @@ void QDir::refresh() const */ QStringList QDir::nameFiltersFromString(const QString &nameFilter) { - return QDirPrivate::Data::splitFilters(nameFilter); + return QDirPrivate::splitFilters(nameFilter); } /*! @@ -2243,7 +2220,7 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter) bool QDir::matchAllDirs() const { Q_D(const QDir); - return d->data->matchAllDirs; + return d->matchAllDirs; } @@ -2255,10 +2232,10 @@ bool QDir::matchAllDirs() const void QDir::setMatchAllDirs(bool on) { Q_D(QDir); + d->initFileEngine(); + d->clear(); - QDirPrivate::Data::detach(d->data); - d->data->clear(); - d->data->matchAllDirs = on; + d->matchAllDirs = on; } /*! @@ -2267,8 +2244,7 @@ void QDir::setMatchAllDirs(bool on) QString QDir::nameFilter() const { Q_D(const QDir); - - return nameFilters().join(QString(d->data->filterSepChar)); + return nameFilters().join(QString(d->filterSepChar)); } /*! @@ -2294,9 +2270,8 @@ QString QDir::nameFilter() const void QDir::setNameFilter(const QString &nameFilter) { Q_D(QDir); - - d->data->filterSepChar = QDirPrivate::Data::getFilterSepChar(nameFilter); - setNameFilters(QDirPrivate::Data::splitFilters(nameFilter, d->data->filterSepChar)); + d->filterSepChar = QDirPrivate::getFilterSepChar(nameFilter); + setNameFilters(QDirPrivate::splitFilters(nameFilter, d->filterSepChar)); } /*! diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index 28da271..abfe387 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -45,7 +45,7 @@ #include #include #include -#include +#include QT_BEGIN_HEADER @@ -58,9 +58,19 @@ class QDirPrivate; class Q_CORE_EXPORT QDir { protected: - QScopedPointer d_ptr; + QSharedDataPointer d_ptr; private: - Q_DECLARE_PRIVATE(QDir) + inline QDirPrivate* d_func() + { + detach(); + return const_cast(d_ptr.constData()); + } + + inline const QDirPrivate* d_func() const + { + return d_ptr.constData(); + } + public: enum Filter { Dirs = 0x001, Files = 0x002, @@ -130,6 +140,8 @@ public: QDir &operator=(const QDir &); QDir &operator=(const QString &path); + void detach(); + void setPath(const QString &path); QString path() const; QString absolutePath() const; -- cgit v0.12 From 84373eb1c5f78874cf44b6e63cbffd4d49820f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 25 Aug 2010 14:18:03 +0200 Subject: QDirPrivate refactoring Moved common initialization code from QDir ctor to QDirPrivate. Reviewed-by: Thomas Zander --- src/corelib/io/qdir.cpp | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 3e64de9..02f0e06 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -85,8 +85,14 @@ class QDirPrivate : public QSharedData { public: - QDirPrivate() + QDirPrivate(const QString &path, + const QStringList &nameFilters_ = QStringList(), + QDir::SortFlags sort_ = QDir::SortFlags(QDir::Name | QDir::IgnoreCase), + QDir::Filters filters_ = QDir::AllEntries) : QSharedData() + , nameFilters(nameFilters_) + , sort(sort_) + , filters(filters_) #ifdef QT3_SUPPORT , filterSepChar(0) , matchAllDirs(false) @@ -94,6 +100,20 @@ public: , fileEngine(0) , listsDirty(1) { + setPath(path.isEmpty() ? QString::fromLatin1(".") : path); + + bool empty = nameFilters.isEmpty(); + if (!empty) { + empty = true; + for (int i = 0; i < nameFilters.size(); ++i) { + if (!nameFilters.at(i).isEmpty()) { + empty = false; + break; + } + } + } + if (empty) + nameFilters = QStringList(QString::fromLatin1("*")); } QDirPrivate(const QDirPrivate ©) @@ -494,13 +514,8 @@ void QDirPrivate::initFileEngine() \sa currentPath() */ -QDir::QDir(const QString &path) : d_ptr(new QDirPrivate) +QDir::QDir(const QString &path) : d_ptr(new QDirPrivate(path)) { - Q_D(QDir); - d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); - d->nameFilters = QStringList(QString::fromLatin1("*")); - d->filters = AllEntries; - d->sort = SortFlags(Name | IgnoreCase); } /*! @@ -522,25 +537,9 @@ QDir::QDir(const QString &path) : d_ptr(new QDirPrivate) \sa exists(), setPath(), setNameFilter(), setFilter(), setSorting() */ QDir::QDir(const QString &path, const QString &nameFilter, - SortFlags sort, Filters filters) : d_ptr(new QDirPrivate) + SortFlags sort, Filters filters) + : d_ptr(new QDirPrivate(path, QDir::nameFiltersFromString(nameFilter), sort, filters)) { - Q_D(QDir); - d->setPath(path.isEmpty() ? QString::fromLatin1(".") : path); - d->nameFilters = QDir::nameFiltersFromString(nameFilter); - bool empty = d->nameFilters.isEmpty(); - if (!empty) { - empty = true; - for (int i = 0; i < d->nameFilters.size(); ++i) { - if (!d->nameFilters.at(i).isEmpty()) { - empty = false; - break; - } - } - } - if (empty) - d->nameFilters = QStringList(QString::fromLatin1("*")); - d->sort = sort; - d->filters = filters; } /*! -- cgit v0.12 From 72b00f0b6285aed47009067be4d92869d128856e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 25 Aug 2010 15:16:51 +0200 Subject: QDirPrivate refactoring Some renaming to make intent clearer and improve consistency: listsDirty => listsInitialized (logic inverted) updateFileLists => initFileLists clear => clearFileLists Also note that initializing file lists shouldn't trigger detach, because no previous version of the cached data has been seen. Reviewed-by: Thomas Zander --- src/corelib/io/qdir.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 02f0e06..a88b284 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -98,7 +98,7 @@ public: , matchAllDirs(false) #endif , fileEngine(0) - , listsDirty(1) + , fileListsInitialized(false) { setPath(path.isEmpty() ? QString::fromLatin1(".") : path); @@ -127,7 +127,7 @@ public: , matchAllDirs(copy.matchAllDirs) #endif , fileEngine(0) - , listsDirty(1) + , fileListsInitialized(false) { } @@ -137,7 +137,7 @@ public: } void initFileEngine(); - void updateFileLists() const; + void initFileLists() const; static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *); @@ -175,11 +175,11 @@ public: // set the path to be the qt friendly version so then we can operate on it using just / path = fileEngine->fileName(QAbstractFileEngine::DefaultName); - clear(); + clearFileLists(); } - inline void clear() { - listsDirty = 1; + inline void clearFileLists() { + fileListsInitialized = false; files.clear(); fileInfos.clear(); } @@ -196,7 +196,7 @@ public: QAbstractFileEngine *fileEngine; - mutable uint listsDirty : 1; + mutable bool fileListsInitialized; mutable QStringList files; mutable QFileInfoList fileInfos; }; @@ -312,9 +312,9 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, } } -inline void QDirPrivate::updateFileLists() const +inline void QDirPrivate::initFileLists() const { - if (listsDirty) { + if (!fileListsInitialized) { QFileInfoList l; QDirIterator it(path, nameFilters, filters); while (it.hasNext()) { @@ -322,7 +322,7 @@ inline void QDirPrivate::updateFileLists() const l.append(it.fileInfo()); } sortFileList(sort, l, &files, &fileInfos); - listsDirty = 0; + fileListsInitialized = true; } } @@ -948,7 +948,7 @@ void QDir::setNameFilters(const QStringList &nameFilters) { Q_D(QDir); d->initFileEngine(); - d->clear(); + d->clearFileLists(); d->nameFilters = nameFilters; } @@ -1137,7 +1137,7 @@ void QDir::setFilter(Filters filters) { Q_D(QDir); d->initFileEngine(); - d->clear(); + d->clearFileLists(); d->filters = filters; } @@ -1195,7 +1195,7 @@ void QDir::setSorting(SortFlags sort) { Q_D(QDir); d->initFileEngine(); - d->clear(); + d->clearFileLists(); d->sort = sort; } @@ -1210,7 +1210,7 @@ void QDir::setSorting(SortFlags sort) uint QDir::count() const { Q_D(const QDir); - d->updateFileLists(); + d->initFileLists(); return d->files.count(); } @@ -1224,7 +1224,7 @@ uint QDir::count() const QString QDir::operator[](int pos) const { Q_D(const QDir); - d->updateFileLists(); + d->initFileLists(); return d->files[pos]; } @@ -1307,7 +1307,7 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, sort = d->sort; if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) { - d->updateFileLists(); + d->initFileLists(); return d->files; } @@ -1353,7 +1353,7 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter sort = d->sort; if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) { - d->updateFileLists(); + d->initFileLists(); return d->fileInfos; } @@ -1589,7 +1589,7 @@ bool QDir::makeAbsolute() // ### What do the return values signify? d->path = absolutePath; d->initFileEngine(); - d->clear(); + d->clearFileLists(); if (!(d->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) return false; @@ -2142,7 +2142,7 @@ void QDir::refresh() const { QDirPrivate *d = const_cast(this)->d_func(); d->initFileEngine(); - d->clear(); + d->clearFileLists(); } /*! @@ -2232,7 +2232,7 @@ void QDir::setMatchAllDirs(bool on) { Q_D(QDir); d->initFileEngine(); - d->clear(); + d->clearFileLists(); d->matchAllDirs = on; } -- cgit v0.12 From 1218e1ecfee17aec798d73e469fea292b93f2246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 25 Aug 2010 15:25:22 +0200 Subject: QDirPrivate refactoring While refactoring, a bug was introduced where shared data would be updated before detaching in setNameFilter. Further refactoring turned this into a double-detach, instead. Now the issue is fixed by adding the appropriate initFileEngine and nameFilters assignment, instead of calling setNameFilters to finish the job. Reviewed-by: Thomas Zander --- src/corelib/io/qdir.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index a88b284..64eea23 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2269,8 +2269,10 @@ QString QDir::nameFilter() const void QDir::setNameFilter(const QString &nameFilter) { Q_D(QDir); + d->initFileEngine(); + d->filterSepChar = QDirPrivate::getFilterSepChar(nameFilter); - setNameFilters(QDirPrivate::splitFilters(nameFilter, d->filterSepChar)); + d->nameFilters = QDirPrivate::splitFilters(nameFilter, d->filterSepChar); } /*! -- cgit v0.12 From 852be4c69f8dd4a890d78f9ea7210ecc9e44254a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 26 Aug 2010 11:40:52 +0200 Subject: Begin defining the interface for file engines NG New file engine API is meant to be a thin layer of abstraction over native file system APIs. Stateless and static for the time being. Platform-specific implementations will follow. Reviewed-by: Thomas Zander Reviewed-by: Prasanth Ullattil --- src/corelib/io/qfilesystemengine_p.h | 27 +++++++++++++++++++++++++++ src/corelib/io/qfilesystemmetadata_p.h | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 817f925..c1bb3b4 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -53,10 +53,37 @@ // We mean it. // +#include "qfile.h" +#include "qfilesystementry_p.h" +#include "qfilesystemmetadata_p.h" + QT_BEGIN_NAMESPACE class QFileSystemEngine { +public: + static bool isCaseSensitive(); + + static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link); + static QFileSystemEntry canonicalName(const QFileSystemEntry &entry); + static QFileSystemEntry absoluteName(const QFileSystemEntry &entry); + + static QString bundleName(const QFileSystemEntry &entry); + + static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, + QFileSystemMetaData::FileFlags what); + + static bool createDirectory(const QFileSystemEntry &entry, bool createParents); + static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents); + + static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target); + + static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target); + static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target); + static bool removeFile(const QFileSystemEntry &entry); + + static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, + QFileSystemMetaData *data = 0); }; QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index c051bc5..9664177 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -53,10 +53,16 @@ // We mean it. // +#include + QT_BEGIN_NAMESPACE class QFileSystemMetaData { +public: + enum FileFlag { + }; + Q_DECLARE_FLAGS(FileFlags, FileFlag); }; QT_END_NAMESPACE -- cgit v0.12 From 9367d50311640c1765a05b744de2ac796311fac7 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Thu, 26 Aug 2010 13:56:53 +0200 Subject: Add empty implementations of each of the filesystemengines --- src/corelib/io/io.pri | 4 + src/corelib/io/qfilesystemengine_mac.cpp | 119 ++++++++++++++++++++++++++++++ src/corelib/io/qfilesystemengine_unix.cpp | 119 ++++++++++++++++++++++++++++++ src/corelib/io/qfilesystemengine_win.cpp | 119 ++++++++++++++++++++++++++++++ 4 files changed, 361 insertions(+) create mode 100644 src/corelib/io/qfilesystemengine_mac.cpp create mode 100644 src/corelib/io/qfilesystemengine_unix.cpp create mode 100644 src/corelib/io/qfilesystemengine_win.cpp diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 0334534..d3fddaf 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -68,6 +68,7 @@ win32 { HEADERS += io/qfilesystemwatcher_win_p.h HEADERS += io/qwindowspipewriter_p.h SOURCES += io/qwindowspipewriter.cpp + SOURCES += io/qfilesystemengine_win.cpp } else:unix { SOURCES += io/qfsfileengine_unix.cpp SOURCES += io/qfsfileengine_iterator_unix.cpp @@ -76,6 +77,9 @@ win32 { macx-*: { HEADERS += io/qfilesystemwatcher_fsevents_p.h SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp + SOURCES += io/qfilesystemengine_mac.cpp + } else { + SOURCES += io/qfilesystemengine_unix.cpp } linux-*:!symbian { diff --git a/src/corelib/io/qfilesystemengine_mac.cpp b/src/corelib/io/qfilesystemengine_mac.cpp new file mode 100644 index 0000000..ac71f0e --- /dev/null +++ b/src/corelib/io/qfilesystemengine_mac.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfilesystemengine_p.h" + +bool QFileSystemEngine::isCaseSensitive() +{ + return true; +} + +//static +QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) +{ + return link; // TODO implement +} + +//static +QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) +{ + return entry; // TODO implement; +} + +//static +QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) +{ + return entry; // TODO implement; +} + +//static +QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) +{ + return QString(); // TODO implement; +} + +//static +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::FileFlags what) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) +{ + return false; // TODO implement; +} diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp new file mode 100644 index 0000000..ac71f0e --- /dev/null +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfilesystemengine_p.h" + +bool QFileSystemEngine::isCaseSensitive() +{ + return true; +} + +//static +QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) +{ + return link; // TODO implement +} + +//static +QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) +{ + return entry; // TODO implement; +} + +//static +QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) +{ + return entry; // TODO implement; +} + +//static +QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) +{ + return QString(); // TODO implement; +} + +//static +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::FileFlags what) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) +{ + return false; // TODO implement; +} diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp new file mode 100644 index 0000000..ac71f0e --- /dev/null +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfilesystemengine_p.h" + +bool QFileSystemEngine::isCaseSensitive() +{ + return true; +} + +//static +QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) +{ + return link; // TODO implement +} + +//static +QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) +{ + return entry; // TODO implement; +} + +//static +QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) +{ + return entry; // TODO implement; +} + +//static +QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) +{ + return QString(); // TODO implement; +} + +//static +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::FileFlags what) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) +{ + return false; // TODO implement; +} -- cgit v0.12 From 710258ee0ab068bb713edc8d952293cf810a206d Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 27 Aug 2010 10:34:01 +0200 Subject: Move absoluteName to new fileSystemEngine for unix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the code for determining the absolute path on unix from the qfsfileengine_unix.cpp to the new qfilesystemengine_unix.cpp which is a static, stateless class. Made sure that the old qfsfileengine_unix.cpp keeps on working by calling into the new one. Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 30 +++++++++++++++++++++++++++++- src/corelib/io/qfsfileengine_unix.cpp | 19 +++++-------------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index ac71f0e..bcd75fc 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qfilesystemengine_p.h" +#include "qfsfileengine.h" bool QFileSystemEngine::isCaseSensitive() { @@ -61,7 +62,34 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) //static QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) { - return entry; // TODO implement; + if (entry.isAbsolute()) + return entry; + + QByteArray orig = entry.nativeFilePath(); + QByteArray result; + if (orig.isEmpty() || !orig.startsWith('/')) { + QFileSystemEntry cur(QFSFileEngine::currentPath()); + result = cur.nativeFilePath(); + } + if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) { + if (!result.isEmpty() && !result.endsWith('/')) + result.append('/'); + result.append(orig); + } + + if (result.length() == 1 && result[0] == '/') + return QFileSystemEntry(result); + const bool isDir = result.endsWith('/'); + + /* as long as QDir::cleanPath() operates on a QString we have to convert to a string here. + * ideally we never convert to a string since that loses information. Please fix after + * we get a QByteArray version of QDir::cleanPath() + */ + QFileSystemEntry resultingEntry(result); + QString stringVersion = QDir::cleanPath(resultingEntry.filePath()); + if (isDir) + stringVersion.append(QLatin1Char('/')); + return QFileSystemEntry(stringVersion); } //static diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 774932a..5fecb5d 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -43,6 +43,8 @@ #include "qabstractfileengine.h" #include "private/qfsfileengine_p.h" #include "private/qcore_unix_p.h" +#include "qfilesystementry_p.h" +#include "qfilesystemengine_p.h" #ifndef QT_NO_FSFILEENGINE @@ -1046,20 +1048,9 @@ QString QFSFileEngine::fileName(FileName file) const return QLatin1String("/"); return d->filePath.left(slash); } else if (file == AbsoluteName || file == AbsolutePathName) { - QString ret; - if (d->filePath.isEmpty() || !d->filePath.startsWith(QLatin1Char('/'))) - ret = QDir::currentPath(); - if (!d->filePath.isEmpty() && d->filePath != QLatin1String(".")) { - if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) - ret += QLatin1Char('/'); - ret += d->filePath; - } - if (ret == QLatin1String("/")) - return ret; - bool isDir = ret.endsWith(QLatin1Char('/')); - ret = QDir::cleanPath(ret); - if (isDir) - ret += QLatin1Char('/'); + QFileSystemEntry entry(d->filePath); + entry = QFileSystemEngine::absoluteName(entry); + QString ret = entry.filePath(); if (file == AbsolutePathName) { int slash = ret.lastIndexOf(QLatin1Char('/')); if (slash == -1) -- cgit v0.12 From 1b201e0857d8232eeb1c25942c4fad9360cc11c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 26 Aug 2010 13:47:33 +0200 Subject: QDir::operator= simplification With the recent changes to QDirPrivate and how d_ptr is now a QSharedDataPointer, we no longer need to worry about self-assignment, as that is already handled by the d_ptr. Simplifying code here. Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 64eea23..3587243 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1634,9 +1634,6 @@ bool QDir::operator==(const QDir &dir) const */ QDir &QDir::operator=(const QDir &dir) { - if (this == &dir) - return *this; - d_ptr = dir.d_ptr; return *this; } -- cgit v0.12 From fdec31a2e57c7da48be741c14bedaaff4b95e7af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 26 Aug 2010 13:49:31 +0200 Subject: QDir::makeAbsolute could self-destruct on failure makeAbsolute would return false if the newly constructed file engine reported it wasn't referencing a directory. At this point, the private data has already been updated, rendering the instance unusable. Instead, we now create a separate QDir instance and reset our private data only on success. Similarly to what's done in QDir::cd. Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 3587243..1da4f82 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1585,14 +1585,11 @@ bool QDir::makeAbsolute() // ### What do the return values signify? if (QDir::isRelativePath(absolutePath)) return false; - Q_D(QDir); - - d->path = absolutePath; - d->initFileEngine(); - d->clearFileLists(); - - if (!(d->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) + QDir dir(absolutePath); + if (!(dir.d_ptr.constData()->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) return false; + + *this = dir; return true; } -- cgit v0.12 From eeae8a7479cdb0b716b28ad502abed69dbf339b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 26 Aug 2010 14:03:36 +0200 Subject: Simplify QDir::cd Copy constructing a QDir instance from this and then detaching it in setPath doesn't get us anything so we might as well do it all in one go. Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 1da4f82..9ebfce5 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -896,8 +896,7 @@ bool QDir::cd(const QString &dirName) } } - QDir dir(*this); - dir.setPath(newPath); + QDir dir(newPath); if (!dir.exists()) return false; -- cgit v0.12 From e2eeb1b2410d32b629c675b63dd84c9dcb976546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 10:01:42 +0200 Subject: Adding QFileSystemEntry and QFileSystemEngine to build system Since we're refactoring code out of QFSFileEngine the new internal classes have to be compiled in together with the old engines. For the time being, we'll assume Mac uses the unix version of the engine. We'll fork those only if and as needed. --- qmake/Makefile.unix | 8 ++++++++ qmake/Makefile.win32 | 10 ++++++++++ qmake/Makefile.win32-g++ | 8 ++++++++ qmake/Makefile.win32-g++-sh | 8 ++++++++ qmake/qmake.pri | 5 +++-- src/corelib/io/io.pri | 4 +--- src/tools/bootstrap/bootstrap.pro | 7 +++++-- tools/configure/configure.pro | 8 ++++++-- tools/qtestlib/wince/cetest/bootstrapped.pri | 2 ++ 9 files changed, 51 insertions(+), 9 deletions(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 8d56fc8..8c1ac6d 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -16,6 +16,7 @@ OBJS=project.o property.o main.o makefile.o unixmake2.o unixmake.o \ #qt code QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qglobal.o \ qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfile.o \ + qfilesystementry.o qfilesystemengine_unix.o \ qfsfileengine_unix.o qfsfileengine_iterator_unix.o qfsfileengine.o \ qfsfileengine_iterator.o qregexp.o qvector.o qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o \ qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o \ @@ -44,6 +45,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge $(SOURCE_PATH)/src/corelib/global/qglobal.cpp $(SOURCE_PATH)/src/corelib/tools/qregexp.cpp \ $(SOURCE_PATH)/src/corelib/tools/qbytearray.cpp $(SOURCE_PATH)/src/corelib/tools/qbytearraymatcher.cpp \ $(SOURCE_PATH)/src/corelib/io/qdatastream.cpp $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp \ + $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_unix.cpp $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(SOURCE_PATH)/src/corelib/tools/qlist.cpp \ @@ -160,6 +162,12 @@ qlist.o: $(SOURCE_PATH)/src/corelib/tools/qlist.cpp qfile.o: $(SOURCE_PATH)/src/corelib/io/qfile.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfile.cpp +qfilesystementry.o: $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp + +qfilesystemengine_unix.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp + qfsfileengine.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index b58757c..b76348b 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -88,6 +88,8 @@ QTOBJS= \ qbitarray.obj \ qbuffer.obj \ qcryptographichash.obj \ + qfilesystementry.obj \ + qfilesystemengine_win.obj \ qfsfileengine.obj \ qfsfileengine_iterator.obj \ qbytearray.obj \ @@ -141,6 +143,8 @@ clean:: -del qbuffer.obj -del qcryptographichash.obj -del qlinkedlist.obj + -del qfilesystementry.obj + -del qfilesystemengine_win.obj -del qfsfileengine.obj -del qfsfileengine_iterator.obj -del qbytearray.obj @@ -310,6 +314,12 @@ qfile.obj: $(SOURCE_PATH)\src\corelib\io\qfile.cpp qtemporaryfile.obj: $(SOURCE_PATH)\src\corelib\io\qtemporaryfile.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qtemporaryfile.cpp +qfilesystementry.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystementry.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfilesystementry.cpp + +qfilesystemengine_win.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystemengine_win.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfilesystemengine_win.cpp + qfsfileengine_win.obj: $(SOURCE_PATH)\src\corelib\io\qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfsfileengine_win.cpp diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index e52b8c6..c692731 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -61,6 +61,8 @@ QTOBJS= \ qtemporaryfile.o \ qfileinfo.o \ qabstractfileengine.o \ + qfilesystementry.o \ + qfilesystemengine_win.o \ qfsfileengine.o \ qfsfileengine_iterator.o \ qfsfileengine_win.o \ @@ -192,6 +194,12 @@ qtemporaryfile.o: $(SOURCE_PATH)/src/corelib/io/qtemporaryfile.cpp qabstractfileengine.o: $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp +qfilesystementry.o: $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp + +qfilesystemengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp + qfsfileengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index e4e2e6a..cc256e9 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -61,6 +61,8 @@ QTOBJS= \ qtemporaryfile.o \ qfileinfo.o \ qabstractfileengine.o \ + qfilesystementry.o \ + qfilesystemengine_win.o \ qfsfileengine.o \ qfsfileengine_iterator.o \ qfsfileengine_win.o \ @@ -191,6 +193,12 @@ qtemporaryfile.o: $(SOURCE_PATH)/src/corelib/io/qtemporaryfile.cpp qabstractfileengine.o: $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp +qfilesystementry.o: $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp + +qfilesystemengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp + qfsfileengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp diff --git a/qmake/qmake.pri b/qmake/qmake.pri index a7e0ab1..4d78c8b 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -57,6 +57,7 @@ bootstrap { #Qt code qfile.cpp \ qabstractfileengine.cpp \ qfileinfo.cpp \ + qfilesystementry.cpp \ qfsfileengine.cpp \ qfsfileengine_iterator.cpp \ qglobal.cpp \ @@ -125,14 +126,14 @@ bootstrap { #Qt code qxmlutils.h unix { - SOURCES += qfsfileengine_unix.cpp qfsfileengine_iterator_unix.cpp + SOURCES += qfilesystemengine_unix.cpp qfsfileengine_unix.cpp qfsfileengine_iterator_unix.cpp mac { SOURCES += qcore_mac.cpp qsettings_mac.cpp QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported) LIBS += -framework ApplicationServices } } else:win32 { - SOURCES += qfsfileengine_win.cpp qfsfileengine_iterator_win.cpp qsettings_win.cpp + SOURCES += qfilesystemengine_win.cpp qfsfileengine_win.cpp qfsfileengine_iterator_win.cpp qsettings_win.cpp win32-msvc*:LIBS += ole32.lib advapi32.lib win32-g++*:LIBS += -lole32 -luuid } diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index d3fddaf..3bde2de 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -70,6 +70,7 @@ win32 { SOURCES += io/qwindowspipewriter.cpp SOURCES += io/qfilesystemengine_win.cpp } else:unix { + SOURCES += io/qfilesystemengine_unix.cpp SOURCES += io/qfsfileengine_unix.cpp SOURCES += io/qfsfileengine_iterator_unix.cpp symbian:SOURCES += io/qprocess_symbian.cpp @@ -77,9 +78,6 @@ win32 { macx-*: { HEADERS += io/qfilesystemwatcher_fsevents_p.h SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp - SOURCES += io/qfilesystemengine_mac.cpp - } else { - SOURCES += io/qfilesystemengine_unix.cpp } linux-*:!symbian { diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index a74c9c1..bec1329 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -57,6 +57,7 @@ SOURCES += \ ../../corelib/io/qdiriterator.cpp \ ../../corelib/io/qfile.cpp \ ../../corelib/io/qfileinfo.cpp \ + ../../corelib/io/qfilesystementry.cpp \ ../../corelib/io/qfsfileengine.cpp \ ../../corelib/io/qfsfileengine_iterator.cpp \ ../../corelib/io/qiodevice.cpp \ @@ -83,10 +84,12 @@ SOURCES += \ ../../xml/dom/qdom.cpp \ ../../xml/sax/qxml.cpp -unix:SOURCES += ../../corelib/io/qfsfileengine_unix.cpp \ +unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \ + ../../corelib/io/qfsfileengine_unix.cpp \ ../../corelib/io/qfsfileengine_iterator_unix.cpp -win32:SOURCES += ../../corelib/io/qfsfileengine_win.cpp \ +win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ + ../../corelib/io/qfsfileengine_win.cpp \ ../../corelib/io/qfsfileengine_iterator_win.cpp macx: { diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index 73f3317..9e52f81 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -48,6 +48,9 @@ HEADERS = configureapp.h environment.h tools.h\ $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.h \ $$QT_SOURCE_TREE/src/corelib/io/qfile.h \ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.h \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry_p.h \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_p.h \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemmetadata_p.h \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.h \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_p.h \ $$QT_SOURCE_TREE/src/corelib/io/qiodevice.h \ @@ -86,7 +89,10 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfile.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qiodevice.cpp \ @@ -114,8 +120,6 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.cpp \ $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp -win32:SOURCES += $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp - DEFINES += COMMERCIAL_VERSION INCLUDEPATH += $$QT_SOURCE_TREE/src/corelib/arch/generic \ diff --git a/tools/qtestlib/wince/cetest/bootstrapped.pri b/tools/qtestlib/wince/cetest/bootstrapped.pri index b9c4b2b..0af5c94 100644 --- a/tools/qtestlib/wince/cetest/bootstrapped.pri +++ b/tools/qtestlib/wince/cetest/bootstrapped.pri @@ -4,6 +4,8 @@ SOURCES += \ $$QT_SOURCE_TREE/src/corelib/tools/qstringlist.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfile.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qdir.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ -- cgit v0.12 From b56fad9c12615ac135a36a468c020906f383a0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 10:36:30 +0200 Subject: Added missing QT_BEGIN/END_NAMESPACE to implementation files in new QFileSystem* API. --- src/corelib/io/qfilesystemengine_mac.cpp | 4 ++++ src/corelib/io/qfilesystemengine_unix.cpp | 4 ++++ src/corelib/io/qfilesystemengine_win.cpp | 4 ++++ src/corelib/io/qfilesystementry.cpp | 7 ++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_mac.cpp b/src/corelib/io/qfilesystemengine_mac.cpp index ac71f0e..942415c 100644 --- a/src/corelib/io/qfilesystemengine_mac.cpp +++ b/src/corelib/io/qfilesystemengine_mac.cpp @@ -41,6 +41,8 @@ #include "qfilesystemengine_p.h" +QT_BEGIN_NAMESPACE + bool QFileSystemEngine::isCaseSensitive() { return true; @@ -117,3 +119,5 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per { return false; // TODO implement; } + +QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index bcd75fc..2274e69 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -42,6 +42,8 @@ #include "qfilesystemengine_p.h" #include "qfsfileengine.h" +QT_BEGIN_NAMESPACE + bool QFileSystemEngine::isCaseSensitive() { return true; @@ -145,3 +147,5 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per { return false; // TODO implement; } + +QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index ac71f0e..942415c 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -41,6 +41,8 @@ #include "qfilesystemengine_p.h" +QT_BEGIN_NAMESPACE + bool QFileSystemEngine::isCaseSensitive() { return true; @@ -117,3 +119,5 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per { return false; // TODO implement; } + +QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index bed5435..5858ab3 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -40,7 +40,10 @@ ****************************************************************************/ #include "qfilesystementry_p.h" -#include "qdir.h" + +#include + +QT_BEGIN_NAMESPACE QFileSystemEntry::QFileSystemEntry(const QString &filePath) : m_filePath(filePath), @@ -195,3 +198,5 @@ void QFileSystemEntry::findFileNameSeparators() const m_lastDotInFileName = firstDotInFileName - lastSeparator; } } + +QT_END_NAMESPACE -- cgit v0.12 From 5dfcf2c6778e6852b3d1a2f9c6cc4c9e7c8a5d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 11:36:05 +0200 Subject: Small changes to QFileSystemEntry * Added default constructor. * Made single-argument constructors explicit * Converted bit-field data to "proper" variables - the bit-fields may have been premature optimization and it may even turn out to not relevant to keep this cache. Reviewed-by: Thomas Zander --- src/corelib/io/qfilesystementry.cpp | 7 +++++++ src/corelib/io/qfilesystementry_p.h | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 5858ab3..04ad388 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -45,6 +45,13 @@ QT_BEGIN_NAMESPACE +QFileSystemEntry::QFileSystemEntry() + : m_lastSeparator(0), + m_firstDotInFileName(0), + m_lastDotInFileName(0) +{ +} + QFileSystemEntry::QFileSystemEntry(const QString &filePath) : m_filePath(filePath), m_lastSeparator(-2), diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 68af24d..ae2071a 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -61,8 +61,9 @@ QT_BEGIN_NAMESPACE class QFileSystemEntry { public: - QFileSystemEntry(const QString &filePath); - QFileSystemEntry(const QByteArray &nativeFilePath); + QFileSystemEntry(); + explicit QFileSystemEntry(const QString &filePath); + explicit QFileSystemEntry(const QByteArray &nativeFilePath); QFileSystemEntry(const QByteArray &nativeFilePath, const QString &filePath); QString filePath() const; @@ -88,9 +89,9 @@ private: mutable QString m_filePath; // always has slashes as separator mutable QByteArray m_nativeFilePath; // native encoding and separators - mutable int m_lastSeparator : 16; // index in m_filePath of last separator - mutable int m_firstDotInFileName : 11; // index after m_filePath for first dot (.) - mutable int m_lastDotInFileName : 5; // index after m_firstDotInFileName for last dot (.) + mutable qint16 m_lastSeparator; // index in m_filePath of last separator + mutable qint16 m_firstDotInFileName; // index after m_filePath for first dot (.) + mutable qint16 m_lastDotInFileName; // index after m_firstDotInFileName for last dot (.) }; QT_END_NAMESPACE -- cgit v0.12 From 1d52b8a0643dca077de432d841df5f49f472352a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 12:02:39 +0200 Subject: Removed native file path handling from QFSFileEngine Moved it into QFileSystemEntry, instead. For the time being, QFileSystemEntry may look like an unnecessary extra layer of indirection. For the time being, this allows us to do some code cleanup and de-duplication. It is also a stepping stone to becoming completely independent of the current file engine abstraction. Changes to QFileSystemEntry: - native file path on Windows is now a QString, instead of a QByteArray. Accordingly, constructors taking a QByteArray were removed for these platforms. - Encoding/decoding of file names uses QFile::encode/decodeName API, instead of assuming local 8 bit. On Windows, UTF-16 is used for native, as was being done in QFSFileEngine. - new functions isRoot(), isDriveRoot() [Windows/Symbian], and path() - convenience functions clear() and isEmpty() added to facilitate porting. Changes to QFSFileEngine (Windows): - removed QFSFileEnginePrivate::sizeFdFh(): the function was broken and never used, so might as well not get compiled in. - repeated pattern for use of FindFirstFile/FindClose hidden away in a static inline function. - repeated and inconsistent conversions from QString to native file paths reduced through the use of QFileSystemEntry. Done-with: Prasanth Ullattil Done-with: Thomas Zander --- src/corelib/io/qfilesystementry.cpp | 107 ++++++++++++- src/corelib/io/qfilesystementry_p.h | 23 +++ src/corelib/io/qfsfileengine.cpp | 23 ++- src/corelib/io/qfsfileengine_p.h | 7 +- src/corelib/io/qfsfileengine_unix.cpp | 158 ++++++++----------- src/corelib/io/qfsfileengine_win.cpp | 283 +++++++++++----------------------- src/corelib/io/qtemporaryfile.cpp | 19 +-- 7 files changed, 302 insertions(+), 318 deletions(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 04ad388..a32e22f 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -42,9 +42,38 @@ #include "qfilesystementry_p.h" #include +#include +#include +#ifdef Q_OS_WIN +#include +#endif QT_BEGIN_NAMESPACE +#ifdef Q_OS_WIN +static bool isUncRoot(const QString &server) +{ + QString localPath = QDir::toNativeSeparators(server); + if (!localPath.startsWith(QLatin1String("\\\\"))) + return false; + + int idx = localPath.indexOf(QLatin1Char('\\'), 2); + if (idx == -1 || idx + 1 == localPath.length()) + return true; + + localPath = localPath.right(localPath.length() - idx - 1).trimmed(); + return localPath.isEmpty(); +} + +static inline QString fixIfRelativeUncPath(const QString &path) +{ + QString currentPath = QDir::currentPath(); + if (currentPath.startsWith(QLatin1String("//"))) + return currentPath % QChar(QLatin1Char('/')) % path; + return path; +} +#endif + QFileSystemEntry::QFileSystemEntry() : m_lastSeparator(0), m_firstDotInFileName(0), @@ -60,6 +89,7 @@ QFileSystemEntry::QFileSystemEntry(const QString &filePath) { } +#ifndef Q_OS_WIN QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath) : m_nativeFilePath(nativeFilePath), m_lastSeparator(-2), @@ -76,6 +106,7 @@ QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath, const QStri m_lastDotInFileName(0) { } +#endif QString QFileSystemEntry::filePath() const { @@ -83,7 +114,11 @@ QString QFileSystemEntry::filePath() const return m_filePath; } +#ifndef Q_OS_WIN QByteArray QFileSystemEntry::nativeFilePath() const +#else +QString QFileSystemEntry::nativeFilePath() const +#endif { resolveNativeFilePath(); return m_nativeFilePath; @@ -92,23 +127,59 @@ QByteArray QFileSystemEntry::nativeFilePath() const void QFileSystemEntry::resolveFilePath() const { if (m_filePath.isEmpty() && !m_nativeFilePath.isEmpty()) { - m_filePath = QDir::fromNativeSeparators(QString::fromLocal8Bit(m_nativeFilePath)); +#ifdef Q_OS_WIN + m_filePath = QDir::fromNativeSeparators(m_nativeFilePath); +#else + m_filePath = QDir::fromNativeSeparators(QFile::decodeName(m_nativeFilePath)); +#endif } } void QFileSystemEntry::resolveNativeFilePath() const { if (!m_filePath.isEmpty() && m_nativeFilePath.isEmpty()) { - m_nativeFilePath = QDir::toNativeSeparators(m_filePath).toLocal8Bit(); +#ifdef Q_OS_WIN + QString filePath = m_filePath; + if (isRelative()) + filePath = fixIfRelativeUncPath(m_filePath); + m_nativeFilePath = QFSFileEnginePrivate::longFileName(QDir::toNativeSeparators(filePath)); +#else + m_nativeFilePath = QFile::encodeName(QDir::toNativeSeparators(m_filePath)); +#endif } } QString QFileSystemEntry::fileName() const { findLastSeparator(); +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + if (m_lastSeparator == -1) { + if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + return m_filePath.mid(2); + } +#endif return m_filePath.mid(m_lastSeparator + 1); } +QString QFileSystemEntry::path() const +{ + findLastSeparator(); + if (m_lastSeparator == -1) { +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + return m_filePath.left(2); +#endif + return QString(QLatin1Char('.')); + } + if (m_lastSeparator == 0) + return QString(QLatin1Char('/')); +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + if (m_lastSeparator == 2 && m_filePath.at(1) == QLatin1Char(':')) + return m_filePath.left(m_lastSeparator + 1); +#endif + return m_filePath.left(m_lastSeparator); +} + QString QFileSystemEntry::suffix() const { findFileNameSeparators(); @@ -141,6 +212,38 @@ bool QFileSystemEntry::isAbsolute() const } +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) +bool QFileSystemEntry::isDriveRoot() const +{ + resolveFilePath(); + return (m_filePath.length() == 3 + && m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':') + && m_filePath.at(2) == QLatin1Char('/')); +} +#endif + +bool QFileSystemEntry::isRoot() const +{ + resolveFilePath(); + if (m_filePath == QLatin1String("/") +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + || isDriveRoot() +#if defined(Q_OS_WIN) + || isUncRoot(m_filePath) +#endif +#endif + ) + return true; + + return false; +} + +bool QFileSystemEntry::isEmpty() const +{ + resolveNativeFilePath(); + return m_nativeFilePath.isEmpty(); +} + // private methods void QFileSystemEntry::findLastSeparator() const diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index ae2071a..3e49f2c 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -63,12 +63,19 @@ class QFileSystemEntry public: QFileSystemEntry(); explicit QFileSystemEntry(const QString &filePath); +#ifndef Q_OS_WIN explicit QFileSystemEntry(const QByteArray &nativeFilePath); QFileSystemEntry(const QByteArray &nativeFilePath, const QString &filePath); +#endif QString filePath() const; QString fileName() const; + QString path() const; +#ifndef Q_OS_WIN QByteArray nativeFilePath() const; +#else + QString nativeFilePath() const; +#endif QString suffix() const; QString completeSuffix() const; bool isAbsolute() const; @@ -76,6 +83,17 @@ public: return !isAbsolute(); } +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + bool isDriveRoot() const; +#endif + bool isRoot() const; + + bool isEmpty() const; + void clear() + { + *this = QFileSystemEntry(); + } + private: // creates the QString version out of the bytearray version void resolveFilePath() const; @@ -87,7 +105,12 @@ private: void findFileNameSeparators() const; mutable QString m_filePath; // always has slashes as separator + +#ifdef Q_OS_WIN + mutable QString m_nativeFilePath; // native encoding and separators +#else mutable QByteArray m_nativeFilePath; // native encoding and separators +#endif mutable qint16 m_lastSeparator; // index in m_filePath of last separator mutable qint16 m_firstDotInFileName; // index after m_filePath for first dot (.) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 511a1a6..75f82a6 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -239,11 +239,11 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) /*! Constructs a QFSFileEngine for the file name \a file. */ -QFSFileEngine::QFSFileEngine(const QString &file) : QAbstractFileEngine(*new QFSFileEnginePrivate) +QFSFileEngine::QFSFileEngine(const QString &file) + : QAbstractFileEngine(*new QFSFileEnginePrivate) { Q_D(QFSFileEngine); - d->filePath = QDir::fromNativeSeparators(file); - d->nativeInitFileName(); + d->fileEntry = QFileSystemEntry(QDir::fromNativeSeparators(file)); } /*! @@ -292,8 +292,7 @@ void QFSFileEngine::setFileName(const QString &file) { Q_D(QFSFileEngine); d->init(); - d->filePath = QDir::fromNativeSeparators(file); - d->nativeInitFileName(); + d->fileEntry = QFileSystemEntry(QDir::fromNativeSeparators(file)); } /*! @@ -302,7 +301,7 @@ void QFSFileEngine::setFileName(const QString &file) bool QFSFileEngine::open(QIODevice::OpenMode openMode) { Q_D(QFSFileEngine); - if (d->filePath.isEmpty()) { + if (d->fileEntry.isEmpty()) { qWarning("QFSFileEngine::open: No file name specified"); setError(QFile::OpenError, QLatin1String("No file name specified")); return false; @@ -344,8 +343,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh) d->openMode = openMode; d->lastFlushFailed = false; d->closeFileHandle = false; - d->nativeFilePath.clear(); - d->filePath.clear(); + d->fileEntry.clear(); d->tried_stat = 0; d->fd = -1; @@ -401,8 +399,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd) d->openMode = openMode; d->lastFlushFailed = false; d->closeFileHandle = false; - d->nativeFilePath.clear(); - d->filePath.clear(); + d->fileEntry.clear(); d->fh = 0; d->fd = -1; d->tried_stat = 0; @@ -549,6 +546,7 @@ qint64 QFSFileEngine::size() const /*! \internal */ +#ifndef Q_OS_WIN qint64 QFSFileEnginePrivate::sizeFdFh() const { Q_Q(const QFSFileEngine); @@ -556,13 +554,13 @@ qint64 QFSFileEnginePrivate::sizeFdFh() const QT_STATBUF st; int ret = 0; const_cast(q)->flush(); - if (fh && nativeFilePath.isEmpty()) { + if (fh && fileEntry.isEmpty()) { // Buffered stdlib mode. // ### This should really be an ftell ret = QT_FSTAT(QT_FILENO(fh), &st); } else if (fd == -1) { // Stateless stat. - ret = QT_STAT(nativeFilePath.constData(), &st); + ret = QT_STAT(fileEntry.nativeFilePath().constData(), &st); } else { // Unbuffered stdio mode. ret = QT_FSTAT(fd, &st); @@ -571,6 +569,7 @@ qint64 QFSFileEnginePrivate::sizeFdFh() const return 0; return st.st_size; } +#endif /*! \reimp diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index e9e55f3..74cbca3 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -56,6 +56,7 @@ #include "qplatformdefs.h" #include "QtCore/qfsfileengine.h" #include "private/qabstractfileengine_p.h" +#include "private/qfilesystementry_p.h" #include #ifndef QT_NO_FSFILEENGINE @@ -76,11 +77,9 @@ public: #endif static QString canonicalized(const QString &path); - QString filePath; - QByteArray nativeFilePath; + QFileSystemEntry fileEntry; QIODevice::OpenMode openMode; - void nativeInitFileName(); bool nativeOpen(QIODevice::OpenMode openMode); bool openFh(QIODevice::OpenMode flags, FILE *fh); bool openFd(QIODevice::OpenMode flags, int fd); @@ -89,7 +88,9 @@ public: bool nativeFlush(); bool flushFh(); qint64 nativeSize() const; +#ifndef Q_OS_WIN qint64 sizeFdFh() const; +#endif qint64 nativePos() const; qint64 posFdFh() const; bool nativeSeek(qint64); diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 5fecb5d..3daf7f6 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -200,14 +200,6 @@ static inline bool setCloseOnExec(int fd) /*! \internal */ -void QFSFileEnginePrivate::nativeInitFileName() -{ - nativeFilePath = QFile::encodeName(filePath); -} - -/*! - \internal -*/ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) { Q_Q(QFSFileEngine); @@ -217,7 +209,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) // Try to open the file in unbuffered mode. do { - fd = QT_OPEN(nativeFilePath.constData(), flags, 0666); + fd = QT_OPEN(fileEntry.nativeFilePath().constData(), flags, 0666); } while (fd == -1 && errno == EINTR); // On failure, return and report the error. @@ -256,11 +248,11 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) fh = 0; } else { - QByteArray fopenMode = openModeToFopenMode(openMode, nativeFilePath.constData()); + QByteArray fopenMode = openModeToFopenMode(openMode, fileEntry.nativeFilePath().constData()); // Try to open the file in buffered mode. do { - fh = QT_FOPEN(nativeFilePath.constData(), fopenMode.constData()); + fh = QT_FOPEN(fileEntry.nativeFilePath().constData(), fopenMode.constData()); } while (!fh && errno == EINTR); // On failure, return and report the error. @@ -435,7 +427,7 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - bool ret = unlink(d->nativeFilePath.constData()) == 0; + bool ret = unlink(d->fileEntry.nativeFilePath().constData()) == 0; if (!ret) setError(QFile::RemoveError, qt_error_string(errno)); return ret; @@ -447,7 +439,7 @@ bool QFSFileEngine::copy(const QString &newName) Q_D(QFSFileEngine); RFs rfs = qt_s60GetRFs(); CFileMan* fm = NULL; - QString oldNative(QDir::toNativeSeparators(d->filePath)); + QString oldNative(QDir::toNativeSeparators(d->fileEntry.filePath())); TPtrC oldPtr(qt_QString2TPtrC(oldNative)); QFileInfo fi(newName); QString absoluteNewName = fi.absoluteFilePath(); @@ -478,7 +470,7 @@ bool QFSFileEngine::copy(const QString &newName) bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - bool ret = ::rename(d->nativeFilePath.constData(), QFile::encodeName(newName).constData()) == 0; + bool ret = ::rename(d->fileEntry.nativeFilePath().constData(), QFile::encodeName(newName).constData()) == 0; if (!ret) setError(QFile::RenameError, qt_error_string(errno)); return ret; @@ -487,7 +479,7 @@ bool QFSFileEngine::rename(const QString &newName) bool QFSFileEngine::link(const QString &newName) { Q_D(QFSFileEngine); - bool ret = ::symlink(d->nativeFilePath.constData(), QFile::encodeName(newName).constData()) == 0; + bool ret = ::symlink(d->fileEntry.nativeFilePath().constData(), QFile::encodeName(newName).constData()) == 0; if (!ret) setError(QFile::RenameError, qt_error_string(errno)); return ret; @@ -691,7 +683,7 @@ bool QFSFileEnginePrivate::doStat() const tried_stat = true; could_stat = false; - if (fh && nativeFilePath.isEmpty()) { + if (fh && fileEntry.isEmpty()) { // ### actually covers two cases: d->fh and when the file is not open could_stat = (QT_FSTAT(QT_FILENO(fh), &st) == 0); } else if (fd == -1) { @@ -701,12 +693,12 @@ bool QFSFileEnginePrivate::doStat() const // When the filename is not a link, lstat will return the same info as stat, but this also removes // any need for a further call to lstat to check if the file is a link. need_lstat = false; - could_stat = (QT_LSTAT(nativeFilePath.constData(), &st) == 0); + could_stat = (QT_LSTAT(fileEntry.nativeFilePath().constData(), &st) == 0); is_link = could_stat ? S_ISLNK(st.st_mode) : false; // if it turns out this was a link, we can call stat too. if (is_link) #endif - could_stat = (QT_STAT(nativeFilePath.constData(), &st) == 0); + could_stat = (QT_STAT(fileEntry.nativeFilePath().constData(), &st) == 0); } else { could_stat = (QT_FSTAT(fd, &st) == 0); } @@ -720,7 +712,7 @@ bool QFSFileEnginePrivate::isSymlink() const need_lstat = false; QT_STATBUF st; // don't clobber our main one - is_link = (QT_LSTAT(nativeFilePath.constData(), &st) == 0) ? S_ISLNK(st.st_mode) : false; + is_link = (QT_LSTAT(fileEntry.nativeFilePath().constData(), &st) == 0) ? S_ISLNK(st.st_mode) : false; } return is_link; } @@ -789,15 +781,15 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFil // calculate user permissions if (type & QAbstractFileEngine::ReadUserPerm) { - if (QT_ACCESS(nativeFilePath.constData(), R_OK) == 0) + if (QT_ACCESS(fileEntry.nativeFilePath().constData(), R_OK) == 0) ret |= QAbstractFileEngine::ReadUserPerm; } if (type & QAbstractFileEngine::WriteUserPerm) { - if (QT_ACCESS(nativeFilePath.constData(), W_OK) == 0) + if (QT_ACCESS(fileEntry.nativeFilePath().constData(), W_OK) == 0) ret |= QAbstractFileEngine::WriteUserPerm; } if (type & QAbstractFileEngine::ExeUserPerm) { - if (QT_ACCESS(nativeFilePath.constData(), X_OK) == 0) + if (QT_ACCESS(fileEntry.nativeFilePath().constData(), X_OK) == 0) ret |= QAbstractFileEngine::ExeUserPerm; } @@ -830,7 +822,7 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const bool foundAlias = false; { FSRef fref; - if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(), + if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->fileEntry.filePath())).data(), &fref, NULL) == noErr) { Boolean isAlias, isFolder; if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr && isAlias) { @@ -850,7 +842,7 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const ret |= DirectoryType; #if !defined(QWS) && defined(Q_OS_MAC) if ((ret & DirectoryType) && (type & BundleType)) { - QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath), + QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(d->fileEntry.filePath()), kCFURLPOSIXPathStyle, true); UInt32 type, creator; if (CFBundleGetPackageInfoInDirectory(url, &type, &creator)) @@ -862,35 +854,29 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const if (type & FlagsMask) { if (exists) ret |= ExistsFlag; -#if defined(Q_OS_SYMBIAN) - if (d->filePath == QLatin1String("/") - || (d->filePath.length() == 3 && d->filePath.at(0).isLetter() - && d->filePath.at(1) == QLatin1Char(':') && d->filePath.at(2) == QLatin1Char('/'))) { + if (d->fileEntry.isRoot()) { ret |= RootFlag; } else { +#if defined(Q_OS_SYMBIAN) // In Symbian, all symlinks have hidden attribute for some reason; // lets make them visible for better compatibility with other platforms. // If somebody actually wants a hidden link, then they are out of luck. - if (!d->isSymlink() && _q_isSymbianHidden(d->filePath, ret & DirectoryType)) + if (!d->isSymlink() && _q_isSymbianHidden(d->fileEntry.filePath(), ret & DirectoryType)) ret |= HiddenFlag; - } #else - if (d->filePath == QLatin1String("/")) { - ret |= RootFlag; - } else { QString baseName = fileName(BaseName); if ((baseName.size() > 0 && baseName.at(0) == QLatin1Char('.')) # if !defined(QWS) && defined(Q_OS_MAC) - || _q_isMacHidden(d->filePath) + || _q_isMacHidden(d->fileEntry.filePath()) # if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - || d->st.st_flags & UF_HIDDEN + || d->st.st_flags & UF_HIDDEN # endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 # endif ) { ret |= HiddenFlag; } - } #endif + } } return ret; } @@ -901,50 +887,50 @@ QString QFSFileEngine::fileName(FileName file) const Q_D(const QFSFileEngine); const QLatin1Char slashChar('/'); if(file == BaseName) { - int slash = d->filePath.lastIndexOf(slashChar); + int slash = d->fileEntry.filePath().lastIndexOf(slashChar); if(slash == -1) { - int colon = d->filePath.lastIndexOf(QLatin1Char(':')); + int colon = d->fileEntry.filePath().lastIndexOf(QLatin1Char(':')); if(colon != -1) - return d->filePath.mid(colon + 1); - return d->filePath; + return d->fileEntry.filePath().mid(colon + 1); + return d->fileEntry.filePath(); } - return d->filePath.mid(slash + 1); + return d->fileEntry.filePath().mid(slash + 1); } else if(file == PathName) { - if(!d->filePath.size()) - return d->filePath; + if(!d->fileEntry.filePath().size()) + return d->fileEntry.filePath(); - int slash = d->filePath.lastIndexOf(slashChar); + int slash = d->fileEntry.filePath().lastIndexOf(slashChar); if(slash == -1) { - if(d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':')) - return d->filePath.left(2); + if(d->fileEntry.filePath().length() >= 2 && d->fileEntry.filePath().at(1) == QLatin1Char(':')) + return d->fileEntry.filePath().left(2); return QLatin1String("."); } else { if(!slash) return QLatin1String("/"); - if(slash == 2 && d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':')) + if(slash == 2 && d->fileEntry.filePath().length() >= 2 && d->fileEntry.filePath().at(1) == QLatin1Char(':')) slash++; - return d->filePath.left(slash); + return d->fileEntry.filePath().left(slash); } } else if(file == AbsoluteName || file == AbsolutePathName) { QString ret; - if (!isRelativePathSymbian(d->filePath)) { - if (d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':') - && d->filePath.at(2) != slashChar){ + if (!isRelativePathSymbian(d->fileEntry.filePath())) { + if (d->fileEntry.filePath().size() > 2 && d->fileEntry.filePath().at(1) == QLatin1Char(':') + && d->fileEntry.filePath().at(2) != slashChar){ // It's a drive-relative path, so C:a.txt -> C:/currentpath/a.txt, // or if it's different drive than current, Z:a.txt -> Z:/a.txt QString currentPath = QDir::currentPath(); - if (0 == currentPath.left(1).compare(d->filePath.left(1), Qt::CaseInsensitive)) - ret = currentPath + slashChar + d->filePath.mid(2); + if (0 == currentPath.left(1).compare(d->fileEntry.filePath().left(1), Qt::CaseInsensitive)) + ret = currentPath + slashChar + d->fileEntry.filePath().mid(2); else - ret = d->filePath.left(2) + slashChar + d->filePath.mid(2); - } else if (d->filePath.startsWith(slashChar)) { + ret = d->fileEntry.filePath().left(2) + slashChar + d->fileEntry.filePath().mid(2); + } else if (d->fileEntry.filePath().startsWith(slashChar)) { // It's a absolute path to the current drive, so /a.txt -> C:/a.txt - ret = QDir::currentPath().left(2) + d->filePath; + ret = QDir::currentPath().left(2) + d->fileEntry.filePath(); } else { - ret = d->filePath; + ret = d->fileEntry.filePath(); } } else { - ret = QDir::currentPath() + slashChar + d->filePath; + ret = QDir::currentPath() + slashChar + d->fileEntry.filePath(); } // The path should be absolute at this point. @@ -993,14 +979,14 @@ QString QFSFileEngine::fileName(FileName file) const } else if(file == LinkName) { if (d->isSymlink()) { char s[PATH_MAX+1]; - int len = readlink(d->nativeFilePath.constData(), s, PATH_MAX); + int len = readlink(d->fileEntry.nativeFilePath().constData(), s, PATH_MAX); if (len > 0) { s[len] = '\0'; QString ret = QFile::decodeName(QByteArray(s)); if (isRelativePathSymbian(ret)) { - if (!isRelativePathSymbian(d->filePath)) { - ret.prepend(d->filePath.left(d->filePath.lastIndexOf(slashChar)) + if (!isRelativePathSymbian(d->fileEntry.filePath())) { + ret.prepend(d->fileEntry.filePath().left(d->fileEntry.filePath().lastIndexOf(slashChar)) + slashChar); } else { ret.prepend(QDir::currentPath() + slashChar); @@ -1016,7 +1002,7 @@ QString QFSFileEngine::fileName(FileName file) const } else if(file == BundleName) { return QString(); } - return d->filePath; + return d->fileEntry.filePath(); } #else @@ -1026,7 +1012,7 @@ QString QFSFileEngine::fileName(FileName file) const Q_D(const QFSFileEngine); if (file == BundleName) { #if !defined(QWS) && defined(Q_OS_MAC) - QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(d->filePath), + QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(d->fileEntry.filePath()), kCFURLPOSIXPathStyle, true); if (QCFType dict = CFBundleCopyInfoDictionaryForURL(url)) { if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) { @@ -1037,29 +1023,15 @@ QString QFSFileEngine::fileName(FileName file) const #endif return QString(); } else if (file == BaseName) { - int slash = d->filePath.lastIndexOf(QLatin1Char('/')); - if (slash != -1) - return d->filePath.mid(slash + 1); + return d->fileEntry.fileName(); } else if (file == PathName) { - int slash = d->filePath.lastIndexOf(QLatin1Char('/')); - if (slash == -1) - return QLatin1String("."); - else if (!slash) - return QLatin1String("/"); - return d->filePath.left(slash); + return d->fileEntry.path(); } else if (file == AbsoluteName || file == AbsolutePathName) { - QFileSystemEntry entry(d->filePath); - entry = QFileSystemEngine::absoluteName(entry); - QString ret = entry.filePath(); + QFileSystemEntry entry = QFileSystemEngine::absoluteName(d->fileEntry); if (file == AbsolutePathName) { - int slash = ret.lastIndexOf(QLatin1Char('/')); - if (slash == -1) - return QDir::currentPath(); - else if (!slash) - return QLatin1String("/"); - return ret.left(slash); + return entry.path(); } - return ret; + return entry.filePath(); } else if (file == CanonicalName || file == CanonicalPathName) { if (!(fileFlags(ExistsFlag) & ExistsFlag)) return QString(); @@ -1085,7 +1057,7 @@ QString QFSFileEngine::fileName(FileName file) const while (1) { s = (char *) ::realloc(s, size); Q_CHECK_PTR(s); - len = ::readlink(d->nativeFilePath.constData(), s, size); + len = ::readlink(d->fileEntry.nativeFilePath().constData(), s, size); if (len < 0) { ::free(s); break; @@ -1097,12 +1069,12 @@ QString QFSFileEngine::fileName(FileName file) const } #else char s[PATH_MAX+1]; - int len = readlink(d->nativeFilePath.constData(), s, PATH_MAX); + int len = readlink(d->fileEntry.nativeFilePath().constData(), s, PATH_MAX); #endif if (len > 0) { QString ret; if (d->doStat() && S_ISDIR(d->st.st_mode) && s[0] != '/') { - QDir parent(d->filePath); + QDir parent(d->fileEntry.filePath()); parent.cdUp(); ret = parent.path(); if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) @@ -1115,8 +1087,8 @@ QString QFSFileEngine::fileName(FileName file) const #endif if (!ret.startsWith(QLatin1Char('/'))) { - if (d->filePath.startsWith(QLatin1Char('/'))) { - ret.prepend(d->filePath.left(d->filePath.lastIndexOf(QLatin1Char('/'))) + if (d->fileEntry.filePath().startsWith(QLatin1Char('/'))) { + ret.prepend(d->fileEntry.filePath().left(d->fileEntry.filePath().lastIndexOf(QLatin1Char('/'))) + QLatin1Char('/')); } else { ret.prepend(QDir::currentPath() + QLatin1Char('/')); @@ -1131,7 +1103,7 @@ QString QFSFileEngine::fileName(FileName file) const #if !defined(QWS) && defined(Q_OS_MAC) { FSRef fref; - if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->filePath)).data(), &fref, 0) == noErr) { + if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->fileEntry.filePath())).data(), &fref, 0) == noErr) { Boolean isAlias, isFolder; if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) { AliasHandle alias; @@ -1146,7 +1118,7 @@ QString QFSFileEngine::fileName(FileName file) const #endif return QString(); } - return d->filePath; + return d->fileEntry.filePath(); } #endif // Q_OS_SYMBIAN @@ -1154,9 +1126,9 @@ bool QFSFileEngine::isRelativePath() const { Q_D(const QFSFileEngine); #if defined(Q_OS_SYMBIAN) - return isRelativePathSymbian(d->filePath); + return isRelativePathSymbian(d->fileEntry.filePath()); #else - return d->filePath.length() ? d->filePath[0] != QLatin1Char('/') : true; + return d->fileEntry.filePath().length() ? d->fileEntry.filePath()[0] != QLatin1Char('/') : true; #endif } @@ -1253,7 +1225,7 @@ bool QFSFileEngine::setPermissions(uint perms) if (d->fd != -1) ret = fchmod(d->fd, mode) == 0; else - ret = ::chmod(d->nativeFilePath.constData(), mode) == 0; + ret = ::chmod(d->fileEntry.nativeFilePath().constData(), mode) == 0; if (!ret) setError(QFile::PermissionsError, qt_error_string(errno)); return ret; @@ -1268,7 +1240,7 @@ bool QFSFileEngine::setSize(qint64 size) else if (d->fh) ret = QT_FTRUNCATE(QT_FILENO(d->fh), size) == 0; else - ret = QT_TRUNCATE(d->nativeFilePath.constData(), size) == 0; + ret = QT_TRUNCATE(d->fileEntry.nativeFilePath().constData(), size) == 0; if (!ret) setError(QFile::ResizeError, qt_error_string(errno)); return ret; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 84120b4..6f81652 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -128,7 +128,7 @@ typedef struct _REPARSE_DATA_BUFFER { QT_BEGIN_NAMESPACE -static QString readLink(const QString &link); +static QString readLink(const QFileSystemEntry &link); Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0; @@ -279,20 +279,6 @@ bool QFSFileEnginePrivate::uncListSharesOnServer(const QString &server, QStringL return false; } -static bool isUncRoot(const QString &server) -{ - QString localPath = QDir::toNativeSeparators(server); - if (!localPath.startsWith(QLatin1String("\\\\"))) - return false; - - int idx = localPath.indexOf(QLatin1Char('\\'), 2); - if (idx == -1 || idx + 1 == localPath.length()) - return true; - - localPath = localPath.right(localPath.length() - idx - 1).trimmed(); - return localPath.isEmpty(); -} - #if !defined(Q_OS_WINCE) static inline bool isUncPath(const QString &path) { @@ -302,25 +288,6 @@ static inline bool isUncPath(const QString &path) } #endif -static inline bool isRelativePath(const QString &path) -{ - // drive, e.g. "a:", or UNC root, e.q. "//" - return !(path.startsWith(QLatin1Char('/')) - || (path.length() >= 2 - && ((path.at(0).isLetter() && path.at(1) == QLatin1Char(':')) - || (path.at(0) == QLatin1Char('/') && path.at(1) == QLatin1Char('/'))))); -} - -static QString fixIfRelativeUncPath(const QString &path) -{ - if (isRelativePath(path)) { - QString currentPath = QDir::currentPath() + QLatin1Char('/'); - if (currentPath.startsWith(QLatin1String("//"))) - return QString(path).prepend(currentPath); - } - return path; -} - // can be //server or //server/share static bool uncShareExists(const QString &server) { @@ -333,13 +300,6 @@ static bool uncShareExists(const QString &server) return false; } -static inline bool isDriveRoot(const QString &path) -{ - return (path.length() == 3 - && path.at(0).isLetter() && path.at(1) == QLatin1Char(':') - && path.at(2) == QLatin1Char('/')); -} - static QString nativeAbsoluteFilePath(const QString &path) { QString absPath; @@ -390,13 +350,22 @@ QString QFSFileEnginePrivate::longFileName(const QString &path) #endif } -/* - \internal -*/ -void QFSFileEnginePrivate::nativeInitFileName() +static inline bool getFindData(QString path, WIN32_FIND_DATA &findData) { - QString path = longFileName(QDir::toNativeSeparators(fixIfRelativeUncPath(filePath))); - nativeFilePath = QByteArray((const char *)path.utf16(), path.size() * 2 + 1); + // path should not end with a trailing slash + while (path.endsWith(QLatin1Char('\\'))) + path.chop(1); + + // can't handle drives + if (!path.endsWith(QLatin1Char(':'))) { + HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData); + if (hFind != INVALID_HANDLE_VALUE) { + ::FindClose(hFind); + return true; + } + } + + return false; } /* @@ -421,7 +390,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) DWORD creationDisp = (openMode & QIODevice::WriteOnly) ? OPEN_ALWAYS : OPEN_EXISTING; // Create the file handle. - fileHandle = CreateFile((const wchar_t*)nativeFilePath.constData(), + fileHandle = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(), accessRights, shareMode, &securityAtts, @@ -538,31 +507,18 @@ qint64 QFSFileEnginePrivate::nativeSize() const // Not-open mode, where the file name is known: We'll check the // file system directly. - if (openMode == QIODevice::NotOpen && !nativeFilePath.isEmpty()) { + if (openMode == QIODevice::NotOpen && !fileEntry.isEmpty()) { WIN32_FILE_ATTRIBUTE_DATA attribData; - bool ok = ::GetFileAttributesEx((const wchar_t*)nativeFilePath.constData(), + bool ok = ::GetFileAttributesEx((const wchar_t*)fileEntry.nativeFilePath().utf16(), GetFileExInfoStandard, &attribData); if (!ok) { int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { - QByteArray path = nativeFilePath; - // path for the FindFirstFile should not end with a trailing slash - while (!path.isEmpty() && reinterpret_cast( - path.constData() + path.length())[-1] == '\\') - path.chop(2); - - // FindFirstFile can not handle drives - if (!path.isEmpty() && reinterpret_cast( - path.constData() + path.length())[-1] != ':') { - WIN32_FIND_DATA findData; - HANDLE hFind = ::FindFirstFile((const wchar_t*)path.constData(), - &findData); - if (hFind != INVALID_HANDLE_VALUE) { - ::FindClose(hFind); - ok = true; - attribData.nFileSizeHigh = findData.nFileSizeHigh; - attribData.nFileSizeLow = findData.nFileSizeLow; - } + WIN32_FIND_DATA findData; + if (getFindData(fileEntry.nativeFilePath(), findData)) { + ok = true; + attribData.nFileSizeHigh = findData.nFileSizeHigh; + attribData.nFileSizeLow = findData.nFileSizeLow; } } } @@ -831,7 +787,7 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - bool ret = ::DeleteFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16()) != 0; + bool ret = ::DeleteFile((wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0; if (!ret) setError(QFile::RemoveError, qt_error_string()); return ret; @@ -840,8 +796,10 @@ bool QFSFileEngine::remove() bool QFSFileEngine::copy(const QString ©Name) { Q_D(QFSFileEngine); - bool ret = ::CopyFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), - (wchar_t*)QFSFileEnginePrivate::longFileName(copyName).utf16(), true) != 0; + + QFileSystemEntry target(copyName); + bool ret = ::CopyFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(), + (wchar_t*)target.nativeFilePath().utf16(), true) != 0; if (!ret) setError(QFile::CopyError, qt_error_string()); return ret; @@ -850,8 +808,9 @@ bool QFSFileEngine::copy(const QString ©Name) bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - bool ret = ::MoveFile((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), - (wchar_t*)QFSFileEnginePrivate::longFileName(newName).utf16()) != 0; + QFileSystemEntry target(newName); + bool ret = ::MoveFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(), + (wchar_t*)target.nativeFilePath().utf16()) != 0; if (!ret) setError(QFile::RenameError, qt_error_string()); return ret; @@ -896,20 +855,9 @@ static bool isDirPath(const QString &dirPath, bool *existed) if (fileAttrib == INVALID_FILE_ATTRIBUTES) { int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { - // path for the FindFirstFile should not end with a trailing slash - while (path.endsWith(QLatin1Char('\\'))) - path.chop(1); - - // FindFirstFile can not handle drives - if (!path.endsWith(QLatin1Char(':'))) { - WIN32_FIND_DATA findData; - HANDLE hFind = ::FindFirstFile((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), - &findData); - if (hFind != INVALID_HANDLE_VALUE) { - ::FindClose(hFind); - fileAttrib = findData.dwFileAttributes; - } - } + WIN32_FIND_DATA findData; + if (getFindData(QFSFileEnginePrivate::longFileName(path), findData)) + fileAttrib = findData.dwFileAttributes; } } @@ -1164,19 +1112,17 @@ bool QFSFileEnginePrivate::doStat() const tried_stat = true; could_stat = false; - if (filePath.isEmpty()) + if (fileEntry.isEmpty()) return could_stat; - QString fname; - if(filePath.endsWith(QLatin1String(".lnk"))) { - fname = readLink(filePath); + QFileSystemEntry fname; + if(fileEntry.filePath().endsWith(QLatin1String(".lnk"))) { + fname = QFileSystemEntry(readLink(fileEntry)); if(fname.isEmpty()) return could_stat; } else - fname = filePath; - - fname = fixIfRelativeUncPath(fname); + fname = fileEntry; UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); @@ -1191,48 +1137,37 @@ bool QFSFileEnginePrivate::doStat() const } } #else - DWORD tmpAttributes = GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(fname).utf16()); + DWORD tmpAttributes = GetFileAttributes((wchar_t*)fname.nativeFilePath().utf16()); if (tmpAttributes != -1) { fileAttrib = tmpAttributes; could_stat = true; } #endif } else { - fileAttrib = GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(fname).utf16()); + fileAttrib = GetFileAttributes((wchar_t*)fname.nativeFilePath().utf16()); if (fileAttrib == INVALID_FILE_ATTRIBUTES) { int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { - QString path = QDir::toNativeSeparators(fname); - // path for the FindFirstFile should not end with a trailing slash - while (path.endsWith(QLatin1Char('\\'))) - path.chop(1); - - // FindFirstFile can not handle drives - if (!path.endsWith(QLatin1Char(':'))) { - WIN32_FIND_DATA findData; - HANDLE hFind = ::FindFirstFile((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), - &findData); - if (hFind != INVALID_HANDLE_VALUE) { - ::FindClose(hFind); - fileAttrib = findData.dwFileAttributes; - } + WIN32_FIND_DATA findData; + if (getFindData(fname.nativeFilePath(), findData)) { + fileAttrib = findData.dwFileAttributes; } } } could_stat = fileAttrib != INVALID_FILE_ATTRIBUTES; if (!could_stat) { #if !defined(Q_OS_WINCE) - if (isDriveRoot(fname)) { + if (fname.isDriveRoot()) { // a valid drive ?? DWORD drivesBitmask = ::GetLogicalDrives(); - int drivebit = 1 << (fname.at(0).toUpper().unicode() - QLatin1Char('A').unicode()); + int drivebit = 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode()); if (drivesBitmask & drivebit) { fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM; could_stat = true; } } else { #endif - QString path = QDir::toNativeSeparators(fname); + const QString &path = fname.nativeFilePath(); bool is_dir = false; if (path.startsWith(QLatin1String("\\\\"))) { // UNC - stat doesn't work for all cases (Windows bug) @@ -1274,11 +1209,11 @@ bool QFSFileEnginePrivate::doStat() const } -static QString readSymLink(const QString &link) +static QString readSymLink(const QFileSystemEntry &link) { QString result; #if !defined(Q_OS_WINCE) - HANDLE handle = CreateFile((wchar_t*)QFSFileEnginePrivate::longFileName(link).utf16(), + HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(), FILE_READ_EA, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 0, @@ -1328,7 +1263,7 @@ static QString readSymLink(const QString &link) return result; } -static QString readLink(const QString &link) +static QString readLink(const QFileSystemEntry &link) { #if !defined(Q_OS_WINCE) #if !defined(QT_NO_LIBRARY) && !defined(Q_CC_MWERKS) @@ -1352,7 +1287,7 @@ static QString readLink(const QString &link) IPersistFile *ppf; hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf); if (SUCCEEDED(hres)) { - hres = ppf->Load((LPOLESTR)link.utf16(), STGM_READ); + hres = ppf->Load((LPOLESTR)link.nativeFilePath().utf16(), STGM_READ); //The original path of the link is retrieved. If the file/folder //was moved, the return value still have the old path. if (SUCCEEDED(hres)) { @@ -1374,7 +1309,7 @@ static QString readLink(const QString &link) #else wchar_t target[MAX_PATH]; QString result; - if (SHGetShortcutTarget((wchar_t*)QFileInfo(link).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) { + if (SHGetShortcutTarget((wchar_t*)QFileInfo(link.filePath()).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) { result = QString::fromWCharArray(target); if (result.startsWith(QLatin1Char('"'))) result.remove(0,1); @@ -1458,7 +1393,7 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFil if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) { enum { ReadMask = 0x00000001, WriteMask = 0x00000002, ExecMask = 0x00000020 }; - QString fname = filePath.endsWith(QLatin1String(".lnk")) ? readLink(filePath) : filePath; + QString fname = fileEntry.filePath().endsWith(QLatin1String(".lnk")) ? readLink(fileEntry) : fileEntry.filePath(); PSID pOwner = 0; PSID pGroup = 0; PACL pDacl; @@ -1528,7 +1463,7 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFil | QAbstractFileEngine::WriteOtherPerm; } - QString fname = filePath.endsWith(QLatin1String(".lnk")) ? readLink(filePath) : filePath; + QString fname = fileEntry.filePath().endsWith(QLatin1String(".lnk")) ? readLink(fileEntry) : fileEntry.filePath(); QString ext = fname.right(4).toLower(); if ((fileAttrib & FILE_ATTRIBUTE_DIRECTORY) || ext == QLatin1String(".exe") || ext == QLatin1String(".com") || ext == QLatin1String(".bat") || @@ -1561,16 +1496,8 @@ bool QFSFileEnginePrivate::isSymlink() const is_link = false; if (fileAttrib & FILE_ATTRIBUTE_REPARSE_POINT) { - QString path = QDir::toNativeSeparators(filePath); - // path for the FindFirstFile should not end with a trailing slash - while (path.endsWith(QLatin1Char('\\'))) - path.chop(1); - WIN32_FIND_DATA findData; - HANDLE hFind = ::FindFirstFile((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), - &findData); - if (hFind != INVALID_HANDLE_VALUE) { - ::FindClose(hFind); + if (getFindData(fileEntry.nativeFilePath(), findData)) { if ((findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { is_link = true; @@ -1606,9 +1533,9 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil } } if (type & TypesMask) { - if (d->filePath.endsWith(QLatin1String(".lnk"))) { + if (d->fileEntry.filePath().endsWith(QLatin1String(".lnk"))) { ret |= LinkType; - QString l = readLink(d->filePath); + QString l = readLink(d->fileEntry); if (!l.isEmpty()) { bool existed = false; if (isDirPath(l, &existed) && existed) @@ -1630,7 +1557,7 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::Fil ret |= LocalDiskFlag; if (d->doStat()) { ret |= ExistsFlag; - if (d->filePath == QLatin1String("/") || isDriveRoot(d->filePath) || isUncRoot(d->filePath)) + if (d->fileEntry.isRoot()) ret |= RootFlag; else if (d->fileAttrib & FILE_ATTRIBUTE_HIDDEN) ret |= HiddenFlag; @@ -1643,50 +1570,26 @@ QString QFSFileEngine::fileName(FileName file) const { Q_D(const QFSFileEngine); if (file == BaseName) { - int slash = d->filePath.lastIndexOf(QLatin1Char('/')); - if (slash == -1) { - int colon = d->filePath.lastIndexOf(QLatin1Char(':')); - if (colon != -1) - return d->filePath.mid(colon + 1); - return d->filePath; - } - return d->filePath.mid(slash + 1); + return d->fileEntry.fileName(); } else if (file == PathName) { - if (!d->filePath.size()) - return d->filePath; - - int slash = d->filePath.lastIndexOf(QLatin1Char('/')); - if (slash == -1) { - if (d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':')) - return d->filePath.left(2); - return QString(QLatin1Char('.')); - } else { - if (!slash) - return QString(QLatin1Char('/')); - if (slash == 2 && d->filePath.length() >= 2 && d->filePath.at(1) == QLatin1Char(':')) - slash++; - return d->filePath.left(slash); - } + return d->fileEntry.path(); } else if (file == AbsoluteName || file == AbsolutePathName) { QString ret; if (!isRelativePath()) { #if !defined(Q_OS_WINCE) - if (d->filePath.startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt - d->filePath.size() == 2 || // It's a drive letter that needs to get a working dir appended - (d->filePath.size() > 2 && d->filePath.at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt - d->filePath.contains(QLatin1String("/../")) || d->filePath.contains(QLatin1String("/./")) || - d->filePath.endsWith(QLatin1String("/..")) || d->filePath.endsWith(QLatin1String("/."))) + if (d->fileEntry.filePath().startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt + d->fileEntry.filePath().size() == 2 || // It's a drive letter that needs to get a working dir appended + (d->fileEntry.filePath().size() > 2 && d->fileEntry.filePath().at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt + d->fileEntry.filePath().contains(QLatin1String("/../")) || d->fileEntry.filePath().contains(QLatin1String("/./")) || + d->fileEntry.filePath().endsWith(QLatin1String("/..")) || d->fileEntry.filePath().endsWith(QLatin1String("/."))) { - ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(d->filePath)); - } else { - ret = d->filePath; + ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(d->fileEntry.filePath())); } -#else - ret = d->filePath; #endif + ret = d->fileEntry.filePath(); } else { - ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + d->filePath); + ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + d->fileEntry.filePath()); } // The path should be absolute at this point. @@ -1728,25 +1631,22 @@ QString QFSFileEngine::fileName(FileName file) const return ret; } else if (file == LinkName) { QString ret; - if (d->filePath.endsWith(QLatin1String(".lnk"))) - ret = readLink(d->filePath); + if (d->fileEntry.filePath().endsWith(QLatin1String(".lnk"))) + ret = readLink(d->fileEntry); else if (d->doStat() && d->isSymlink()) - ret = readSymLink(d->filePath); + ret = readSymLink(d->fileEntry); return QDir::fromNativeSeparators(ret); } else if (file == BundleName) { return QString(); } - return d->filePath; + return d->fileEntry.filePath(); } bool QFSFileEngine::isRelativePath() const { Q_D(const QFSFileEngine); // drive, e.g. "a:", or UNC root, e.q. "//" - return !(d->filePath.startsWith(QLatin1Char('/')) - || (d->filePath.length() >= 2 - && ((d->filePath.at(0).isLetter() && d->filePath.at(1) == QLatin1Char(':')) - || (d->filePath.at(0) == QLatin1Char('/') && d->filePath.at(1) == QLatin1Char('/'))))); + return d->fileEntry.isRelative(); } uint QFSFileEngine::ownerId(FileOwner /*own*/) const @@ -1765,7 +1665,7 @@ QString QFSFileEngine::owner(FileOwner own) const if (ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) { PSID pOwner = 0; PSECURITY_DESCRIPTOR pSD; - if (ptrGetNamedSecurityInfoW((wchar_t*)d->filePath.utf16(), SE_FILE_OBJECT, + if (ptrGetNamedSecurityInfoW((wchar_t*)d->fileEntry.nativeFilePath().utf16(), SE_FILE_OBJECT, own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0, 0, 0, &pSD) == ERROR_SUCCESS) { @@ -1817,7 +1717,7 @@ bool QFSFileEngine::setPermissions(uint perms) if (mode == 0) // not supported return false; - ret = ::_wchmod((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), mode) == 0; + ret = ::_wchmod((wchar_t*)d->fileEntry.nativeFilePath().utf16(), mode) == 0; if (!ret) setError(QFile::PermissionsError, qt_error_string(errno)); return ret; @@ -1847,9 +1747,9 @@ bool QFSFileEngine::setSize(qint64 size) return false; } - if (!d->nativeFilePath.isEmpty()) { + if (!d->fileEntry.isEmpty()) { // resize file on disk - QFile file(d->filePath); + QFile file(d->fileEntry.filePath()); if (file.open(QFile::ReadWrite)) { bool ret = file.resize(size); if (!ret) @@ -1915,27 +1815,16 @@ QDateTime QFSFileEngine::fileTime(FileTime time) const #endif } else { WIN32_FILE_ATTRIBUTE_DATA attribData; - bool ok = ::GetFileAttributesEx((wchar_t*)QFSFileEnginePrivate::longFileName(d->filePath).utf16(), GetFileExInfoStandard, &attribData); + bool ok = ::GetFileAttributesEx((wchar_t*)QFSFileEnginePrivate::longFileName(d->fileEntry.filePath()).utf16(), GetFileExInfoStandard, &attribData); if (!ok) { int errorCode = GetLastError(); if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { - QString path = QDir::toNativeSeparators(d->filePath); - // path for the FindFirstFile should not end with a trailing slash - while (path.endsWith(QLatin1Char('\\'))) - path.chop(1); - - // FindFirstFile can not handle drives - if (!path.endsWith(QLatin1Char(':'))) { - WIN32_FIND_DATA findData; - HANDLE hFind = ::FindFirstFile((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), - &findData); - if (hFind != INVALID_HANDLE_VALUE) { - ::FindClose(hFind); - ok = true; - attribData.ftCreationTime = findData.ftCreationTime; - attribData.ftLastWriteTime = findData.ftLastWriteTime; - attribData.ftLastAccessTime = findData.ftLastAccessTime; - } + WIN32_FIND_DATA findData; + if (getFindData(d->fileEntry.nativeFilePath(), findData)) { + ok = true; + attribData.ftCreationTime = findData.ftCreationTime; + attribData.ftLastWriteTime = findData.ftLastWriteTime; + attribData.ftLastAccessTime = findData.ftLastAccessTime; } } } @@ -1977,7 +1866,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, #ifdef Q_USE_DEPRECATED_MAP_API nativeClose(); // handle automatically closed by kernel with mapHandle (below). - handle = ::CreateFileForMapping((const wchar_t*)nativeFilePath.constData(), + handle = ::CreateFileForMapping((const wchar_t*)fileEntry.nativeFilePath().utf16(), GENERIC_READ | (openMode & QIODevice::WriteOnly ? GENERIC_WRITE : 0), 0, NULL, diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index c34c4a4..a0d3176 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -295,7 +295,7 @@ public: : QFSFileEngine(), filePathIsTemplate(fileIsTemplate) { Q_D(QFSFileEngine); - d->filePath = file; + d->fileEntry = QFileSystemEntry(file); if (!filePathIsTemplate) QFSFileEngine::setFileName(file); @@ -346,7 +346,7 @@ void QTemporaryFileEngine::setFileTemplate(const QString &fileTemplate) { Q_D(QFSFileEngine); if (filePathIsTemplate) - d->filePath = fileTemplate; + d->fileEntry = QFileSystemEntry(fileTemplate); } bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) @@ -359,7 +359,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) if (!filePathIsTemplate) return QFSFileEngine::open(openMode); - QString qfilename = d->filePath; + QString qfilename = d->fileEntry.filePath(); if(!qfilename.contains(QLatin1String("XXXXXX"))) qfilename += QLatin1String(".XXXXXX"); @@ -377,9 +377,8 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) d->closeFileHandle = true; // Restore the file names (open() resets them). - d->filePath = QString::fromLocal8Bit(filename); //changed now! + d->fileEntry = QFileSystemEntry(QByteArray(filename)); //changed now! filePathIsTemplate = false; - d->nativeInitFileName(); delete [] filename; return true; } @@ -395,9 +394,8 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) return false; } - QString template_ = d->filePath; - d->filePath = QString::fromLocal8Bit(filename); - d->nativeInitFileName(); + QString template_ = d->fileEntry.filePath(); + d->fileEntry = QFileSystemEntry(QString::fromLocal8Bit(filename)); delete [] filename; if (QFSFileEngine::open(openMode)) { @@ -405,8 +403,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) return true; } - d->filePath = template_; - d->nativeFilePath.clear(); + d->fileEntry = QFileSystemEntry(template_); return false; #endif } @@ -418,7 +415,7 @@ bool QTemporaryFileEngine::remove() // we must explicitly call QFSFileEngine::close() before we remove it. QFSFileEngine::close(); if (QFSFileEngine::remove()) { - d->filePath.clear(); + d->fileEntry.clear(); return true; } return false; -- cgit v0.12 From 3fed8517dc34b77707a42eb1f43a4e7199f105c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 13:57:31 +0200 Subject: QFileSystemEngine::isCaseSensitive for Symbian and Windows --- src/corelib/io/qfilesystemengine_unix.cpp | 4 ++++ src/corelib/io/qfilesystemengine_win.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 2274e69..68cc154 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -46,7 +46,11 @@ QT_BEGIN_NAMESPACE bool QFileSystemEngine::isCaseSensitive() { +#if defined(Q_OS_SYMBIAN) + return false; +#else return true; +#endif } //static diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 942415c..40df120 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE bool QFileSystemEngine::isCaseSensitive() { - return true; + return false; } //static -- cgit v0.12 From 1bdc1dfda903426e7a0bd844c48e67ff9e6b6a94 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 30 Aug 2010 17:41:37 +0200 Subject: Fix the tst_QFileInfo::absolutePath() autotests on Windows Reviewed-by: Joao --- src/corelib/io/qfsfileengine_win.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 6f81652..9f33af5 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1585,9 +1585,11 @@ QString QFSFileEngine::fileName(FileName file) const d->fileEntry.filePath().endsWith(QLatin1String("/..")) || d->fileEntry.filePath().endsWith(QLatin1String("/."))) { ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(d->fileEntry.filePath())); - } + } else #endif - ret = d->fileEntry.filePath(); + { + ret = d->fileEntry.filePath(); + } } else { ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + d->fileEntry.filePath()); } -- cgit v0.12 From 900eb656849d4fa3ff119305c08b631c76fae75e Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 30 Aug 2010 17:28:02 +0200 Subject: Move canonicalPath() to the new qfilesystemengine_unix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Abecasis --- qmake/Makefile.unix | 6 +- qmake/Makefile.win32 | 5 ++ qmake/Makefile.win32-g++ | 4 + qmake/qmake.pri | 1 + src/corelib/io/io.pri | 3 +- src/corelib/io/qfilesystemengine.cpp | 113 +++++++++++++++++++++++++++ src/corelib/io/qfilesystemengine_p.h | 2 + src/corelib/io/qfilesystemengine_unix.cpp | 21 ++++- src/corelib/io/qfsfileengine.cpp | 57 +------------- src/corelib/io/qfsfileengine_unix.cpp | 19 ++--- src/tools/bootstrap/bootstrap.pro | 1 + tools/configure/configure.pro | 1 + tools/qtestlib/wince/cetest/bootstrapped.pri | 1 + 13 files changed, 162 insertions(+), 72 deletions(-) create mode 100644 src/corelib/io/qfilesystemengine.cpp diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 8c1ac6d..4eba3f5 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -16,7 +16,7 @@ OBJS=project.o property.o main.o makefile.o unixmake2.o unixmake.o \ #qt code QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qglobal.o \ qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfile.o \ - qfilesystementry.o qfilesystemengine_unix.o \ + qfilesystementry.o qfilesystemengine_unix.o qfilesystemengine.o \ qfsfileengine_unix.o qfsfileengine_iterator_unix.o qfsfileengine.o \ qfsfileengine_iterator.o qregexp.o qvector.o qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o \ qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o \ @@ -46,6 +46,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge $(SOURCE_PATH)/src/corelib/tools/qbytearray.cpp $(SOURCE_PATH)/src/corelib/tools/qbytearraymatcher.cpp \ $(SOURCE_PATH)/src/corelib/io/qdatastream.cpp $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp \ $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp \ + $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_unix.cpp $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(SOURCE_PATH)/src/corelib/tools/qlist.cpp \ @@ -165,6 +166,9 @@ qfile.o: $(SOURCE_PATH)/src/corelib/io/qfile.cpp qfilesystementry.o: $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp +qfilesystemengine.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp + qfilesystemengine_unix.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index b76348b..ec64fa9 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -89,6 +89,7 @@ QTOBJS= \ qbuffer.obj \ qcryptographichash.obj \ qfilesystementry.obj \ + qfilesystemengine.obj \ qfilesystemengine_win.obj \ qfsfileengine.obj \ qfsfileengine_iterator.obj \ @@ -144,6 +145,7 @@ clean:: -del qcryptographichash.obj -del qlinkedlist.obj -del qfilesystementry.obj + -del qfilesystemengine.obj -del qfilesystemengine_win.obj -del qfsfileengine.obj -del qfsfileengine_iterator.obj @@ -317,6 +319,9 @@ qtemporaryfile.obj: $(SOURCE_PATH)\src\corelib\io\qtemporaryfile.cpp qfilesystementry.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystementry.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfilesystementry.cpp +qfilesystemengine.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystemengine.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfilesystemengine.cpp + qfilesystemengine_win.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystemengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfilesystemengine_win.cpp diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index c692731..f2f8386 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -62,6 +62,7 @@ QTOBJS= \ qfileinfo.o \ qabstractfileengine.o \ qfilesystementry.o \ + qfilesystemengine.o \ qfilesystemengine_win.o \ qfsfileengine.o \ qfsfileengine_iterator.o \ @@ -197,6 +198,9 @@ qabstractfileengine.o: $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp qfilesystementry.o: $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp +qfilesystemengine.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp + qfilesystemengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 4d78c8b..be6a909 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -58,6 +58,7 @@ bootstrap { #Qt code qabstractfileengine.cpp \ qfileinfo.cpp \ qfilesystementry.cpp \ + qfilesystemengine.cpp \ qfsfileengine.cpp \ qfsfileengine_iterator.cpp \ qglobal.cpp \ diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 3bde2de..7a34275 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -56,7 +56,8 @@ SOURCES += \ io/qfsfileengine.cpp \ io/qfsfileengine_iterator.cpp \ io/qfilesystemwatcher.cpp \ - io/qfilesystementry.cpp + io/qfilesystementry.cpp \ + io/qfilesystemengine.cpp win32 { SOURCES += io/qsettings_win.cpp diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp new file mode 100644 index 0000000..04e53ce --- /dev/null +++ b/src/corelib/io/qfilesystemengine.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfilesystemengine_p.h" +#include +#include + +/*! + \internal + + Returns the canonicalized form of \a path (i.e., with all symlinks + resolved, and all redundant path elements removed. +*/ +QString QFileSystemEngine::slowCanonicalized(const QString &path) +{ + if (path.isEmpty()) + return path; + + QFileInfo fi; + const QChar slash(QLatin1Char('/')); + QString tmpPath = path; + int separatorPos = 0; + QSet nonSymlinks; + QSet known; + + known.insert(path); + do { +#ifdef Q_OS_WIN + if (separatorPos == 0) { + if (tmpPath.size() >= 2 && tmpPath.at(0) == slash && tmpPath.at(1) == slash) { + // UNC, skip past the first two elements + separatorPos = tmpPath.indexOf(slash, 2); + } else if (tmpPath.size() >= 3 && tmpPath.at(1) == QLatin1Char(':') && tmpPath.at(2) == slash) { + // volume root, skip since it can not be a symlink + separatorPos = 2; + } + } + if (separatorPos != -1) +#endif + separatorPos = tmpPath.indexOf(slash, separatorPos + 1); + QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos); + if ( +#ifdef Q_OS_SYMBIAN + // Symbian doesn't support directory symlinks, so do not check for link unless we + // are handling the last path element. This not only slightly improves performance, + // but also saves us from lot of unnecessary platform security check failures + // when dealing with files under *:/private directories. + separatorPos == -1 && +#endif + !nonSymlinks.contains(prefix)) { + fi.setFile(prefix); + if (fi.isSymLink()) { + QString target = fi.symLinkTarget(); + if(QFileInfo(target).isRelative()) + target = fi.absolutePath() + slash + target; + if (separatorPos != -1) { + if (fi.isDir() && !target.endsWith(slash)) + target.append(slash); + target.append(tmpPath.mid(separatorPos)); + } + tmpPath = QDir::cleanPath(target); + separatorPos = 0; + + if (known.contains(tmpPath)) + return QString(); + known.insert(tmpPath); + } else { + nonSymlinks.insert(prefix); + } + } + } while (separatorPos != -1); + + return QDir::cleanPath(tmpPath); +} + diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index c1bb3b4..61ca085 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -84,6 +84,8 @@ public: static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data = 0); + + static QString slowCanonicalized(const QString &path); }; QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 68cc154..283c787 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -42,6 +42,9 @@ #include "qfilesystemengine_p.h" #include "qfsfileengine.h" +#include // for realpath() +#include + QT_BEGIN_NAMESPACE bool QFileSystemEngine::isCaseSensitive() @@ -62,7 +65,23 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) //static QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) { - return entry; // TODO implement; + if (entry.isEmpty() || entry.isRoot()) + return entry; + +#ifdef __UCLIBC__ + return QFileSystemEntry::slowCanonicalName(entry); +#else + + char *ret = realpath(entry.nativeFilePath().constData(), (char*)0); + if (ret) { + QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); + free(ret); + return QFileSystemEntry(canonicalPath); + } else if (errno == ENOENT) { // file doesn't exist + return QFileSystemEntry(); + } + return entry; +#endif } //static diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 75f82a6..665d23e 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -41,6 +41,7 @@ #include "qfsfileengine_p.h" #include "qfsfileengine_iterator_p.h" +#include "qfilesystemengine_p.h" #include "qdatetime.h" #include "qdiriterator.h" #include "qset.h" @@ -179,61 +180,7 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) #endif #endif - QFileInfo fi; - const QChar slash(QLatin1Char('/')); - QString tmpPath = path; - int separatorPos = 0; - QSet nonSymlinks; - QSet known; - - known.insert(path); - do { -#ifdef Q_OS_WIN - if (separatorPos == 0) { - if (tmpPath.size() >= 2 && tmpPath.at(0) == slash && tmpPath.at(1) == slash) { - // UNC, skip past the first two elements - separatorPos = tmpPath.indexOf(slash, 2); - } else if (tmpPath.size() >= 3 && tmpPath.at(1) == QLatin1Char(':') && tmpPath.at(2) == slash) { - // volume root, skip since it can not be a symlink - separatorPos = 2; - } - } - if (separatorPos != -1) -#endif - separatorPos = tmpPath.indexOf(slash, separatorPos + 1); - QString prefix = separatorPos == -1 ? tmpPath : tmpPath.left(separatorPos); - if ( -#ifdef Q_OS_SYMBIAN - // Symbian doesn't support directory symlinks, so do not check for link unless we - // are handling the last path element. This not only slightly improves performance, - // but also saves us from lot of unnecessary platform security check failures - // when dealing with files under *:/private directories. - separatorPos == -1 && -#endif - !nonSymlinks.contains(prefix)) { - fi.setFile(prefix); - if (fi.isSymLink()) { - QString target = fi.symLinkTarget(); - if(QFileInfo(target).isRelative()) - target = fi.absolutePath() + slash + target; - if (separatorPos != -1) { - if (fi.isDir() && !target.endsWith(slash)) - target.append(slash); - target.append(tmpPath.mid(separatorPos)); - } - tmpPath = QDir::cleanPath(target); - separatorPos = 0; - - if (known.contains(tmpPath)) - return QString(); - known.insert(tmpPath); - } else { - nonSymlinks.insert(prefix); - } - } - } while (separatorPos != -1); - - return QDir::cleanPath(tmpPath); + return QFileSystemEngine::slowCanonicalized(path); } /*! diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 3daf7f6..29491f5 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1027,25 +1027,16 @@ QString QFSFileEngine::fileName(FileName file) const } else if (file == PathName) { return d->fileEntry.path(); } else if (file == AbsoluteName || file == AbsolutePathName) { - QFileSystemEntry entry = QFileSystemEngine::absoluteName(d->fileEntry); + QFileSystemEntry entry(QFileSystemEngine::absoluteName(d->fileEntry)); if (file == AbsolutePathName) { return entry.path(); } return entry.filePath(); } else if (file == CanonicalName || file == CanonicalPathName) { - if (!(fileFlags(ExistsFlag) & ExistsFlag)) - return QString(); - - QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName)); - if (file == CanonicalPathName && !ret.isEmpty()) { - int slash = ret.lastIndexOf(QLatin1Char('/')); - if (slash == -1) - ret = QDir::currentPath(); - else if (slash == 0) - ret = QLatin1String("/"); - ret = ret.left(slash); - } - return ret; + QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry)); + if (file == CanonicalPathName) + return entry.path(); + return entry.filePath(); } else if (file == LinkName) { if (d->isSymlink()) { #if defined(__GLIBC__) && !defined(PATH_MAX) diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index bec1329..9adba9c 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -58,6 +58,7 @@ SOURCES += \ ../../corelib/io/qfile.cpp \ ../../corelib/io/qfileinfo.cpp \ ../../corelib/io/qfilesystementry.cpp \ + ../../corelib/io/qfilesystemengine.cpp \ ../../corelib/io/qfsfileengine.cpp \ ../../corelib/io/qfsfileengine_iterator.cpp \ ../../corelib/io/qiodevice.cpp \ diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index 9e52f81..854a0e4 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -90,6 +90,7 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ diff --git a/tools/qtestlib/wince/cetest/bootstrapped.pri b/tools/qtestlib/wince/cetest/bootstrapped.pri index 0af5c94..f33dde8 100644 --- a/tools/qtestlib/wince/cetest/bootstrapped.pri +++ b/tools/qtestlib/wince/cetest/bootstrapped.pri @@ -5,6 +5,7 @@ SOURCES += \ $$QT_SOURCE_TREE/src/corelib/io/qfile.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qdir.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ -- cgit v0.12 From c2df86d23477573ef664a20b47b19a42e4a2e6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 15:02:29 +0200 Subject: Removed QFileInfoPrivate::initFileEngine As it served no real purpose. Instead, the relevant bits were inlined in the constructor that used it and makeAbsolute was adapted to use operator=. Reviewed-by: Thomas Zander --- src/corelib/io/qfileinfo.cpp | 12 ++---------- src/corelib/io/qfileinfo_p.h | 5 ++--- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index fe557d0..ccfc9c2 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -47,15 +47,6 @@ QT_BEGIN_NAMESPACE -void QFileInfoPrivate::initFileEngine(const QString &file) -{ - delete fileEngine; - fileEngine = 0; - clear(); - fileEngine = QAbstractFileEngine::create(file); - fileName = file; -} - QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const { if (cache_enabled && !fileNames[(int)name].isNull()) @@ -586,7 +577,8 @@ bool QFileInfo::makeAbsolute() return false; QString absFileName = d_ptr.constData()->getFileName(QAbstractFileEngine::AbsoluteName); // QSharedDataPointer::operator->() will detach. - d_ptr->initFileEngine(absFileName); + + *this = QFileInfo(absFileName); return true; } diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 138116e..f23ae53 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -79,16 +79,15 @@ public: cachedFlags(0), cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) {} inline QFileInfoPrivate(const QString &file) - : QSharedData(), fileEngine(0), + : QSharedData(), fileEngine(QAbstractFileEngine::create(file)), + fileName(file), cachedFlags(0), cache_enabled(1), fileFlags(0), fileSize(0) { - initFileEngine(file); } inline ~QFileInfoPrivate() { delete fileEngine; } - void initFileEngine(const QString &); inline void clearFlags() const { fileFlags = 0; -- cgit v0.12 From 7a8cdcac068898697f9f0f75c410ea673d6f0d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 16:59:20 +0200 Subject: Adding minimal QFileSystemIterator API Only stubs, for now, but it's a start. Reviewed-by: Thomas Zander --- qmake/Makefile.unix | 7 ++- qmake/Makefile.win32 | 5 ++ qmake/Makefile.win32-g++ | 4 ++ qmake/Makefile.win32-g++-sh | 4 ++ qmake/qmake.pri | 4 +- src/corelib/io/io.pri | 5 +- src/corelib/io/qfilesystemiterator_p.h | 78 ++++++++++++++++++++++++++++ src/corelib/io/qfilesystemiterator_unix.cpp | 61 ++++++++++++++++++++++ src/corelib/io/qfilesystemiterator_win.cpp | 61 ++++++++++++++++++++++ src/tools/bootstrap/bootstrap.pro | 2 + tools/configure/configure.pro | 2 + tools/qtestlib/wince/cetest/bootstrapped.pri | 1 + 12 files changed, 229 insertions(+), 5 deletions(-) create mode 100644 src/corelib/io/qfilesystemiterator_p.h create mode 100644 src/corelib/io/qfilesystemiterator_unix.cpp create mode 100644 src/corelib/io/qfilesystemiterator_win.cpp diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 4eba3f5..e8e96fd 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -16,7 +16,7 @@ OBJS=project.o property.o main.o makefile.o unixmake2.o unixmake.o \ #qt code QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qglobal.o \ qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfile.o \ - qfilesystementry.o qfilesystemengine_unix.o qfilesystemengine.o \ + qfilesystementry.o qfilesystemengine_unix.o qfilesystemengine.o qfilesystemiterator_unix.o \ qfsfileengine_unix.o qfsfileengine_iterator_unix.o qfsfileengine.o \ qfsfileengine_iterator.o qregexp.o qvector.o qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o \ qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o \ @@ -46,7 +46,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge $(SOURCE_PATH)/src/corelib/tools/qbytearray.cpp $(SOURCE_PATH)/src/corelib/tools/qbytearraymatcher.cpp \ $(SOURCE_PATH)/src/corelib/io/qdatastream.cpp $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp \ $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp \ - $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp \ + $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_unix.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_unix.cpp $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(SOURCE_PATH)/src/corelib/tools/qlist.cpp \ @@ -172,6 +172,9 @@ qfilesystemengine.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp qfilesystemengine_unix.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp +qfilesystemiterator_unix.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_unix.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_unix.cpp + qfsfileengine.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index ec64fa9..fa17b9d 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -91,6 +91,7 @@ QTOBJS= \ qfilesystementry.obj \ qfilesystemengine.obj \ qfilesystemengine_win.obj \ + qfilesystemiterator_win.obj \ qfsfileengine.obj \ qfsfileengine_iterator.obj \ qbytearray.obj \ @@ -147,6 +148,7 @@ clean:: -del qfilesystementry.obj -del qfilesystemengine.obj -del qfilesystemengine_win.obj + -del qfilesystemiterator_win.obj -del qfsfileengine.obj -del qfsfileengine_iterator.obj -del qbytearray.obj @@ -325,6 +327,9 @@ qfilesystemengine.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystemengine.cpp qfilesystemengine_win.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystemengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfilesystemengine_win.cpp +qfilesystemiterator_win.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystemiterator_win.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfilesystemiterator_win.cpp + qfsfileengine_win.obj: $(SOURCE_PATH)\src\corelib\io\qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfsfileengine_win.cpp diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index f2f8386..57ea3d5 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -64,6 +64,7 @@ QTOBJS= \ qfilesystementry.o \ qfilesystemengine.o \ qfilesystemengine_win.o \ + qfilesystemiterator_win.o \ qfsfileengine.o \ qfsfileengine_iterator.o \ qfsfileengine_win.o \ @@ -204,6 +205,9 @@ qfilesystemengine.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp qfilesystemengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp +qfilesystemiterator_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win.cpp + qfsfileengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index cc256e9..33deb01 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -63,6 +63,7 @@ QTOBJS= \ qabstractfileengine.o \ qfilesystementry.o \ qfilesystemengine_win.o \ + qfilesystemiterator_win.o \ qfsfileengine.o \ qfsfileengine_iterator.o \ qfsfileengine_win.o \ @@ -199,6 +200,9 @@ qfilesystementry.o: $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp qfilesystemengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp +qfilesystemiterator_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win.cpp + qfsfileengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp diff --git a/qmake/qmake.pri b/qmake/qmake.pri index be6a909..7226b12 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -127,14 +127,14 @@ bootstrap { #Qt code qxmlutils.h unix { - SOURCES += qfilesystemengine_unix.cpp qfsfileengine_unix.cpp qfsfileengine_iterator_unix.cpp + SOURCES += qfilesystemengine_unix.cpp qfilesystemiterator_unix.cpp qfsfileengine_unix.cpp qfsfileengine_iterator_unix.cpp mac { SOURCES += qcore_mac.cpp qsettings_mac.cpp QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported) LIBS += -framework ApplicationServices } } else:win32 { - SOURCES += qfilesystemengine_win.cpp qfsfileengine_win.cpp qfsfileengine_iterator_win.cpp qsettings_win.cpp + SOURCES += qfilesystemengine_win.cpp qfsfileengine_win.cpp qfilesystemiterator_win.cpp qfsfileengine_iterator_win.cpp qsettings_win.cpp win32-msvc*:LIBS += ole32.lib advapi32.lib win32-g++*:LIBS += -lole32 -luuid } diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 7a34275..5d10216 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -32,7 +32,8 @@ HEADERS += \ io/qfilesystemwatcher_p.h \ io/qfilesystementry_p.h \ io/qfilesystemengine_p.h \ - io/qfilesystemmetadata_p.h + io/qfilesystemmetadata_p.h \ + io/qfilesystemiterator_p.h SOURCES += \ io/qabstractfileengine.cpp \ @@ -70,8 +71,10 @@ win32 { HEADERS += io/qwindowspipewriter_p.h SOURCES += io/qwindowspipewriter.cpp SOURCES += io/qfilesystemengine_win.cpp + SOURCES += io/qfilesystemiterator_win.cpp } else:unix { SOURCES += io/qfilesystemengine_unix.cpp + SOURCES += io/qfilesystemiterator_unix.cpp SOURCES += io/qfsfileengine_unix.cpp SOURCES += io/qfsfileengine_iterator_unix.cpp symbian:SOURCES += io/qprocess_symbian.cpp diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h new file mode 100644 index 0000000..436ff7e --- /dev/null +++ b/src/corelib/io/qfilesystemiterator_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QFILESYSTEMITERATOR_P_H_INCLUDED +#define QFILESYSTEMITERATOR_P_H_INCLUDED + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QFileSystemIterator +{ +public: + QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters); + + bool advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData); + +private: + Q_DISABLE_COPY(QFileSystemIterator) +}; + +QT_END_NAMESPACE + +#endif // include guard diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp new file mode 100644 index 0000000..3ee344b --- /dev/null +++ b/src/corelib/io/qfilesystemiterator_unix.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfilesystemiterator_p.h" + +QT_BEGIN_NAMESPACE + +QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, + const QStringList &nameFilters) +{ + Q_UNUSED(entry) + Q_UNUSED(filters) + Q_UNUSED(nameFilters) +} + +bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) +{ + Q_UNUSED(fileEntry) + Q_UNUSED(metaData) + return false; +} + +QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp new file mode 100644 index 0000000..3ee344b --- /dev/null +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfilesystemiterator_p.h" + +QT_BEGIN_NAMESPACE + +QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, + const QStringList &nameFilters) +{ + Q_UNUSED(entry) + Q_UNUSED(filters) + Q_UNUSED(nameFilters) +} + +bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) +{ + Q_UNUSED(fileEntry) + Q_UNUSED(metaData) + return false; +} + +QT_END_NAMESPACE diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 9adba9c..6d2f760 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -86,10 +86,12 @@ SOURCES += \ ../../xml/sax/qxml.cpp unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \ + ../../corelib/io/qfilesystemiterator_unix.cpp \ ../../corelib/io/qfsfileengine_unix.cpp \ ../../corelib/io/qfsfileengine_iterator_unix.cpp win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ + ../../corelib/io/qfilesystemiterator_win.cpp \ ../../corelib/io/qfsfileengine_win.cpp \ ../../corelib/io/qfsfileengine_iterator_win.cpp diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index 854a0e4..fe1b028 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -51,6 +51,7 @@ HEADERS = configureapp.h environment.h tools.h\ $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry_p.h \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_p.h \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemmetadata_p.h \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_p.h \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.h \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_p.h \ $$QT_SOURCE_TREE/src/corelib/io/qiodevice.h \ @@ -92,6 +93,7 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ diff --git a/tools/qtestlib/wince/cetest/bootstrapped.pri b/tools/qtestlib/wince/cetest/bootstrapped.pri index f33dde8..76245b0 100644 --- a/tools/qtestlib/wince/cetest/bootstrapped.pri +++ b/tools/qtestlib/wince/cetest/bootstrapped.pri @@ -7,6 +7,7 @@ SOURCES += \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystementry.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfilesystemengine_win.cpp \ + $$QT_SOURCE_TREE/src/corelib/io/qfilesystemiterator_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ -- cgit v0.12 From e074824409dae5d2e242c3a6904329826a708c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 17:40:11 +0200 Subject: QFileInfo: Prepare for engine-less implementation The absence of a file engine was being interpreted as a synonym for a default constructed instance (or failed engine creation with QT_NO_FSFILEENGINE). By having an explicit flag, we open the door for bypassing file engine creation. Reviewed-by: Thomas Zander --- src/corelib/io/qfileinfo.cpp | 73 ++++++++++++++++++++++---------------------- src/corelib/io/qfileinfo_p.h | 32 +++++++++++++------ 2 files changed, 59 insertions(+), 46 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index ccfc9c2..248b83d 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -328,7 +328,7 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const // ### (GetFullPathName()). if (fileinfo.d_ptr == d_ptr) return true; - if (!d->fileEngine || !fileinfo.d_ptr->fileEngine) + if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed) return false; if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive()) return false; @@ -454,7 +454,7 @@ void QFileInfo::setFile(const QDir &dir, const QString &file) QString QFileInfo::absoluteFilePath() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::AbsoluteName); } @@ -471,7 +471,7 @@ QString QFileInfo::absoluteFilePath() const QString QFileInfo::canonicalFilePath() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::CanonicalName); } @@ -498,7 +498,7 @@ QString QFileInfo::absolutePath() const { Q_D(const QFileInfo); - if (!d->fileEngine) { + if (d->isDefaultConstructed) { return QLatin1String(""); } else if (d->fileName.isEmpty()) { qWarning("QFileInfo::absolutePath: Constructed with empty filename"); @@ -518,7 +518,7 @@ QString QFileInfo::absolutePath() const QString QFileInfo::canonicalPath() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::CanonicalPathName); } @@ -535,7 +535,7 @@ QString QFileInfo::canonicalPath() const QString QFileInfo::path() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::PathName); } @@ -559,7 +559,7 @@ QString QFileInfo::path() const bool QFileInfo::isRelative() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return true; return d->fileEngine->isRelativePath(); } @@ -573,7 +573,8 @@ bool QFileInfo::isRelative() const */ bool QFileInfo::makeAbsolute() { - if (!d_ptr.constData()->fileEngine || !d_ptr.constData()->fileEngine->isRelativePath()) + if (d_ptr.constData()->isDefaultConstructed + || !d_ptr.constData()->fileEngine->isRelativePath()) return false; QString absFileName = d_ptr.constData()->getFileName(QAbstractFileEngine::AbsoluteName); // QSharedDataPointer::operator->() will detach. @@ -591,7 +592,7 @@ bool QFileInfo::makeAbsolute() bool QFileInfo::exists() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::ExistsFlag); } @@ -618,7 +619,7 @@ void QFileInfo::refresh() QString QFileInfo::filePath() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::DefaultName); } @@ -637,7 +638,7 @@ QString QFileInfo::filePath() const QString QFileInfo::fileName() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BaseName); } @@ -657,7 +658,7 @@ QString QFileInfo::fileName() const QString QFileInfo::bundleName() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BundleName); } @@ -681,7 +682,7 @@ QString QFileInfo::bundleName() const QString QFileInfo::baseName() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0); } @@ -700,7 +701,7 @@ QString QFileInfo::baseName() const QString QFileInfo::completeBaseName() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); QString name = d->getFileName(QAbstractFileEngine::BaseName); int index = name.lastIndexOf(QLatin1Char('.')); @@ -721,7 +722,7 @@ QString QFileInfo::completeBaseName() const QString QFileInfo::completeSuffix() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); QString fileName = d->getFileName(QAbstractFileEngine::BaseName); int firstDot = fileName.indexOf(QLatin1Char('.')); @@ -748,7 +749,7 @@ QString QFileInfo::completeSuffix() const QString QFileInfo::suffix() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); QString fileName = d->getFileName(QAbstractFileEngine::BaseName); int lastDot = fileName.lastIndexOf(QLatin1Char('.')); @@ -813,7 +814,7 @@ QDir QFileInfo::dir(bool absPath) const bool QFileInfo::isReadable() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::ReadUserPerm); } @@ -826,7 +827,7 @@ bool QFileInfo::isReadable() const bool QFileInfo::isWritable() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::WriteUserPerm); } @@ -839,7 +840,7 @@ bool QFileInfo::isWritable() const bool QFileInfo::isExecutable() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::ExeUserPerm); } @@ -853,7 +854,7 @@ bool QFileInfo::isExecutable() const bool QFileInfo::isHidden() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::HiddenFlag); } @@ -868,7 +869,7 @@ bool QFileInfo::isHidden() const bool QFileInfo::isFile() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::FileType); } @@ -882,7 +883,7 @@ bool QFileInfo::isFile() const bool QFileInfo::isDir() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::DirectoryType); } @@ -898,7 +899,7 @@ bool QFileInfo::isDir() const bool QFileInfo::isBundle() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::BundleType); } @@ -923,7 +924,7 @@ bool QFileInfo::isBundle() const bool QFileInfo::isSymLink() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::LinkType); } @@ -936,7 +937,7 @@ bool QFileInfo::isSymLink() const bool QFileInfo::isRoot() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return true; return d->getFileFlags(QAbstractFileEngine::RootFlag); } @@ -964,7 +965,7 @@ bool QFileInfo::isRoot() const QString QFileInfo::readLink() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileName(QAbstractFileEngine::LinkName); } @@ -982,7 +983,7 @@ QString QFileInfo::readLink() const QString QFileInfo::owner() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileOwner(QAbstractFileEngine::OwnerUser); } @@ -998,7 +999,7 @@ QString QFileInfo::owner() const uint QFileInfo::ownerId() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return 0; return d->fileEngine->ownerId(QAbstractFileEngine::OwnerUser); } @@ -1016,7 +1017,7 @@ uint QFileInfo::ownerId() const QString QFileInfo::group() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QLatin1String(""); return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } @@ -1032,7 +1033,7 @@ QString QFileInfo::group() const uint QFileInfo::groupId() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return 0; return d->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup); } @@ -1053,7 +1054,7 @@ uint QFileInfo::groupId() const bool QFileInfo::permission(QFile::Permissions permissions) const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return false; return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions; } @@ -1065,7 +1066,7 @@ bool QFileInfo::permission(QFile::Permissions permissions) const QFile::Permissions QFileInfo::permissions() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return 0; return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask); } @@ -1080,7 +1081,7 @@ QFile::Permissions QFileInfo::permissions() const qint64 QFileInfo::size() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return 0; if (!d->getCachedFlag(QFileInfoPrivate::CachedSize)) { d->setCachedFlag(QFileInfoPrivate::CachedSize); @@ -1105,7 +1106,7 @@ qint64 QFileInfo::size() const QDateTime QFileInfo::created() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QDateTime(); return d->getFileTime(QAbstractFileEngine::CreationTime); } @@ -1118,7 +1119,7 @@ QDateTime QFileInfo::created() const QDateTime QFileInfo::lastModified() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QDateTime(); return d->getFileTime(QAbstractFileEngine::ModificationTime); } @@ -1134,7 +1135,7 @@ QDateTime QFileInfo::lastModified() const QDateTime QFileInfo::lastRead() const { Q_D(const QFileInfo); - if (!d->fileEngine) + if (d->isDefaultConstructed) return QDateTime(); return d->getFileTime(QAbstractFileEngine::AccessTime); } diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index f23ae53..b9b1092 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -71,23 +71,33 @@ public: inline QFileInfoPrivate() : QSharedData(), fileEngine(0), - cachedFlags(0), cache_enabled(1), fileFlags(0), fileSize(0) + cachedFlags(0), + isDefaultConstructed(true), + cache_enabled(true), fileFlags(0), fileSize(0) {} inline QFileInfoPrivate(const QFileInfoPrivate ©) : QSharedData(copy), fileEngine(QAbstractFileEngine::create(copy.fileName)), fileName(copy.fileName), - cachedFlags(0), cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) + cachedFlags(0), +#ifndef QT_NO_FSFILEENGINE + isDefaultConstructed(false), +#else + isDefaultConstructed(!fileEngine), +#endif + cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) {} inline QFileInfoPrivate(const QString &file) : QSharedData(), fileEngine(QAbstractFileEngine::create(file)), fileName(file), - cachedFlags(0), cache_enabled(1), fileFlags(0), fileSize(0) + cachedFlags(0), +#ifndef QT_NO_FSFILEENGINE + isDefaultConstructed(false), +#else + isDefaultConstructed(!fileEngine), +#endif + cache_enabled(true), fileFlags(0), fileSize(0) { } - inline ~QFileInfoPrivate() - { - delete fileEngine; - } inline void clearFlags() const { fileFlags = 0; @@ -108,13 +118,15 @@ public: QString getFileName(QAbstractFileEngine::FileName) const; QString getFileOwner(QAbstractFileEngine::FileOwner own) const; - QAbstractFileEngine *fileEngine; + QScopedPointer const fileEngine; + mutable QString fileName; mutable QString fileNames[QAbstractFileEngine::NFileNames]; mutable QString fileOwners[2]; - mutable uint cachedFlags : 31; - mutable uint cache_enabled : 1; + mutable uint cachedFlags : 30; + bool const isDefaultConstructed : 1; // QFileInfo is a default constructed instance + bool cache_enabled : 1; mutable uint fileFlags; mutable qint64 fileSize; mutable QDateTime fileTimes[3]; -- cgit v0.12 From 50db9fb1bf4944d4b8e3077e0a9d30afb4495c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 18:47:13 +0200 Subject: Reverting QDir::detach introduced earlier From the client API it is a broken concept, because it could leave the user with an uninitialized file engine. Fixing to initialize the file engine, would mean it is useless for internal use where file engines are initialized separately. In the end, removing both the QDir::detach introduced earlier and throwing away the private d_func'tions altogether is a binary-compatible change that should allow us to push this change in a patch release (fingers crossed!) Reviewed-by: Thiago Macieira --- src/corelib/io/qdir.cpp | 71 +++++++++++++++++++++++-------------------------- src/corelib/io/qdir.h | 13 --------- 2 files changed, 33 insertions(+), 51 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 9ebfce5..b355f62 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -561,11 +561,6 @@ QDir::~QDir() { } -void QDir::detach() -{ - d_ptr.detach(); -} - /*! Sets the path of the directory to \a path. The path is cleaned of redundant ".", ".." and of multiple separators. No check is made @@ -599,7 +594,7 @@ void QDir::setPath(const QString &path) */ QString QDir::path() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); return d->path; } @@ -613,7 +608,7 @@ QString QDir::path() const */ QString QDir::absolutePath() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); QString ret = d->path; if (QDir::isRelativePath(ret)) ret = absoluteFilePath(QString::fromLatin1("")); @@ -638,7 +633,7 @@ QString QDir::absolutePath() const */ QString QDir::canonicalPath() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (!d->fileEngine) return QLatin1String(""); @@ -658,7 +653,7 @@ QString QDir::canonicalPath() const */ QString QDir::dirName() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); int pos = d->path.lastIndexOf(QLatin1Char('/')); if (pos == -1) return d->path; @@ -676,7 +671,7 @@ QString QDir::dirName() const */ QString QDir::filePath(const QString &fileName) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (isAbsolutePath(fileName)) return QString(fileName); @@ -699,7 +694,7 @@ QString QDir::filePath(const QString &fileName) const */ QString QDir::absoluteFilePath(const QString &fileName) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (isAbsolutePath(fileName)) return fileName; if (!d->fileEngine) @@ -924,7 +919,7 @@ bool QDir::cdUp() */ QStringList QDir::nameFilters() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); return d->nameFilters; } @@ -945,7 +940,7 @@ QStringList QDir::nameFilters() const */ void QDir::setNameFilters(const QStringList &nameFilters) { - Q_D(QDir); + QDirPrivate* d = d_ptr.data(); d->initFileEngine(); d->clearFileLists(); @@ -1052,7 +1047,7 @@ QStringList QDir::searchPaths(const QString &prefix) */ QDir::Filters QDir::filter() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); return d->filters; } @@ -1134,7 +1129,7 @@ QDir::Filters QDir::filter() const */ void QDir::setFilter(Filters filters) { - Q_D(QDir); + QDirPrivate* d = d_ptr.data(); d->initFileEngine(); d->clearFileLists(); @@ -1148,7 +1143,7 @@ void QDir::setFilter(Filters filters) */ QDir::SortFlags QDir::sorting() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); return d->sort; } @@ -1192,7 +1187,7 @@ QDir::SortFlags QDir::sorting() const */ void QDir::setSorting(SortFlags sort) { - Q_D(QDir); + QDirPrivate* d = d_ptr.data(); d->initFileEngine(); d->clearFileLists(); @@ -1208,7 +1203,7 @@ void QDir::setSorting(SortFlags sort) */ uint QDir::count() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); d->initFileLists(); return d->files.count(); } @@ -1222,7 +1217,7 @@ uint QDir::count() const */ QString QDir::operator[](int pos) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); d->initFileLists(); return d->files[pos]; } @@ -1248,7 +1243,7 @@ QString QDir::operator[](int pos) const */ QStringList QDir::entryList(Filters filters, SortFlags sort) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); return entryList(d->nameFilters, filters, sort); } @@ -1271,7 +1266,7 @@ QStringList QDir::entryList(Filters filters, SortFlags sort) const */ QFileInfoList QDir::entryInfoList(Filters filters, SortFlags sort) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); return entryInfoList(d->nameFilters, filters, sort); } @@ -1294,7 +1289,7 @@ QFileInfoList QDir::entryInfoList(Filters filters, SortFlags sort) const QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, SortFlags sort) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (filters == NoFilter) filters = d->filters; @@ -1340,7 +1335,7 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filters, SortFlags sort) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (filters == NoFilter) filters = d->filters; @@ -1376,7 +1371,7 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter */ bool QDir::mkdir(const QString &dirName) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (dirName.isEmpty()) { qWarning("QDir::mkdir: Empty or null file name(s)"); @@ -1400,7 +1395,7 @@ bool QDir::mkdir(const QString &dirName) const */ bool QDir::rmdir(const QString &dirName) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (dirName.isEmpty()) { qWarning("QDir::rmdir: Empty or null file name(s)"); @@ -1425,7 +1420,7 @@ bool QDir::rmdir(const QString &dirName) const */ bool QDir::mkpath(const QString &dirPath) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (dirPath.isEmpty()) { qWarning("QDir::mkpath: Empty or null file name(s)"); @@ -1451,7 +1446,7 @@ bool QDir::mkpath(const QString &dirPath) const */ bool QDir::rmpath(const QString &dirPath) const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (dirPath.isEmpty()) { qWarning("QDir::rmpath: Empty or null file name(s)"); @@ -1475,7 +1470,7 @@ bool QDir::rmpath(const QString &dirPath) const */ bool QDir::isReadable() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (!d->fileEngine) return false; @@ -1500,7 +1495,7 @@ bool QDir::isReadable() const */ bool QDir::exists() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (!d->fileEngine) return false; @@ -1527,7 +1522,7 @@ bool QDir::exists() const */ bool QDir::isRoot() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (!d->fileEngine) return true; @@ -1561,7 +1556,7 @@ bool QDir::isRoot() const */ bool QDir::isRelative() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); if (!d->fileEngine) return false; @@ -1603,8 +1598,8 @@ bool QDir::makeAbsolute() // ### What do the return values signify? */ bool QDir::operator==(const QDir &dir) const { - const QDirPrivate *d = d_func(); - const QDirPrivate *other = dir.d_func(); + const QDirPrivate *d = d_ptr.constData(); + const QDirPrivate *other = dir.d_ptr.constData(); if (d == other) return true; @@ -2133,7 +2128,7 @@ bool QDir::isRelativePath(const QString &path) */ void QDir::refresh() const { - QDirPrivate *d = const_cast(this)->d_func(); + QDirPrivate *d = const_cast(this)->d_ptr.data(); d->initFileEngine(); d->clearFileLists(); } @@ -2211,7 +2206,7 @@ QStringList QDir::nameFiltersFromString(const QString &nameFilter) */ bool QDir::matchAllDirs() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); return d->matchAllDirs; } @@ -2223,7 +2218,7 @@ bool QDir::matchAllDirs() const */ void QDir::setMatchAllDirs(bool on) { - Q_D(QDir); + QDirPrivate* d = d_ptr.data(); d->initFileEngine(); d->clearFileLists(); @@ -2235,7 +2230,7 @@ void QDir::setMatchAllDirs(bool on) */ QString QDir::nameFilter() const { - Q_D(const QDir); + const QDirPrivate* d = d_ptr.constData(); return nameFilters().join(QString(d->filterSepChar)); } @@ -2261,7 +2256,7 @@ QString QDir::nameFilter() const */ void QDir::setNameFilter(const QString &nameFilter) { - Q_D(QDir); + QDirPrivate* d = d_ptr.data(); d->initFileEngine(); d->filterSepChar = QDirPrivate::getFilterSepChar(nameFilter); diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h index abfe387..7e5fbac 100644 --- a/src/corelib/io/qdir.h +++ b/src/corelib/io/qdir.h @@ -59,17 +59,6 @@ class Q_CORE_EXPORT QDir { protected: QSharedDataPointer d_ptr; -private: - inline QDirPrivate* d_func() - { - detach(); - return const_cast(d_ptr.constData()); - } - - inline const QDirPrivate* d_func() const - { - return d_ptr.constData(); - } public: enum Filter { Dirs = 0x001, @@ -140,8 +129,6 @@ public: QDir &operator=(const QDir &); QDir &operator=(const QString &path); - void detach(); - void setPath(const QString &path); QString path() const; QString absolutePath() const; -- cgit v0.12 From 7a9f84eb0563355aab76c0b56db44382c516cf35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 19:02:26 +0200 Subject: Another bug-o introduced in fixing QDirPrivate refactoring Must clear file lists when changing the name filters. --- src/corelib/io/qdir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index b355f62..70b00a0 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2258,6 +2258,7 @@ void QDir::setNameFilter(const QString &nameFilter) { QDirPrivate* d = d_ptr.data(); d->initFileEngine(); + d->clearFileLists(); d->filterSepChar = QDirPrivate::getFilterSepChar(nameFilter); d->nameFilters = QDirPrivate::splitFilters(nameFilter, d->filterSepChar); -- cgit v0.12 From c14c0a61bbd8466b00f5600707bc0aedbbf260af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 31 Aug 2010 09:56:27 +0200 Subject: QDir and QFileInfo shouldn't lose properties when detaching For QFileInfo, the caching state was being lost on the different setFile overloads. QDir::cd and ::makeAbsolute were losing filters and sorting flags. QDir issues were introduced with these patches: "Simplify QDir::cd" "QDir::makeAbsolute could self-destruct on failure" Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 41 ++++++++------ src/corelib/io/qfileinfo.cpp | 8 +-- tests/auto/qdir/tst_qdir.cpp | 99 ++++++++++++++++++++++++++++++++++ tests/auto/qfileinfo/tst_qfileinfo.cpp | 48 +++++++++++++++++ 4 files changed, 176 insertions(+), 20 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 70b00a0..7d5c070 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -136,6 +136,19 @@ public: delete fileEngine; } + bool exists() const + { + if (!fileEngine) + return false; + const QAbstractFileEngine::FileFlags info = + fileEngine->fileFlags(QAbstractFileEngine::DirectoryType + | QAbstractFileEngine::ExistsFlag + | QAbstractFileEngine::Refresh); + if (!(info & QAbstractFileEngine::DirectoryType)) + return false; + return info & QAbstractFileEngine::ExistsFlag; + } + void initFileEngine(); void initFileLists() const; @@ -891,11 +904,13 @@ bool QDir::cd(const QString &dirName) } } - QDir dir(newPath); - if (!dir.exists()) + QScopedPointer dir(new QDirPrivate(*d_ptr.constData())); + dir->setPath(newPath); + + if (!dir->exists()) return false; - *this = dir; + d_ptr = dir.take(); return true; } @@ -1495,17 +1510,7 @@ bool QDir::isReadable() const */ bool QDir::exists() const { - const QDirPrivate* d = d_ptr.constData(); - - if (!d->fileEngine) - return false; - const QAbstractFileEngine::FileFlags info = - d->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType - | QAbstractFileEngine::ExistsFlag - | QAbstractFileEngine::Refresh); - if (!(info & QAbstractFileEngine::DirectoryType)) - return false; - return info & QAbstractFileEngine::ExistsFlag; + return d_ptr->exists(); } /*! @@ -1579,11 +1584,13 @@ bool QDir::makeAbsolute() // ### What do the return values signify? if (QDir::isRelativePath(absolutePath)) return false; - QDir dir(absolutePath); - if (!(dir.d_ptr.constData()->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) + QScopedPointer dir(new QDirPrivate(*d_ptr.constData())); + dir->setPath(absolutePath); + + if (!(dir->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) return false; - *this = dir; + d_ptr = dir.take(); return true; } diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 248b83d..7eca212 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -395,7 +395,9 @@ QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo) */ void QFileInfo::setFile(const QString &file) { + bool caching = d_ptr.constData()->cache_enabled; *this = QFileInfo(file); + d_ptr->cache_enabled = caching; } /*! @@ -411,7 +413,7 @@ void QFileInfo::setFile(const QString &file) */ void QFileInfo::setFile(const QFile &file) { - *this = QFileInfo(file.fileName()); + setFile(file.fileName()); } /*! @@ -427,7 +429,7 @@ void QFileInfo::setFile(const QFile &file) */ void QFileInfo::setFile(const QDir &dir, const QString &file) { - *this = QFileInfo(dir.filePath(file)); + setFile(dir.filePath(file)); } /*! @@ -579,7 +581,7 @@ bool QFileInfo::makeAbsolute() QString absFileName = d_ptr.constData()->getFileName(QAbstractFileEngine::AbsoluteName); // QSharedDataPointer::operator->() will detach. - *this = QFileInfo(absFileName); + setFile(absFileName); return true; } diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 661a4c7..9678868 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -173,6 +173,8 @@ private slots: void updateFileLists(); + void detachingOperations(); + #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void isRoot_data(); void isRoot(); @@ -1561,6 +1563,103 @@ void tst_QDir::updateFileLists() QCOMPARE(dir.entryList(), QStringList() << "sub-dir1" << "sub-dir2" << "file1.txt"); } +void tst_QDir::detachingOperations() +{ + QString const defaultPath("."); + QStringList const defaultNameFilters = QStringList("*"); + QDir::SortFlags const defaultSorting = QDir::Name | QDir::IgnoreCase; + QDir::Filters const defaultFilter = QDir::AllEntries; + + QString const path1(".."); + QString const path2("./foo"); + QStringList const nameFilters = QStringList(QString("*.txt")); + QDir::SortFlags const sorting = QDir::Name | QDir::DirsLast | QDir::Reversed; + QDir::Filters const filter = QDir::Writable; + + QDir dir1; + + QCOMPARE(dir1.path(), defaultPath); + QCOMPARE(dir1.filter(), defaultFilter); + QCOMPARE(dir1.nameFilters(), defaultNameFilters); + QCOMPARE(dir1.sorting(), defaultSorting); + + dir1.setPath(path1); + QCOMPARE(dir1.path(), path1); + QCOMPARE(dir1.filter(), defaultFilter); + QCOMPARE(dir1.nameFilters(), defaultNameFilters); + QCOMPARE(dir1.sorting(), defaultSorting); + + dir1.setFilter(filter); + QCOMPARE(dir1.path(), path1); + QCOMPARE(dir1.filter(), filter); + QCOMPARE(dir1.nameFilters(), defaultNameFilters); + QCOMPARE(dir1.sorting(), defaultSorting); + + dir1.setNameFilters(nameFilters); + QCOMPARE(dir1.path(), path1); + QCOMPARE(dir1.filter(), filter); + QCOMPARE(dir1.nameFilters(), nameFilters); + QCOMPARE(dir1.sorting(), defaultSorting); + + dir1.setSorting(sorting); + QCOMPARE(dir1.path(), path1); + QCOMPARE(dir1.filter(), filter); + QCOMPARE(dir1.nameFilters(), nameFilters); + QCOMPARE(dir1.sorting(), sorting); + + dir1.setPath(path2); + QCOMPARE(dir1.path(), path2); + QCOMPARE(dir1.filter(), filter); + QCOMPARE(dir1.nameFilters(), nameFilters); + QCOMPARE(dir1.sorting(), sorting); + + { + QDir dir2(dir1); + QCOMPARE(dir2.path(), path2); + QCOMPARE(dir2.filter(), filter); + QCOMPARE(dir2.nameFilters(), nameFilters); + QCOMPARE(dir2.sorting(), sorting); + } + + { + QDir dir2; + QCOMPARE(dir2.path(), defaultPath); + QCOMPARE(dir2.filter(), defaultFilter); + QCOMPARE(dir2.nameFilters(), defaultNameFilters); + QCOMPARE(dir2.sorting(), defaultSorting); + + dir2 = dir1; + QCOMPARE(dir2.path(), path2); + QCOMPARE(dir2.filter(), filter); + QCOMPARE(dir2.nameFilters(), nameFilters); + QCOMPARE(dir2.sorting(), sorting); + + dir2 = path1; + QCOMPARE(dir2.path(), path1); + QCOMPARE(dir2.filter(), filter); + QCOMPARE(dir2.nameFilters(), nameFilters); + QCOMPARE(dir2.sorting(), sorting); + } + + dir1.refresh(); + QCOMPARE(dir1.path(), path2); + QCOMPARE(dir1.filter(), filter); + QCOMPARE(dir1.nameFilters(), nameFilters); + QCOMPARE(dir1.sorting(), sorting); + + QString const currentPath = QDir::currentPath(); + QVERIFY(dir1.cd(currentPath)); + QCOMPARE(dir1.path(), currentPath); + QCOMPARE(dir1.filter(), filter); + QCOMPARE(dir1.nameFilters(), nameFilters); + QCOMPARE(dir1.sorting(), sorting); + + QVERIFY(dir1.cdUp()); + QCOMPARE(dir1.filter(), filter); + QCOMPARE(dir1.nameFilters(), nameFilters); + QCOMPARE(dir1.sorting(), sorting); +} + #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void tst_QDir::isRoot_data() { diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 32aa671..7659a75 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -181,6 +181,8 @@ private slots: void equalOperator() const; void equalOperatorWithDifferentSlashes() const; void notEqualOperator() const; + + void detachingOperations(); }; tst_QFileInfo::tst_QFileInfo() @@ -1545,5 +1547,51 @@ void tst_QFileInfo::notEqualOperator() const QVERIFY(QFileInfo() != QFileInfo()); } +void tst_QFileInfo::detachingOperations() +{ + QFileInfo info1; + QVERIFY(info1.caching()); + info1.setCaching(false); + + { + QFileInfo info2 = info1; + + QVERIFY(!info1.caching()); + QVERIFY(!info2.caching()); + + info2.setCaching(true); + QVERIFY(info2.caching()); + + info1.setFile("foo"); + QVERIFY(!info1.caching()); + } + + { + QFile file("foo"); + info1.setFile(file); + QVERIFY(!info1.caching()); + } + + info1.setFile(QDir(), "foo"); + QVERIFY(!info1.caching()); + + { + QFileInfo info3; + QVERIFY(info3.caching()); + + info3 = info1; + QVERIFY(!info3.caching()); + } + + info1.refresh(); + QVERIFY(!info1.caching()); + + QVERIFY(info1.makeAbsolute()); + QVERIFY(!info1.caching()); + + info1.detach(); + QVERIFY(!info1.caching()); +} + QTEST_MAIN(tst_QFileInfo) #include "tst_qfileinfo.moc" -- cgit v0.12 From 5e1196c2c98b5331c0ccdbfa2aea26b35fb4a3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 31 Aug 2010 13:17:15 +0200 Subject: QDir: Removed checks for existance of fileEngine Directly or indirectly, all instances of QDir call QDirPrivate::setPath, which allocates a file engine and dereferences it. Any failures there should already lead to a crash or a bad_alloc exception being thrown in case of failure. Given that, QDir may be (and was) broken when compiling Qt with QT_NO_FSFILEENGINE, if no custom file engine and handler are provided. This being the case, it's pointless to check fileEngine for null all over the place. This simplifies the code and should allow for easier transition to file-engine-less implementation. Reviewed-by: Thomas Zander --- src/corelib/io/qdir.cpp | 57 +++++++------------------------------------------ 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 7d5c070..8c99226 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -97,7 +97,6 @@ public: , filterSepChar(0) , matchAllDirs(false) #endif - , fileEngine(0) , fileListsInitialized(false) { setPath(path.isEmpty() ? QString::fromLatin1(".") : path); @@ -126,20 +125,12 @@ public: , filterSepChar(copy.filterSepChar) , matchAllDirs(copy.matchAllDirs) #endif - , fileEngine(0) , fileListsInitialized(false) { } - ~QDirPrivate() - { - delete fileEngine; - } - bool exists() const { - if (!fileEngine) - return false; const QAbstractFileEngine::FileFlags info = fileEngine->fileFlags(QAbstractFileEngine::DirectoryType | QAbstractFileEngine::ExistsFlag @@ -183,8 +174,8 @@ public: p.truncate(p.length() - 1); } - delete fileEngine; - fileEngine = QAbstractFileEngine::create(p); + path = p; + initFileEngine(); // set the path to be the qt friendly version so then we can operate on it using just / path = fileEngine->fileName(QAbstractFileEngine::DefaultName); @@ -207,7 +198,7 @@ public: bool matchAllDirs; #endif - QAbstractFileEngine *fileEngine; + QScopedPointer fileEngine; mutable bool fileListsInitialized; mutable QStringList files; @@ -339,11 +330,9 @@ inline void QDirPrivate::initFileLists() const } } -void QDirPrivate::initFileEngine() +inline void QDirPrivate::initFileEngine() { - QAbstractFileEngine *newFileEngine = QAbstractFileEngine::create(path); - delete fileEngine; - fileEngine = newFileEngine; + fileEngine.reset(QAbstractFileEngine::create(path)); } /*! @@ -646,11 +635,7 @@ QString QDir::absolutePath() const */ QString QDir::canonicalPath() const { - const QDirPrivate* d = d_ptr.constData(); - - if (!d->fileEngine) - return QLatin1String(""); - return cleanPath(d->fileEngine->fileName(QAbstractFileEngine::CanonicalName)); + return cleanPath(d_ptr->fileEngine->fileName(QAbstractFileEngine::CanonicalName)); } /*! @@ -710,8 +695,6 @@ QString QDir::absoluteFilePath(const QString &fileName) const const QDirPrivate* d = d_ptr.constData(); if (isAbsolutePath(fileName)) return fileName; - if (!d->fileEngine) - return fileName; QString ret; #ifndef QT_NO_FSFILEENGINE @@ -1392,8 +1375,6 @@ bool QDir::mkdir(const QString &dirName) const qWarning("QDir::mkdir: Empty or null file name(s)"); return false; } - if (!d->fileEngine) - return false; QString fn = filePath(dirName); return d->fileEngine->mkdir(fn, false); @@ -1416,8 +1397,6 @@ bool QDir::rmdir(const QString &dirName) const qWarning("QDir::rmdir: Empty or null file name(s)"); return false; } - if (!d->fileEngine) - return false; QString fn = filePath(dirName); return d->fileEngine->rmdir(fn, false); @@ -1441,8 +1420,6 @@ bool QDir::mkpath(const QString &dirPath) const qWarning("QDir::mkpath: Empty or null file name(s)"); return false; } - if (!d->fileEngine) - return false; QString fn = filePath(dirPath); return d->fileEngine->mkdir(fn, true); @@ -1467,8 +1444,6 @@ bool QDir::rmpath(const QString &dirPath) const qWarning("QDir::rmpath: Empty or null file name(s)"); return false; } - if (!d->fileEngine) - return false; QString fn = filePath(dirPath); return d->fileEngine->rmdir(fn, true); @@ -1487,8 +1462,6 @@ bool QDir::isReadable() const { const QDirPrivate* d = d_ptr.constData(); - if (!d->fileEngine) - return false; const QAbstractFileEngine::FileFlags info = d->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType | QAbstractFileEngine::PermsMask); @@ -1527,11 +1500,7 @@ bool QDir::exists() const */ bool QDir::isRoot() const { - const QDirPrivate* d = d_ptr.constData(); - - if (!d->fileEngine) - return true; - return d->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag; + return d_ptr->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag; } /*! @@ -1561,11 +1530,7 @@ bool QDir::isRoot() const */ bool QDir::isRelative() const { - const QDirPrivate* d = d_ptr.constData(); - - if (!d->fileEngine) - return false; - return d->fileEngine->isRelativePath(); + return d_ptr->fileEngine->isRelativePath(); } @@ -1578,8 +1543,6 @@ bool QDir::isRelative() const */ bool QDir::makeAbsolute() // ### What do the return values signify? { - if (!d_ptr.constData()->fileEngine) - return false; QString absolutePath = d_ptr.constData()->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); if (QDir::isRelativePath(absolutePath)) return false; @@ -1610,7 +1573,6 @@ bool QDir::operator==(const QDir &dir) const if (d == other) return true; - Q_ASSERT(d->fileEngine && other->fileEngine); if (d->fileEngine->caseSensitive() != other->fileEngine->caseSensitive()) return false; if (d->filters == other->filters @@ -1695,9 +1657,6 @@ bool QDir::rename(const QString &oldName, const QString &newName) return false; } - if (!d_ptr.constData()->fileEngine) - return false; - QFile file(filePath(oldName)); if (!file.exists()) return false; -- cgit v0.12 From d3b152ba1e3cd38dd675c801474105d518bacb44 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 1 Sep 2010 13:33:12 +0200 Subject: Finish canonicalized for all platforms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QFSFileEnginePrivate::canonicalized is now removed and spread out over the qfsfileengine_unix.cpp and qfsfileengine.cpp Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 27 +++++++++++++++-- src/corelib/io/qfilesystemengine_win.cpp | 2 +- src/corelib/io/qfsfileengine.cpp | 50 ------------------------------- src/corelib/io/qfsfileengine_p.h | 1 - src/corelib/io/qfsfileengine_unix.cpp | 17 +++-------- src/corelib/io/qfsfileengine_win.cpp | 15 ++++------ 6 files changed, 35 insertions(+), 77 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 283c787..62fb1b3 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -45,6 +45,10 @@ #include // for realpath() #include +#if defined(Q_OS_MAC) +# include +#endif + QT_BEGIN_NAMESPACE bool QFileSystemEngine::isCaseSensitive() @@ -71,8 +75,27 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) #ifdef __UCLIBC__ return QFileSystemEntry::slowCanonicalName(entry); #else - - char *ret = realpath(entry.nativeFilePath().constData(), (char*)0); + char *ret = 0; +# if defined(Q_OS_MAC) + // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { + ret = realpath(entry.nativeFilePath().constData(), (char*)0); + } else { + // on 10.5 we can use FSRef to resolve the file path. + QString path = QDir::cleanPath(entry.filePath()); + FSRef fsref; + if (FSPathMakeRef((const UInt8 *)path.toUtf8().data(), &fsref, 0) == noErr) { + CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref); + CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle); + QString ret = QCFString::toQString(canonicalPath); + CFRelease(canonicalPath); + CFRelease(urlref); + return QFileSystemEntry(ret); + } + } +# else + ret = realpath(entry.nativeFilePath().constData(), (char*)0); +# endif if (ret) { QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); free(ret); diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 40df120..aa6d2b1 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -57,7 +57,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) //static QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) { - return entry; // TODO implement; + return QFileSystemEntry(slowCanonicalized(entry.filePath())); } //static diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 665d23e..5d7b354 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -134,56 +134,6 @@ void QFSFileEnginePrivate::init() } /*! - \internal - - Returns the canonicalized form of \a path (i.e., with all symlinks - resolved, and all redundant path elements removed. -*/ -QString QFSFileEnginePrivate::canonicalized(const QString &path) -{ - if (path.isEmpty()) - return path; - - // FIXME let's see if this stuff works, then we might be able to remove some of the other code. -#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) - if (path.size() == 1 && path.at(0) == QLatin1Char('/')) - return path; -#endif -#if defined(Q_OS_LINUX) || defined(Q_OS_SYMBIAN) || defined(Q_OS_MAC) - // ... but Linux with uClibc does not have it -#if !defined(__UCLIBC__) - char *ret = 0; -#if defined(Q_OS_MAC) - // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { - ret = realpath(path.toLocal8Bit().constData(), (char*)0); - } else { - // on 10.5 we can use FSRef to resolve the file path. - FSRef fsref; - if (FSPathMakeRef((const UInt8 *)QDir::cleanPath(path).toUtf8().data(), &fsref, 0) == noErr) { - CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref); - CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle); - QString ret = QCFString::toQString(canonicalPath); - CFRelease(canonicalPath); - CFRelease(urlref); - return ret; - } - } -#else - ret = realpath(path.toLocal8Bit().constData(), (char*)0); -#endif - if (ret) { - QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); - free(ret); - return canonicalPath; - } -#endif -#endif - - return QFileSystemEngine::slowCanonicalized(path); -} - -/*! Constructs a QFSFileEngine for the file name \a file. */ QFSFileEngine::QFSFileEngine(const QString &file) diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 74cbca3..9eaf6fd 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -75,7 +75,6 @@ public: #ifdef Q_WS_WIN static QString longFileName(const QString &path); #endif - static QString canonicalized(const QString &path); QFileSystemEntry fileEntry; QIODevice::OpenMode openMode; diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 29491f5..0b73a7b 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -963,19 +963,10 @@ QString QFSFileEngine::fileName(FileName file) const } return ret; } else if(file == CanonicalName || file == CanonicalPathName) { - if (!(fileFlags(ExistsFlag) & ExistsFlag)) - return QString(); - - QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName)); - if (file == CanonicalPathName && !ret.isEmpty()) { - int slash = ret.lastIndexOf(slashChar); - if (slash == -1) - ret = QDir::fromNativeSeparators(QDir::currentPath()); - else if (slash == 0) - ret = QLatin1String("/"); - ret = ret.left(slash); - } - return ret; + QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry)); + if (file == CanonicalPathName) + return entry.path(); + return entry.filePath(); } else if(file == LinkName) { if (d->isSymlink()) { char s[PATH_MAX+1]; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 9f33af5..bc88776 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -43,6 +43,7 @@ #include "qplatformdefs.h" #include "qabstractfileengine.h" #include "private/qfsfileengine_p.h" +#include "qfilesystemengine_p.h" #include #include "qfile.h" @@ -1620,17 +1621,11 @@ QString QFSFileEngine::fileName(FileName file) const } else if (file == CanonicalName || file == CanonicalPathName) { if (!(fileFlags(ExistsFlag) & ExistsFlag)) return QString(); + QFileSystemEngine entry(QFileSystemEngine::slowCanonicalized(fileName(AbsoluteName))); - QString ret = QFSFileEnginePrivate::canonicalized(fileName(AbsoluteName)); - if (!ret.isEmpty() && file == CanonicalPathName) { - int slash = ret.lastIndexOf(QLatin1Char('/')); - if (slash == -1) - ret = QDir::currentPath(); - else if (slash == 0) - ret = QString(QLatin1Char('/')); - ret = ret.left(slash); - } - return ret; + if (file == CanonicalPathName) + return entry.path(); + return entry.filePath(); } else if (file == LinkName) { QString ret; if (d->fileEntry.filePath().endsWith(QLatin1String(".lnk"))) -- cgit v0.12 From 88ae6dc40e6f725a3dc15056a0b9e8f00d727c09 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 1 Sep 2010 12:53:04 +0200 Subject: Breaking changes to QFileSystemEntry's constructors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we are using a QString for the native file path on windows, the constructors we had on other platforms didn't make sense: we can't have two constructors taking a single QString parameter, and it would be error prone to have the two argument constructor (taking two QString parameters, on Windows) change the meaning of the first argument. This patch introduces a typedef for the NativePath type being used; the constructor taking the native path now requires a dummy parameter that makes the intent expliciti; and the order of the arguments on the constructor taking both native and Qt paths had the order switched. Done-with: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 4 +-- src/corelib/io/qfilesystementry.cpp | 12 +++------ src/corelib/io/qfilesystementry_p.h | 30 ++++++++++------------ src/corelib/io/qtemporaryfile.cpp | 2 +- .../auto/qfilesystementry/tst_qfilesystementry.cpp | 2 +- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 62fb1b3..b7fe8e0 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -126,14 +126,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) } if (result.length() == 1 && result[0] == '/') - return QFileSystemEntry(result); + return QFileSystemEntry(result, QFileSystemEntry::FromNativePath()); const bool isDir = result.endsWith('/'); /* as long as QDir::cleanPath() operates on a QString we have to convert to a string here. * ideally we never convert to a string since that loses information. Please fix after * we get a QByteArray version of QDir::cleanPath() */ - QFileSystemEntry resultingEntry(result); + QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath()); QString stringVersion = QDir::cleanPath(resultingEntry.filePath()); if (isDir) stringVersion.append(QLatin1Char('/')); diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index a32e22f..c3ada48 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -89,8 +89,7 @@ QFileSystemEntry::QFileSystemEntry(const QString &filePath) { } -#ifndef Q_OS_WIN -QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath) +QFileSystemEntry::QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath /* dummy */) : m_nativeFilePath(nativeFilePath), m_lastSeparator(-2), m_firstDotInFileName(-2), @@ -98,7 +97,7 @@ QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath) { } -QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath, const QString &filePath) +QFileSystemEntry::QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath) : m_filePath(filePath), m_nativeFilePath(nativeFilePath), m_lastSeparator(-2), @@ -106,7 +105,6 @@ QFileSystemEntry::QFileSystemEntry(const QByteArray &nativeFilePath, const QStri m_lastDotInFileName(0) { } -#endif QString QFileSystemEntry::filePath() const { @@ -114,11 +112,7 @@ QString QFileSystemEntry::filePath() const return m_filePath; } -#ifndef Q_OS_WIN -QByteArray QFileSystemEntry::nativeFilePath() const -#else -QString QFileSystemEntry::nativeFilePath() const -#endif +QFileSystemEntry::NativePath QFileSystemEntry::nativeFilePath() const { resolveNativeFilePath(); return m_nativeFilePath; diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 3e49f2c..3786bb3 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -61,21 +61,24 @@ QT_BEGIN_NAMESPACE class QFileSystemEntry { public: - QFileSystemEntry(); - explicit QFileSystemEntry(const QString &filePath); + #ifndef Q_OS_WIN - explicit QFileSystemEntry(const QByteArray &nativeFilePath); - QFileSystemEntry(const QByteArray &nativeFilePath, const QString &filePath); + typedef QByteArray NativePath; +#else + typedef QString NativePath; #endif + struct FromNativePath{}; + + QFileSystemEntry(); + explicit QFileSystemEntry(const QString &filePath); + + QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath dummy); + QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath); QString filePath() const; QString fileName() const; QString path() const; -#ifndef Q_OS_WIN - QByteArray nativeFilePath() const; -#else - QString nativeFilePath() const; -#endif + NativePath nativeFilePath() const; QString suffix() const; QString completeSuffix() const; bool isAbsolute() const; @@ -101,16 +104,11 @@ private: void resolveNativeFilePath() const; // resolves the separator void findLastSeparator() const; - /// resolves the dots and the separator + // resolves the dots and the separator void findFileNameSeparators() const; mutable QString m_filePath; // always has slashes as separator - -#ifdef Q_OS_WIN - mutable QString m_nativeFilePath; // native encoding and separators -#else - mutable QByteArray m_nativeFilePath; // native encoding and separators -#endif + mutable NativePath m_nativeFilePath; // native encoding and separators mutable qint16 m_lastSeparator; // index in m_filePath of last separator mutable qint16 m_firstDotInFileName; // index after m_filePath for first dot (.) diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index a0d3176..479ea20 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -377,7 +377,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) d->closeFileHandle = true; // Restore the file names (open() resets them). - d->fileEntry = QFileSystemEntry(QByteArray(filename)); //changed now! + d->fileEntry = QFileSystemEntry(QByteArray(filename), QFileSystemEntry::FromNativePath()); //changed now! filePathIsTemplate = false; delete [] filename; return true; diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 58b7c6f..35389b4 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -140,7 +140,7 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry1.isAbsolute(), absolute); QCOMPARE(entry1.isRelative(), !absolute); - QFileSystemEntry entry2(nativeFilePath); + QFileSystemEntry entry2(nativeFilePath, QFileSystemEntry::FromNativePath()); QCOMPARE(entry2.suffix(), suffix); QCOMPARE(entry2.completeSuffix(), completeSuffix); QCOMPARE(entry2.isAbsolute(), absolute); -- cgit v0.12 From a543c044234f2854a53f9a659e9004f4aa536bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 30 Aug 2010 13:58:26 +0200 Subject: Expanding the stub QFileSystemMetaData Renamed FileFlags to MetaDataFlags. Added barebones structure and enum values to be shared across different implementations, with placeholders for platform-specific #includes and data members. Reviewed-by: Thomas Zander --- src/corelib/io/qfilesystemengine_mac.cpp | 2 +- src/corelib/io/qfilesystemengine_p.h | 2 +- src/corelib/io/qfilesystemengine_unix.cpp | 2 +- src/corelib/io/qfilesystemengine_win.cpp | 2 +- src/corelib/io/qfilesystemmetadata_p.h | 75 +++++++++++++++++++++++++++++-- 5 files changed, 75 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_mac.cpp b/src/corelib/io/qfilesystemengine_mac.cpp index 942415c..c915a2c 100644 --- a/src/corelib/io/qfilesystemengine_mac.cpp +++ b/src/corelib/io/qfilesystemengine_mac.cpp @@ -73,7 +73,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) } //static -bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::FileFlags what) +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { return false; // TODO implement; } diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 61ca085..982b782 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -71,7 +71,7 @@ public: static QString bundleName(const QFileSystemEntry &entry); static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, - QFileSystemMetaData::FileFlags what); + QFileSystemMetaData::MetaDataFlags what); static bool createDirectory(const QFileSystemEntry &entry, bool createParents); static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents); diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index b7fe8e0..d4759c8 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -147,7 +147,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) } //static -bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::FileFlags what) +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { return false; // TODO implement; } diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index aa6d2b1..dd6467a 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -73,7 +73,7 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) } //static -bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::FileFlags what) +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { return false; // TODO implement; } diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 9664177..40bad9e 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -55,14 +55,81 @@ #include +// Platform-specific includes +#if defined(Q_OS_WIN) +#else +#endif + QT_BEGIN_NAMESPACE -class QFileSystemMetaData +class QFileSystemEngine; + +struct QFileSystemMetaData { -public: - enum FileFlag { + QFileSystemMetaData() + : cachedFlags(0) + { + } + + enum MetaDataFlag { + // Permissions, overlaps with QFile::Permissions + OtherReadPermission = 0x00000004, OtherWritePermission = 0x00000002, OtherExecutePermission = 0x00000001, + GroupReadPermission = 0x00000040, GroupWritePermission = 0x00000020, GroupExecutePermission = 0x00000010, + UserReadPermission = 0x00000400, UserWritePermission = 0x00000200, UserExecutePermission = 0x00000100, + OwnerReadPermission = 0x00004000, OwnerWritePermission = 0x00002000, OwnerExecutePermission = 0x00001000, + + OtherPermissions = 0x0000000F, + GroupPermissions = 0x000000F0, + UserPermissions = 0x00000F00, + OwnerPermissions = 0x0000F000, + + Permissions = 0x0000FFFF, + + // Type + LinkType = 0x00010000, + FileType = 0x00020000, + DirectoryType = 0x00040000, + BundleType = 0x00080000, + + Type = 0x000F0000, + + // Attributes + HiddenAttribute = 0x00100000, + LocalDiskAttribute = 0x00200000, + ExistsAttribute = 0x00400000, + SizeAttribute = 0x00800000, // Note: overlaps with QAbstractFileEngine::RootFlag + + Attributes = 0x00F00000, + + // Times + CreationTime = 0x01000000, // Note: overlaps with QAbstractFileEngine::Refresh + ModificationTime = 0x02000000, + AccessTime = 0x04000000, + + Times = 0x07000000 }; - Q_DECLARE_FLAGS(FileFlags, FileFlag); + Q_DECLARE_FLAGS(MetaDataFlags, MetaDataFlag) + + bool hasFlags(MetaDataFlags flags) const + { + return ((cachedFlags & flags) == flags); + } + + void clear() + { + cachedFlags = 0; + } + +private: + friend class QFileSystemEngine; + + MetaDataFlags cachedFlags; + + // Platform-specific data goes here: +#if defined(Q_OS_WIN) +#else +#endif + }; QT_END_NAMESPACE -- cgit v0.12 From 9e31072524f496493c9b9b799c4f9520f77cf7c5 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 1 Sep 2010 14:59:43 +0200 Subject: Make QFileSystemEngine::slowCanonicalized private --- src/corelib/io/qfilesystemengine_p.h | 1 + src/corelib/io/qfsfileengine_win.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 982b782..f50701e 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -85,6 +85,7 @@ public: static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data = 0); +private: static QString slowCanonicalized(const QString &path); }; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index bc88776..7262129 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1621,7 +1621,7 @@ QString QFSFileEngine::fileName(FileName file) const } else if (file == CanonicalName || file == CanonicalPathName) { if (!(fileFlags(ExistsFlag) & ExistsFlag)) return QString(); - QFileSystemEngine entry(QFileSystemEngine::slowCanonicalized(fileName(AbsoluteName))); + QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry)); if (file == CanonicalPathName) return entry.path(); -- cgit v0.12 From 111886749d2cc6a94de382e454916446052dd355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 1 Sep 2010 14:59:59 +0200 Subject: QFileSystemIterator: added destructor and placeholder for data Reviewed-by: Prasanth Ullattil --- src/corelib/io/qfilesystemiterator_p.h | 7 +++++++ src/corelib/io/qfilesystemiterator_unix.cpp | 4 ++++ src/corelib/io/qfilesystemiterator_win.cpp | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h index 436ff7e..21ad70a 100644 --- a/src/corelib/io/qfilesystemiterator_p.h +++ b/src/corelib/io/qfilesystemiterator_p.h @@ -66,10 +66,17 @@ class QFileSystemIterator { public: QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters); + ~QFileSystemIterator(); bool advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData); private: + + // Platform-specific data +#if defined(Q_OS_WIN) +#else +#endif + Q_DISABLE_COPY(QFileSystemIterator) }; diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp index 3ee344b..1a6bf87 100644 --- a/src/corelib/io/qfilesystemiterator_unix.cpp +++ b/src/corelib/io/qfilesystemiterator_unix.cpp @@ -51,6 +51,10 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi Q_UNUSED(nameFilters) } +QFileSystemIterator::~QFileSystemIterator() +{ +} + bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) { Q_UNUSED(fileEntry) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 3ee344b..1a6bf87 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -51,6 +51,10 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi Q_UNUSED(nameFilters) } +QFileSystemIterator::~QFileSystemIterator() +{ +} + bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) { Q_UNUSED(fileEntry) -- cgit v0.12 From f6e118d7ec781a97e8648145d4dfdb40516b13b4 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 1 Sep 2010 16:21:14 +0200 Subject: Fix tst_QFileSystemEntry auto tests on windows While resolving the native path, Windows implementation saves it as long absolute path. The tests are updated for this. This patch also splits the windows & unix code paths. Reviewed-by: Joao --- .../auto/qfilesystementry/tst_qfilesystementry.cpp | 112 +++++++++++++++------ 1 file changed, 83 insertions(+), 29 deletions(-) diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 35389b4..f4def8d 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -58,68 +58,121 @@ private slots: void getSetCheck(); }; +#if defined(WIN_STUFF) void tst_QFileSystemEntry::getSetCheck_data() { - QTest::addColumn("nativeFilePath"); + QTest::addColumn("nativeFilePath"); + QTest::addColumn("internalnativeFilePath"); QTest::addColumn("filepath"); QTest::addColumn("filename"); QTest::addColumn("suffix"); QTest::addColumn("completeSuffix"); QTest::addColumn("absolute"); + QString absPrefix = QLatin1String("\\\\?\\"); + QString relPrefix = absPrefix + + QDir::toNativeSeparators(QDir::currentPath()) + + QLatin1String("\\"); + QTest::newRow("simple") -#if defined(WIN_STUFF) - << QByteArray("A:\\home\\qt\\in\\a\\dir.tar.gz") - << "A:/home/qt/in/a/dir.tar.gz" + << QString("A:\\home\\qt\\in\\a\\dir.tar.gz") + << absPrefix + QString("A:\\home\\qt\\in\\a\\dir.tar.gz") + << "A:/home/qt/in/a/dir.tar.gz" + << "dir.tar.gz" << "gz" << "tar.gz" << true; + + QTest::newRow("relative") + << QString("in\\a\\dir.tar.gz") + << relPrefix + QString("in\\a\\dir.tar.gz") + << "in/a/dir.tar.gz" + << "dir.tar.gz" << "gz" << "tar.gz" << false; + + QTest::newRow("noSuffix") + << QString("myDir\\myfile") + << relPrefix + QString("myDir\\myfile") + << "myDir/myfile" << "myfile" << "" << "" << false; + + QTest::newRow("noLongSuffix") + << QString("myDir\\myfile.txt") + << relPrefix + QString("myDir\\myfile.txt") + << "myDir/myfile.txt" << "myfile.txt" << "txt" << "txt" << false; + + QTest::newRow("endingSlash") + << QString("myDir\\myfile.bla\\") + << relPrefix + QString("myDir\\myfile.bla\\") + << "myDir/myfile.bla/" << "" << "" << "" << false; + + QTest::newRow("absolutePath") + << QString("A:dir\\without\\leading\\backslash.bat") + << absPrefix + QString("A:\\dir\\without\\leading\\backslash.bat") + << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << true; +} + +void tst_QFileSystemEntry::getSetCheck() +{ + QFETCH(QString, nativeFilePath); + QFETCH(QString, internalnativeFilePath); + QFETCH(QString, filepath); + QFETCH(QString, filename); + QFETCH(QString, suffix); + QFETCH(QString, completeSuffix); + QFETCH(bool, absolute); + + QFileSystemEntry entry1(filepath); + QCOMPARE(entry1.filePath(), filepath); + QCOMPARE(entry1.nativeFilePath().toLower(), internalnativeFilePath.toLower()); + QCOMPARE(entry1.fileName(), filename); + QCOMPARE(entry1.suffix(), suffix); + QCOMPARE(entry1.completeSuffix(), completeSuffix); + QCOMPARE(entry1.isAbsolute(), absolute); + QCOMPARE(entry1.isRelative(), !absolute); + + QFileSystemEntry entry2(nativeFilePath, QFileSystemEntry::FromNativePath()); + QCOMPARE(entry2.suffix(), suffix); + QCOMPARE(entry2.completeSuffix(), completeSuffix); + QCOMPARE(entry2.isAbsolute(), absolute); + QCOMPARE(entry2.isRelative(), !absolute); + QCOMPARE(entry2.filePath(), filepath); + // This is entry was created using the native file path, + // so it should use that without any changes. + QCOMPARE(entry2.nativeFilePath(), nativeFilePath); + QCOMPARE(entry2.fileName(), filename); +} + #else + +void tst_QFileSystemEntry::getSetCheck_data() +{ + QTest::addColumn("nativeFilePath"); + QTest::addColumn("filepath"); + QTest::addColumn("filename"); + QTest::addColumn("suffix"); + QTest::addColumn("completeSuffix"); + QTest::addColumn("absolute"); + + QTest::newRow("simple") << QByteArray("/home/qt/in/a/dir.tar.gz") << "/home/qt/in/a/dir.tar.gz" -#endif << "dir.tar.gz" << "gz" << "tar.gz" << true; - QTest::newRow("relative") -#if defined(WIN_STUFF) - << QByteArray("in\\a\\dir.tar.gz") - << "in/a/dir.tar.gz" -#else << QByteArray("in/a/dir.tar.gz") << "in/a/dir.tar.gz" -#endif << "dir.tar.gz" << "gz" << "tar.gz" << false; QTest::newRow("noSuffix") -#if defined(WIN_STUFF) - << QByteArray("myDir\\myfile") -#else << QByteArray("myDir/myfile") -#endif << "myDir/myfile" << "myfile" << "" << "" << false; QTest::newRow("noLongSuffix") -#if defined(WIN_STUFF) - << QByteArray("myDir\\myfile.txt") -#else << QByteArray("myDir/myfile.txt") -#endif << "myDir/myfile.txt" << "myfile.txt" << "txt" << "txt" << false; QTest::newRow("endingSlash") -#if defined(WIN_STUFF) - << QByteArray("myDir\\myfile.bla\\") -#else << QByteArray("myDir/myfile.bla/") -#endif << "myDir/myfile.bla/" << "" << "" << "" << false; -#if defined(WIN_STUFF) - QTest::newRow("absolutePath") - << QByteArray("A:dir\\without\\leading\\backslash.bat") - << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << true; -#else QTest::newRow("relativePath") << QByteArray("A:dir/without/leading/backslash.bat") << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << false; -#endif } void tst_QFileSystemEntry::getSetCheck() @@ -149,6 +202,7 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry2.nativeFilePath(), nativeFilePath); QCOMPARE(entry2.fileName(), filename); } +#endif QTEST_MAIN(tst_QFileSystemEntry) #include -- cgit v0.12 From 34d8b4f0fa7f039504b62f2bbf84668f5345b643 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 1 Sep 2010 16:25:43 +0200 Subject: Updated comment in tst_QFileSystemEntry autotest --- tests/auto/qfilesystementry/tst_qfilesystementry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index f4def8d..5194c02 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -132,8 +132,8 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry2.isAbsolute(), absolute); QCOMPARE(entry2.isRelative(), !absolute); QCOMPARE(entry2.filePath(), filepath); - // This is entry was created using the native file path, - // so it should use that without any changes. + // Since this entry was created using the native path, + // the object shouldnot change nativeFilePath. QCOMPARE(entry2.nativeFilePath(), nativeFilePath); QCOMPARE(entry2.fileName(), filename); } -- cgit v0.12 From c7784c70b865792a5f09fc83e9a50cc327864a22 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 3 Sep 2010 09:35:45 +0200 Subject: Implement bundleName() in QFileSystemEngine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the code from the qfsfileengine_unix.cpp to the new place and make the old place just call the new one. Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 12 +++++++++++- src/corelib/io/qfilesystemengine_win.cpp | 2 +- src/corelib/io/qfsfileengine_unix.cpp | 12 +----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index d4759c8..4b1932d 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -143,7 +143,17 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) //static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { - return QString(); // TODO implement; +#if !defined(QWS) && defined(Q_OS_MAC) + QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(entry.filePath()), + kCFURLPOSIXPathStyle, true); + if (QCFType dict = CFBundleCopyInfoDictionaryForURL(url)) { + if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) { + if (CFGetTypeID(name) == CFStringGetTypeID()) + return QCFString::toQString((CFStringRef)name); + } + } +#endif + return QString(); } //static diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index dd6467a..ef47fe5 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -69,7 +69,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) //static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { - return QString(); // TODO implement; + return QString(); } //static diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 0b73a7b..9ca195b 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -1002,17 +1002,7 @@ QString QFSFileEngine::fileName(FileName file) const { Q_D(const QFSFileEngine); if (file == BundleName) { -#if !defined(QWS) && defined(Q_OS_MAC) - QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(d->fileEntry.filePath()), - kCFURLPOSIXPathStyle, true); - if (QCFType dict = CFBundleCopyInfoDictionaryForURL(url)) { - if (CFTypeRef name = (CFTypeRef)CFDictionaryGetValue(dict, kCFBundleNameKey)) { - if (CFGetTypeID(name) == CFStringGetTypeID()) - return QCFString::toQString((CFStringRef)name); - } - } -#endif - return QString(); + return QFileSystemEngine::bundleName(d->fileEntry); } else if (file == BaseName) { return d->fileEntry.fileName(); } else if (file == PathName) { -- cgit v0.12 From e6747da757b4daba1fc17db9902a9c39b426455f Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 3 Sep 2010 09:37:14 +0200 Subject: Move mkdir code to createDirectory for unix' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit migrate the QFSFileEngine::mkdir code to QFileSystemEngine::createDirectory and make the former call the latter. Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 33 ++++++++++++++++++++++++++++++- src/corelib/io/qfsfileengine_unix.cpp | 32 +----------------------------- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 4b1932d..469abfe 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qfilesystemengine_p.h" +#include "qplatformdefs.h" #include "qfsfileengine.h" #include // for realpath() @@ -165,7 +166,37 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM //static bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents) { - return false; // TODO implement; + QString dirName = entry.filePath(); + if (createParents) { + dirName = QDir::cleanPath(dirName); +#if defined(Q_OS_SYMBIAN) + dirName = QDir::toNativeSeparators(dirName); +#endif + for (int oldslash = -1, slash=0; slash != -1; oldslash = slash) { + slash = dirName.indexOf(QDir::separator(), oldslash+1); + if (slash == -1) { + if (oldslash == dirName.length()) + break; + slash = dirName.length(); + } + if (slash) { + QByteArray chunk = QFile::encodeName(dirName.left(slash)); + QT_STATBUF st; + if (QT_STAT(chunk, &st) != -1) { + if ((st.st_mode & S_IFMT) != S_IFDIR) + return false; + } else if (QT_MKDIR(chunk, 0777) != 0) { + return false; + } + } + } + return true; + } +#if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s + if (dirName.endsWith(QLatin1Char('/'))) + dirName.chop(1); +#endif + return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0); } //static diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 9ca195b..c20d6ae 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -492,37 +492,7 @@ qint64 QFSFileEnginePrivate::nativeSize() const bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const { - QString dirName = name; - if (createParentDirectories) { - dirName = QDir::cleanPath(dirName); -#if defined(Q_OS_SYMBIAN) - dirName = QDir::toNativeSeparators(dirName); -#endif - for(int oldslash = -1, slash=0; slash != -1; oldslash = slash) { - slash = dirName.indexOf(QDir::separator(), oldslash+1); - if (slash == -1) { - if (oldslash == dirName.length()) - break; - slash = dirName.length(); - } - if (slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); - QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { - if ((st.st_mode & S_IFMT) != S_IFDIR) - return false; - } else if (QT_MKDIR(chunk, 0777) != 0) { - return false; - } - } - } - return true; - } -#if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s - if (dirName.endsWith(QLatin1Char('/'))) - dirName.chop(1); -#endif - return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0); + return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories); } bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const -- cgit v0.12 From 5b76ea63f5dba0a6b427d9d4dbcb7be6d7afeeec Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 3 Sep 2010 09:37:43 +0200 Subject: Move rmdir code to createDirectory for unix' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit migrate the QFSFileEngine::rmdir code to QFileSystemEngine::removeDirectory and make the former call the latter. Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 22 +++++++++++++++++++++- src/corelib/io/qfsfileengine_unix.cpp | 23 +---------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 469abfe..7c72782 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -202,7 +202,27 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea //static bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents) { - return false; // TODO implement; + if (removeEmptyParents) { + QString dirName = QDir::cleanPath(entry.filePath()); +#if defined(Q_OS_SYMBIAN) + dirName = QDir::toNativeSeparators(dirName); +#endif + for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { + QByteArray chunk = QFile::encodeName(dirName.left(slash)); + QT_STATBUF st; + if (QT_STAT(chunk, &st) != -1) { + if ((st.st_mode & S_IFMT) != S_IFDIR) + return false; + if (::rmdir(chunk) != 0) + return oldslash != 0; + } else { + return false; + } + slash = dirName.lastIndexOf(QDir::separator(), oldslash-1); + } + return true; + } + return rmdir(QFile::encodeName(entry.filePath())) == 0; } //static diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index c20d6ae..50b18fc 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -497,28 +497,7 @@ bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) con bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const { - QString dirName = name; - if (recurseParentDirectories) { - dirName = QDir::cleanPath(dirName); -#if defined(Q_OS_SYMBIAN) - dirName = QDir::toNativeSeparators(dirName); -#endif - for(int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); - QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { - if ((st.st_mode & S_IFMT) != S_IFDIR) - return false; - if (::rmdir(chunk) != 0) - return oldslash != 0; - } else { - return false; - } - slash = dirName.lastIndexOf(QDir::separator(), oldslash-1); - } - return true; - } - return ::rmdir(QFile::encodeName(dirName)) == 0; + return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories); } bool QFSFileEngine::caseSensitive() const -- cgit v0.12 From 33634cd85233b75d8c24ef8ed67ff054d709b6e9 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 3 Sep 2010 19:04:12 +0100 Subject: Port over QFileSystemIterator for Symbian OS Also added the QDirIterator::IteratorFlags iteratorFlags as a parameter for QFileSystemIterator, as it impacts what kind of filtering we can do via the OS. i.e. filename filtering isn't compatible with recursive iteration. Reviewed-By: joao --- src/corelib/io/qfilesystemiterator_p.h | 15 ++- src/corelib/io/qfilesystemiterator_symbian.cpp | 134 +++++++++++++++++++++++++ src/corelib/io/qfilesystemiterator_unix.cpp | 3 +- src/corelib/io/qfilesystemiterator_win.cpp | 3 +- 4 files changed, 152 insertions(+), 3 deletions(-) create mode 100644 src/corelib/io/qfilesystemiterator_symbian.cpp diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h index 21ad70a..ed1ef5e 100644 --- a/src/corelib/io/qfilesystemiterator_p.h +++ b/src/corelib/io/qfilesystemiterator_p.h @@ -55,17 +55,25 @@ #include #include +#include #include #include #include +// Platform-specific headers +#if defined(Q_OS_WIN) +#elif defined (Q_OS_SYMBIAN) +#include +#else +#endif + QT_BEGIN_NAMESPACE class QFileSystemIterator { public: - QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters); + QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters, QDirIterator::IteratorFlags flags); ~QFileSystemIterator(); bool advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData); @@ -74,6 +82,11 @@ private: // Platform-specific data #if defined(Q_OS_WIN) +#elif defined (Q_OS_SYMBIAN) + RDir dirHandle; + TEntryArray entries; + TInt lastError; + TInt entryIndex; #else #endif diff --git a/src/corelib/io/qfilesystemiterator_symbian.cpp b/src/corelib/io/qfilesystemiterator_symbian.cpp new file mode 100644 index 0000000..9093599 --- /dev/null +++ b/src/corelib/io/qfilesystemiterator_symbian.cpp @@ -0,0 +1,134 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfilesystemiterator_p.h" +#include "qfilesystemengine_p.h" +#include "qcore_symbian_p.h" + +QT_BEGIN_NAMESPACE + +QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &path, QDir::Filters filters, + const QStringList &nameFilters, QDirIterator::IteratorFlags iteratorFlags) + : lastError(KErrNone), entryIndex(-1) +{ + RFs& fs = qt_s60GetRFs(); + + TFileName symbianPath; + QString abspath = QFileSystemEngine::absoluteName(path).nativeFilePath(); + + if (!abspath.endsWith(QLatin1Char('\\'))) + abspath.append(QLatin1Char('\\')); + + int pathLen = abspath.length(); + if (pathLen > symbianPath.MaxLength()) { + lastError = KErrBadName; + return; + } + symbianPath.Copy(qt_QString2TPtrC(abspath)); + + //set up server side filtering to reduce IPCs + //RDir won't accept all valid name filters e.g. "*. bar" + if (nameFilters.count() == 1 && !(filters & QDir::AllDirs) && iteratorFlags + == QDirIterator::NoIteratorFlags && pathLen + nameFilters[0].length() + <= symbianPath.MaxLength()) { + //server side supports one mask - skip this for recursive mode or if only files should be filtered + symbianPath.Append(qt_QString2TPtrC(nameFilters[0])); + } + + TUint symbianMask = 0; + if ((filters & QDir::Dirs) || (filters & QDir::AllDirs) || (iteratorFlags + & QDirIterator::Subdirectories)) + symbianMask |= KEntryAttDir; //include directories + if (filters & QDir::Hidden) + symbianMask |= KEntryAttHidden; + if (filters & QDir::System) + symbianMask |= KEntryAttSystem; + if (((filters & QDir::Files) == 0) && symbianMask == KEntryAttDir) + symbianMask |= KEntryAttMatchExclusive; //exclude non-directories + else if (symbianMask == 0) { + if ((filters & QDir::PermissionMask) == QDir::Writable) + symbianMask = KEntryAttMatchExclude | KEntryAttReadOnly; + else if ((filters & QDir::PermissionMask) == QDir::Readable) + symbianMask = KEntryAttMatchExclusive | KEntryAttReadOnly; + } + + lastError = dirHandle.Open(fs, symbianPath, symbianMask); +} + +QFileSystemIterator::~QFileSystemIterator() +{ + dirHandle.Close(); +} + +static void createFileSystemMetaDataHelper(const TEntry &entry, QFileSystemMetaData &metaData) +{ + //placeholder + //TODO: adapt from QFileInfoPrivate::fromTEntry(entries[entryIndex], path()); + //or add this functionality to QFileSystemMetaData +} + +bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) +{ + //1st time, lastError is result of dirHandle.Open(), entries.Count() is 0 and entryIndex is -1 so initial read is triggered + //subsequent times, read is triggered each time we reach the end of the entry list + //final time, lastError is KErrEof so we don't need to read anymore. + ++entryIndex; + if (lastError == KErrNone && entryIndex >= entries.Count()) { + lastError = dirHandle.Read(entries); + entryIndex = 0; + } + + //each call to advance() gets the next entry from the entry list. + //from the final (or only) read call, KErrEof is returned together with a full buffer so we still need to go through the list + if ((lastError == KErrNone || lastError == KErrEof) && entryIndex < entries.Count()) { + Q_ASSERT(entryIndex >= 0); + const TEntry &entry(entries[entryIndex]); + fileEntry = QFileSystemEntry(qt_TDesC2QString(entry.iName), QFileSystemEntry::FromNativePath()); + createFileSystemMetaDataHelper(entry, metaData); + return true; + } + + //TODO: error reporting, to allow user to distinguish empty directory from error condition. + + return false; +} + +QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp index 1a6bf87..3c73496 100644 --- a/src/corelib/io/qfilesystemiterator_unix.cpp +++ b/src/corelib/io/qfilesystemiterator_unix.cpp @@ -44,11 +44,12 @@ QT_BEGIN_NAMESPACE QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, - const QStringList &nameFilters) + const QStringList &nameFilters, QDirIterator::IteratorFlags flags) { Q_UNUSED(entry) Q_UNUSED(filters) Q_UNUSED(nameFilters) + Q_UNUSED(flags) } QFileSystemIterator::~QFileSystemIterator() diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 1a6bf87..3c73496 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -44,11 +44,12 @@ QT_BEGIN_NAMESPACE QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, - const QStringList &nameFilters) + const QStringList &nameFilters, QDirIterator::IteratorFlags flags) { Q_UNUSED(entry) Q_UNUSED(filters) Q_UNUSED(nameFilters) + Q_UNUSED(flags) } QFileSystemIterator::~QFileSystemIterator() -- cgit v0.12 From 00bcd42c9ec6cb723fdccb08bb969eef0e5f1f0f Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 3 Sep 2010 19:17:46 +0100 Subject: Implementation of QFileSystemEngine for Symbian OS Code comes from QFile, QDir and QFileInfo in the native IO branch Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 213 +++++++++++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 src/corelib/io/qfilesystemengine_symbian.cpp diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp new file mode 100644 index 0000000..2798bdf --- /dev/null +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qfilesystemengine_p.h" +#include "qfsfileengine.h" +#include "qcore_symbian_p.h" + +#include + +QT_BEGIN_NAMESPACE + +bool QFileSystemEngine::isCaseSensitive() +{ + return false; +} + +//static +QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) +{ + return link; // TODO implement +} + +//static +QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) +{ + if (entry.isEmpty() || entry.isRoot()) + return entry; + + QFileSystemEntry result = absoluteName(entry); + RFs& fs(qt_s60GetRFs()); + TUint e; + //Att is faster than Entry for determining if a file exists, due to smaller IPC + TInt r = fs.Att(qt_QString2TPtrC(result.nativeFilePath()), e); + + if (r == KErrNone) { + return result; + } else { // file doesn't exist + return QFileSystemEntry(); + } +} + +//static +QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) +{ + if (entry.isAbsolute()) + return entry; + + QString orig = entry.filePath(); + QString result; + if (orig.isEmpty() || !orig.startsWith('/')) { + QFileSystemEntry cur(QFSFileEngine::currentPath()); + result = cur.filePath(); + } + if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) { + if (!result.isEmpty() && !result.endsWith('/')) + result.append('/'); + result.append(orig); + } + + if (result.length() == 1 && result[0] == '/') + return QFileSystemEntry(result); + const bool isDir = result.endsWith('/'); + + result = QDir::cleanPath(result); + if (isDir) + result.append(QLatin1Char('/')); + return QFileSystemEntry(result); +} + +//static +QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) +{ + return QString(); // TODO implement; +} + +//static +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) +{ + return false; // TODO implement; +} + +//static +bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents) +{ + QString abspath = absoluteName(entry).nativeFilePath(); + if (!abspath.endsWith(QLatin1Char('\\'))) + abspath.append(QLatin1Char('\\')); + TInt r; + if (createParents) + r = qt_s60GetRFs().MkDirAll(qt_QString2TPtrC(abspath)); + else + r = qt_s60GetRFs().MkDir(qt_QString2TPtrC(abspath)); + return (r == KErrNone || r == KErrAlreadyExists); +} + +//static +bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents) +{ + QString abspath = absoluteName(entry).nativeFilePath(); + if (!abspath.endsWith(QLatin1Char('\\'))) + abspath.append(QLatin1Char('\\')); + TPtrC dir(qt_QString2TPtrC(abspath)); + RFs& fs = qt_s60GetRFs(); + bool ok = false; + //behaviour of FS file engine: + //returns true if the directory could be removed + //success/failure of removing parent directories does not matter + while (KErrNone == fs.RmDir(dir)) { + ok = true; + if (!removeEmptyParents) + break; + //RFs::RmDir treats "c:\foo\bar" and "c:\foo\" the same, so it is sufficient to remove the last \ to the end + dir.Set(dir.Left(dir.LocateReverse(TChar('\\')))); + } + return ok; +} + +//static +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + Q_UNUSED(source) + Q_UNUSED(target) + return false; +} + +//static +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + //TODO: review - should this be a singleton? + CFileMan *fm = 0; + TRAPD(err, fm = CFileMan::NewL(qt_s60GetRFs())); + if(err == KErrNone) { + err = fm->Copy(qt_QString2TPtrC(source.nativeFilePath()), qt_QString2TPtrC(target.nativeFilePath()), 0); + delete fm; + return true; + } + //TODO: error reporting d->setSymbianError(err, QFile::CopyError); + return false; +} + +//static +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +{ + QString sourcepath = absoluteName(source).nativeFilePath(); + QString targetpath = absoluteName(target).nativeFilePath(); + RFs& fs(qt_s60GetRFs()); + TInt err = fs.Rename(qt_QString2TPtrC(sourcepath), qt_QString2TPtrC(targetpath)); + return err == KErrNone; // TODO error reporting; +} + +//static +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) +{ + QString targetpath = absoluteName(entry).nativeFilePath(); + RFs& fs(qt_s60GetRFs()); + TInt err = fs.Delete(qt_QString2TPtrC(targetpath)); + return false; // TODO error reporting; +} + +//static +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) +{ + QString targetpath = absoluteName(entry).nativeFilePath(); + TUint setmask = 0; + TUint clearmask = 0; + RFs& fs(qt_s60GetRFs()); + if (permissions & (QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther)) + clearmask = KEntryAttReadOnly; + else + setmask = KEntryAttReadOnly; + TInt err = fs.SetAtt(qt_QString2TPtrC(targetpath), setmask, clearmask); + return err != KErrNone; // TODO error reporting, metadata update; +} + +QT_END_NAMESPACE -- cgit v0.12 From c4606e7fc8eeb52cd8966d317a77e4a69b0f2359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 3 Sep 2010 11:31:43 +0200 Subject: QFileSystemEngine/Mac: keep it empty until needed Added qfilesystemengine_mac to the build system, but hollowed it out. This way, it is ready for immediate use without having unnecessary stubs that can be found in the _unix version already. --- qmake/Makefile.unix | 4 ++ qmake/qmake.pri | 1 + src/corelib/io/io.pri | 1 + src/corelib/io/qfilesystemengine_mac.cpp | 77 +------------------------------- src/tools/bootstrap/bootstrap.pro | 1 + 5 files changed, 8 insertions(+), 76 deletions(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index e8e96fd..d248831 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -46,6 +46,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge $(SOURCE_PATH)/src/corelib/tools/qbytearray.cpp $(SOURCE_PATH)/src/corelib/tools/qbytearraymatcher.cpp \ $(SOURCE_PATH)/src/corelib/io/qdatastream.cpp $(SOURCE_PATH)/src/corelib/io/qbuffer.cpp \ $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp \ + $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_mac.cpp \ $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_unix.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_unix.cpp $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator.cpp \ @@ -172,6 +173,9 @@ qfilesystemengine.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp qfilesystemengine_unix.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_unix.cpp +qfilesystemengine_mac.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_mac.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_mac.cpp + qfilesystemiterator_unix.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_unix.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_unix.cpp diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 7226b12..ae31eca 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -129,6 +129,7 @@ bootstrap { #Qt code unix { SOURCES += qfilesystemengine_unix.cpp qfilesystemiterator_unix.cpp qfsfileengine_unix.cpp qfsfileengine_iterator_unix.cpp mac { + SOURCES += qfilesystemengine_mac.cpp SOURCES += qcore_mac.cpp qsettings_mac.cpp QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported) LIBS += -framework ApplicationServices diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 5d10216..7c3712e 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -81,6 +81,7 @@ win32 { else:SOURCES += io/qprocess_unix.cpp macx-*: { HEADERS += io/qfilesystemwatcher_fsevents_p.h + SOURCES += io/qfilesystemengine_mac.cpp SOURCES += io/qsettings_mac.cpp io/qfilesystemwatcher_fsevents.cpp } diff --git a/src/corelib/io/qfilesystemengine_mac.cpp b/src/corelib/io/qfilesystemengine_mac.cpp index c915a2c..30d7fa5 100644 --- a/src/corelib/io/qfilesystemengine_mac.cpp +++ b/src/corelib/io/qfilesystemengine_mac.cpp @@ -43,81 +43,6 @@ QT_BEGIN_NAMESPACE -bool QFileSystemEngine::isCaseSensitive() -{ - return true; -} - -//static -QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) -{ - return link; // TODO implement -} - -//static -QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) -{ - return entry; // TODO implement; -} - -//static -QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) -{ - return entry; // TODO implement; -} - -//static -QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) -{ - return QString(); // TODO implement; -} - -//static -bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) -{ - return false; // TODO implement; -} - -//static -bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents) -{ - return false; // TODO implement; -} - -//static -bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents) -{ - return false; // TODO implement; -} - -//static -bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) -{ - return false; // TODO implement; -} - -//static -bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) -{ - return false; // TODO implement; -} - -//static -bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) -{ - return false; // TODO implement; -} - -//static -bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) -{ - return false; // TODO implement; -} - -//static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) -{ - return false; // TODO implement; -} +// Mac-specific implementations only! QT_END_NAMESPACE diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 6d2f760..016fdc0 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -97,6 +97,7 @@ win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ macx: { QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported) + SOURCES += ../../corelib/io/qfilesystemengine_mac.cpp SOURCES += ../../corelib/kernel/qcore_mac.cpp LIBS += -framework CoreServices } -- cgit v0.12 From 81b302d06c93b77127a2bd6ee527aeefadffbf64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 3 Sep 2010 13:43:33 +0200 Subject: QFileSystemMetaData: filling up Changes to QFileSystemMetaData resulting from implementing QFileSystemEngine::fillMetaData on Unix -- commit to follow. * Added missing operators for MetaDataFlags * Tentatively sharing entryFlags and size across platforms; times and owner IDs are candidates * Flags definition simplified and made stricter; unused bits are no longer set in masks, either * New AliasType for Mac; AliasType and BundleType on other platforms are 0 so they can be optimized out * New SequentialType for files that are not regular files * LocalDiskAttribute (LocalDiskFlag in QAbstractFileEngine) was only used to flag the use of a native file engine, so it's useless here * New flags for querying owner IDs * New method: missingFlags, to help with incremental queries * Added accessors for known data * New method to fill metaData from struct stat --- src/corelib/io/qfilesystemengine_unix.cpp | 51 ++++++++++- src/corelib/io/qfilesystemmetadata_p.h | 136 +++++++++++++++++++++++++++--- 2 files changed, 172 insertions(+), 15 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 7c72782..3011aa0 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "qplatformdefs.h" #include "qfilesystemengine_p.h" #include "qplatformdefs.h" #include "qfsfileengine.h" @@ -47,11 +48,59 @@ #include #if defined(Q_OS_MAC) -# include +# include #endif QT_BEGIN_NAMESPACE +void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) +{ + // Permissions + if (statBuffer.st_mode & S_IRUSR) + entryFlags |= QFileSystemMetaData::OwnerReadPermission; + if (statBuffer.st_mode & S_IWUSR) + entryFlags |= QFileSystemMetaData::OwnerWritePermission; + if (statBuffer.st_mode & S_IXUSR) + entryFlags |= QFileSystemMetaData::OwnerExecutePermission; + + if (statBuffer.st_mode & S_IRGRP) + entryFlags |= QFileSystemMetaData::GroupReadPermission; + if (statBuffer.st_mode & S_IWGRP) + entryFlags |= QFileSystemMetaData::GroupWritePermission; + if (statBuffer.st_mode & S_IXGRP) + entryFlags |= QFileSystemMetaData::GroupExecutePermission; + + if (statBuffer.st_mode & S_IROTH) + entryFlags |= QFileSystemMetaData::OtherReadPermission; + if (statBuffer.st_mode & S_IWOTH) + entryFlags |= QFileSystemMetaData::OtherWritePermission; + if (statBuffer.st_mode & S_IXOTH) + entryFlags |= QFileSystemMetaData::OtherExecutePermission; + + // Type + if ((statBuffer.st_mode & S_IFMT) == S_IFREG) + entryFlags |= QFileSystemMetaData::FileType; + else if ((statBuffer.st_mode & S_IFMT) == S_IFDIR) + entryFlags |= QFileSystemMetaData::DirectoryType; + else + entryFlags |= QFileSystemMetaData::SequentialType; + + // Attributes + entryFlags |= QFileSystemMetaData::ExistsAttribute; + size_ = statBuffer.st_size; +#if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if (statBuffer.st_flags & UF_HIDDEN) { + entryFlags |= QFileSystemMetaData::HiddenAttribute; + knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; + } +#endif + + // Times + creationTime_ = statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime; + modificationTime_ = statBuffer.st_mtime; + accessTime_ = statBuffer.st_atime; +} + bool QFileSystemEngine::isCaseSensitive() { #if defined(Q_OS_SYMBIAN) diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 40bad9e..5914eb3 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -53,7 +53,10 @@ // We mean it. // +#include "qplatformdefs.h" #include +#include +#include // Platform-specific includes #if defined(Q_OS_WIN) @@ -67,7 +70,7 @@ class QFileSystemEngine; struct QFileSystemMetaData { QFileSystemMetaData() - : cachedFlags(0) + : knownFlagsMask(0) { } @@ -78,60 +81,165 @@ struct QFileSystemMetaData UserReadPermission = 0x00000400, UserWritePermission = 0x00000200, UserExecutePermission = 0x00000100, OwnerReadPermission = 0x00004000, OwnerWritePermission = 0x00002000, OwnerExecutePermission = 0x00001000, - OtherPermissions = 0x0000000F, - GroupPermissions = 0x000000F0, - UserPermissions = 0x00000F00, - OwnerPermissions = 0x0000F000, + OtherPermissions = OtherReadPermission | OtherWritePermission | OtherExecutePermission, + GroupPermissions = GroupReadPermission | GroupWritePermission | GroupExecutePermission, + UserPermissions = UserReadPermission | UserWritePermission | UserExecutePermission, + OwnerPermissions = OwnerReadPermission | OwnerWritePermission | OwnerExecutePermission, - Permissions = 0x0000FFFF, + Permissions = OtherPermissions | GroupPermissions | UserPermissions | OwnerPermissions, // Type LinkType = 0x00010000, FileType = 0x00020000, DirectoryType = 0x00040000, +#if !defined(QWS) && defined(Q_OS_MAC) BundleType = 0x00080000, + AliasType = 0x08000000, +#else + BundleType = 0x0, + AliasType = 0x0, +#endif + SequentialType = 0x00800000, // Note: overlaps with QAbstractFileEngine::RootFlag - Type = 0x000F0000, + Type = LinkType | FileType | DirectoryType | BundleType | SequentialType | AliasType, // Attributes HiddenAttribute = 0x00100000, - LocalDiskAttribute = 0x00200000, + SizeAttribute = 0x00200000, // Note: overlaps with QAbstractFileEngine::LocalDiskFlag ExistsAttribute = 0x00400000, - SizeAttribute = 0x00800000, // Note: overlaps with QAbstractFileEngine::RootFlag - Attributes = 0x00F00000, + Attributes = HiddenAttribute | SizeAttribute | ExistsAttribute, // Times CreationTime = 0x01000000, // Note: overlaps with QAbstractFileEngine::Refresh ModificationTime = 0x02000000, AccessTime = 0x04000000, - Times = 0x07000000 + Times = CreationTime | ModificationTime | AccessTime, + + // Owner IDs + UserId = 0x10000000, + GroupId = 0x20000000, + + OwnerIds = UserId | GroupId, + + PosixStatFlags = QFileSystemMetaData::OtherPermissions + | QFileSystemMetaData::GroupPermissions + | QFileSystemMetaData::OwnerPermissions + | QFileSystemMetaData::FileType + | QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::SequentialType +#if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + // Mac OS >= 10.5: st_flags & UF_HIDDEN + | QFileSystemMetaData::HiddenAttribute +#endif + | QFileSystemMetaData::SizeAttribute + | QFileSystemMetaData::Times + | QFileSystemMetaData::OwnerIds, + + AllMetaDataFlags = 0xFFFFFFFF + }; Q_DECLARE_FLAGS(MetaDataFlags, MetaDataFlag) bool hasFlags(MetaDataFlags flags) const { - return ((cachedFlags & flags) == flags); + return ((knownFlagsMask & flags) == flags); + } + + MetaDataFlags missingFlags(MetaDataFlags flags) + { + return flags & ~knownFlagsMask; } void clear() { - cachedFlags = 0; + knownFlagsMask = 0; + } + + void clearFlags(MetaDataFlags flags = AllMetaDataFlags) + { + knownFlagsMask &= ~flags; + } + + bool exists() const { return (entryFlags & ExistsAttribute); } + + bool isLink() const { return (entryFlags & LinkType); } + bool isFile() const { return (entryFlags & FileType); } + bool isDirectory() const { return (entryFlags & DirectoryType); } +#if !defined(QWS) && defined(Q_OS_MAC) + bool isBundle() const { return (entryFlags & BundleType); } + bool isAlias() const { return (entryFlags & AliasType); } +#else + bool isBundle() const { return false; } + bool isAlias() const { return false; } +#endif + bool isSequential() const { return (entryFlags & SequentialType); } + bool isHidden() const { return (entryFlags & HiddenAttribute); } + + qint64 size() const { return size_; } + + QFile::Permissions permissions() const { return QFile::Permissions(Permissions & entryFlags); } + +#if defined(Q_OS_UNIX) + QDateTime creationTime() const { return QDateTime::fromTime_t(creationTime_); } + QDateTime modificationTime() const { return QDateTime::fromTime_t(modificationTime_); } + QDateTime accessTime() const { return QDateTime::fromTime_t(accessTime_); } + + QDateTime fileTime(QAbstractFileEngine::FileTime time) const + { + switch (time) + { + case QAbstractFileEngine::ModificationTime: + return modificationTime(); + + case QAbstractFileEngine::AccessTime: + return accessTime(); + + case QAbstractFileEngine::CreationTime: + return creationTime(); + } + + return QDateTime(); + } + + uint userId() const { return userId_; } + uint groupId() const { return groupId_; } + + uint ownerId(QAbstractFileEngine::FileOwner owner) const + { + if (owner == QAbstractFileEngine::OwnerUser) + return userId(); + else + return groupId(); } + void fillFromStatBuf(const QT_STATBUF &statBuffer); +#endif + private: friend class QFileSystemEngine; - MetaDataFlags cachedFlags; + MetaDataFlags knownFlagsMask; + MetaDataFlags entryFlags; + + qint64 size_; // Platform-specific data goes here: #if defined(Q_OS_WIN) #else + time_t creationTime_; + time_t modificationTime_; + time_t accessTime_; + + uint userId_; + uint groupId_; #endif }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags) + QT_END_NAMESPACE #endif // include guard -- cgit v0.12 From 4fd2aced96d9095254d89f9da9c911bd88f15245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 3 Sep 2010 20:17:35 +0200 Subject: QFileSystemEngine::fillMetaData for Unix platforms This shuffles a lot of code out of QFSFileEngine. fillMetaData, however is almost a reimplementation of the logic. Goals for this function are to maximize data gathered and minimize file system queries. Symbian had an optimization to lstat first and only stat again on links, having noticed a lot of lstat were being done that weren't really necessary. That optimization was also made in the new fillMetaData function and extended to all platforms, whenever the LinkType attribute is requested (QFSFileEngine will now typically request this in reply to a fileFlags request). We now try to cache all meta data we get from the file system, while still requesting "refreshes" as often as we did before. Client code going straight to QFileSystemEngine API can choose it's behaviour by clearing and querying specific flags in the QFileSystemMetaData instance. Reviewed-by: Prasanth Ullattil --- src/corelib/io/qfilesystemengine_p.h | 3 + src/corelib/io/qfilesystemengine_unix.cpp | 209 ++++++++++++++++++++- src/corelib/io/qfsfileengine.cpp | 33 +--- src/corelib/io/qfsfileengine_p.h | 14 +- src/corelib/io/qfsfileengine_unix.cpp | 300 +++++++++--------------------- 5 files changed, 324 insertions(+), 235 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index f50701e..182ccd6 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -72,6 +72,9 @@ public: static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what); +#if defined(Q_OS_UNIX) + static bool fillMetaData(int fd, QFileSystemMetaData &data); // what = PosixStatFlags +#endif static bool createDirectory(const QFileSystemEntry &entry, bool createParents); static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents); diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 3011aa0..6b3c157 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -47,12 +47,64 @@ #include // for realpath() #include +#if defined(Q_OS_SYMBIAN) +# include +# include +# include +# include +#endif + #if defined(Q_OS_MAC) # include #endif QT_BEGIN_NAMESPACE +#if defined(Q_OS_SYMBIAN) +static bool _q_isSymbianHidden(const QFileSystemEntry &entry, bool isDir) +{ + RFs rfs = qt_s60GetRFs(); + + QFileSystemEntry absoluteEntry = QFileSystemEngine::absoluteName(entry); + QString absolutePath = absoluteEntry.filePath(); + + if (isDir && !absolutePath.endsWith(QLatin1Char('/'))) + absolutePath.append(QLatin1Char('/')); + + TPtrC ptr(qt_QString2TPtrC(absolutePath)); + TUint attributes; + TInt err = rfs.Att(ptr, attributes); + return (err == KErrNone && (attributes & KEntryAttHidden)); +} +#endif + +#if !defined(QWS) && defined(Q_OS_MAC) +static inline bool _q_isMacHidden(const char *nativePath) +{ + OSErr err; + + FSRef fsRef; + err = FSPathMakeRefWithOptions(reinterpret_cast(nativePath), + kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0); + if (err != noErr) + return false; + + FSCatalogInfo catInfo; + err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL); + if (err != noErr) + return false; + + FileInfo * const fileInfo = reinterpret_cast(&catInfo.finderInfo); + return (fileInfo->finderFlags & kIsInvisible); +} +#else +static inline bool _q_isMacHidden(const char *nativePath) +{ + // no-op + return false; +} +#endif + void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) { // Permissions @@ -207,9 +259,162 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) } //static -bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) +bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data) { - return false; // TODO implement; + data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags; + data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags; + + QT_STATBUF statBuffer; + if (QT_FSTAT(fd, &statBuffer) == 0) { + data.fillFromStatBuf(statBuffer); + return true; + } + + return false; +} + +//static +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, + QFileSystemMetaData::MetaDataFlags what) +{ +#if !defined(QWS) && defined(Q_OS_MAC) + if (what & QFileSystemMetaData::BundleType) { + if (!data.hasFlags(QFileSystemMetaData::DirectoryType)) + what |= QFileSystemMetaData::DirectoryType; + } +#endif + +#if defined(Q_OS_SYMBIAN) + if (what & QFileSystemMetaData::HiddenAttribute) { + if (!data.hasFlags(QFileSystemMetaData::LinkType | QFileSystemMetaData::DirectoryType)) + what |= QFileSystemMetaData::LinkType | QFileSystemMetaData::DirectoryType; + } +#endif + + if (what & QFileSystemMetaData::PosixStatFlags) + what |= QFileSystemMetaData::PosixStatFlags; + + if (what & QFileSystemMetaData::ExistsAttribute) { + // FIXME: Would other queries being performed provide this bit? + what |= QFileSystemMetaData::PosixStatFlags; + } + + data.entryFlags &= ~what; + + const char * nativeFilePath; + int nativeFilePathLength; + { + const QByteArray &path = entry.nativeFilePath(); + nativeFilePath = path.constData(); + nativeFilePathLength = path.size(); + } + + bool entryExists = true; // innocent until proven otherwise + + QT_STATBUF statBuffer; + bool statBufferValid = false; + if (what & QFileSystemMetaData::LinkType) { + if (QT_LSTAT(nativeFilePath, &statBuffer) == 0) { + if (S_ISLNK(statBuffer.st_mode)) { + data.entryFlags |= QFileSystemMetaData::LinkType; + } else { + statBufferValid = true; + data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags; + } + } else { + entryExists = false; + } + + data.knownFlagsMask |= QFileSystemMetaData::LinkType; + } + + if (statBufferValid || (what & QFileSystemMetaData::PosixStatFlags)) { + if (entryExists && !statBufferValid) + statBufferValid = (QT_STAT(nativeFilePath, &statBuffer) == 0); + + if (statBufferValid) + data.fillFromStatBuf(statBuffer); + else + entryExists = false; + + // reset the mask + data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags + | QFileSystemMetaData::ExistsAttribute; + } + +#if !defined(QWS) && defined(Q_OS_MAC) + if (what & QFileSystemMetaData::AliasType) + { + if (entryExists) { + FSRef fref; + if (FSPathMakeRef((const UInt8 *)nativeFilePath, &fref, NULL) == noErr) { + Boolean isAlias, isFolder; + if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr) { + if (isAlias) + data.entryFlags |= QFileSystemMetaData::AliasType; + } + } + } + data.knownFlagsMask |= QFileSystemMetaData::AliasType; + } +#endif + + if (what & QFileSystemMetaData::UserPermissions) { + // calculate user permissions + + if (entryExists) { + if (what & QFileSystemMetaData::UserReadPermission) { + if (QT_ACCESS(nativeFilePath, R_OK) == 0) + data.entryFlags |= QFileSystemMetaData::UserReadPermission; + } + if (what & QFileSystemMetaData::UserWritePermission) { + if (QT_ACCESS(nativeFilePath, W_OK) == 0) + data.entryFlags |= QFileSystemMetaData::UserWritePermission; + } + if (what & QFileSystemMetaData::UserExecutePermission) { + if (QT_ACCESS(nativeFilePath, X_OK) == 0) + data.entryFlags |= QFileSystemMetaData::UserExecutePermission; + } + } + data.knownFlagsMask |= (what & QFileSystemMetaData::UserPermissions); + } + + if (what & QFileSystemMetaData::HiddenAttribute + && !data.isHidden()) { +#if defined(Q_OS_SYMBIAN) + // In Symbian, all symlinks have hidden attribute for some reason; + // lets make them visible for better compatibility with other platforms. + // If somebody actually wants a hidden link, then they are out of luck. + if (entryExists && !data.isLink() && _q_isSymbianHidden(entry, data.isDirectory())) + data.entryFlags |= QFileSystemMetaData::HiddenAttribute; +#else + QString fileName = entry.fileName(); + if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.')) + || (entryExists && _q_isMacHidden(nativeFilePath))) + data.entryFlags |= QFileSystemMetaData::HiddenAttribute; +#endif + data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; + } + +#if !defined(QWS) && defined(Q_OS_MAC) + if (what & QFileSystemMetaData::BundleType) { + if (entryExists && data.isDirectory()) { + QCFType path = CFStringCreateWithBytes(0, + (const UInt8*)nativeFilePath, nativeFilePathLength, + kCFStringEncodingUTF8, false); + QCFType url = CFURLCreateWithFileSystemPath(0, path, + kCFURLPOSIXPathStyle, true); + + UInt32 type, creator; + if (CFBundleGetPackageInfoInDirectory(url, &type, &creator)) + data.entryFlags |= QFileSystemMetaData::BundleType; + } + + data.knownFlagsMask |= QFileSystemMetaData::BundleType; + } +#endif + + return data.hasFlags(what); } //static diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 5d7b354..1b0a28c 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -447,24 +447,13 @@ qint64 QFSFileEngine::size() const qint64 QFSFileEnginePrivate::sizeFdFh() const { Q_Q(const QFSFileEngine); - // ### Fix this function, it should not stat unless the file is closed. - QT_STATBUF st; - int ret = 0; const_cast(q)->flush(); - if (fh && fileEntry.isEmpty()) { - // Buffered stdlib mode. - // ### This should really be an ftell - ret = QT_FSTAT(QT_FILENO(fh), &st); - } else if (fd == -1) { - // Stateless stat. - ret = QT_STAT(fileEntry.nativeFilePath().constData(), &st); - } else { - // Unbuffered stdio mode. - ret = QT_FSTAT(fd, &st); - } - if (ret == -1) + + tried_stat = 0; + metaData.clearFlags(QFileSystemMetaData::SizeAttribute); + if (!doStat(QFileSystemMetaData::SizeAttribute)) return 0; - return st.st_size; + return metaData.size(); } #endif @@ -773,18 +762,14 @@ bool QFSFileEngine::isSequential() const /*! \internal */ +#ifdef Q_OS_UNIX bool QFSFileEnginePrivate::isSequentialFdFh() const { - if (!tried_stat) - doStat(); - if (could_stat) { -#ifdef Q_OS_UNIX - return (st.st_mode & S_IFMT) != S_IFREG; - // ### WINDOWS! -#endif - } + if (doStat(QFileSystemMetaData::SequentialType)) + return metaData.isSequential(); return true; } +#endif /*! \reimp diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 9eaf6fd..6e5f30e 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -56,7 +56,8 @@ #include "qplatformdefs.h" #include "QtCore/qfsfileengine.h" #include "private/qabstractfileengine_p.h" -#include "private/qfilesystementry_p.h" +#include +#include #include #ifndef QT_NO_FSFILEENGINE @@ -102,11 +103,17 @@ public: qint64 writeFdFh(const char *data, qint64 len); int nativeHandle() const; bool nativeIsSequential() const; +#ifndef Q_OS_WIN bool isSequentialFdFh() const; +#endif uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags); bool unmap(uchar *ptr); +#if defined(Q_OS_UNIX) + mutable QFileSystemMetaData metaData; +#endif + FILE *fh; #ifdef Q_WS_WIN HANDLE fileHandle; @@ -120,7 +127,6 @@ public: mutable DWORD fileAttrib; #else QHash > maps; - mutable QT_STATBUF st; #endif int fd; @@ -142,7 +148,11 @@ public: mutable uint is_link : 1; #endif +#if defined(Q_OS_WIN) bool doStat() const; +#else + bool doStat(QFileSystemMetaData::MetaDataFlags flags = QFileSystemMetaData::PosixStatFlags) const; +#endif bool isSymlink() const; #if defined(Q_OS_WIN32) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 50b18fc..71a604a 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -69,7 +69,6 @@ QT_BEGIN_NAMESPACE - #if defined(Q_OS_SYMBIAN) /*! \internal @@ -124,16 +123,17 @@ void QFSFileEnginePrivate::setSymbianError(int symbianError, QFile::FileError de Returns the stdlib open string corresponding to a QIODevice::OpenMode. */ -static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QByteArray &fileName) +static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QFileSystemEntry &fileEntry, + QFileSystemMetaData &metaData) { QByteArray mode; if ((flags & QIODevice::ReadOnly) && !(flags & QIODevice::Truncate)) { mode = "rb"; if (flags & QIODevice::WriteOnly) { - QT_STATBUF statBuf; - if (!fileName.isEmpty() - && QT_STAT(fileName, &statBuf) == 0 - && (statBuf.st_mode & S_IFMT) == S_IFREG) { + metaData.clearFlags(QFileSystemMetaData::FileType); + if (!fileEntry.isEmpty() + && QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::FileType) + && metaData.isFile()) { mode += '+'; } else { mode = "wb+"; @@ -222,13 +222,11 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) if (!(openMode & QIODevice::WriteOnly)) { // we don't need this check if we tried to open for writing because then // we had received EISDIR anyway. - QT_STATBUF statBuf; - if (QT_FSTAT(fd, &statBuf) != -1) { - if ((statBuf.st_mode & S_IFMT) == S_IFDIR) { - q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); - QT_CLOSE(fd); - return false; - } + if (QFileSystemEngine::fillMetaData(fd, metaData) + && metaData.isDirectory()) { + q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); + QT_CLOSE(fd); + return false; } } @@ -248,7 +246,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) fh = 0; } else { - QByteArray fopenMode = openModeToFopenMode(openMode, fileEntry.nativeFilePath().constData()); + QByteArray fopenMode = openModeToFopenMode(openMode, fileEntry, metaData); // Try to open the file in buffered mode. do { @@ -265,13 +263,11 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) if (!(openMode & QIODevice::WriteOnly)) { // we don't need this check if we tried to open for writing because then // we had received EISDIR anyway. - QT_STATBUF statBuf; - if (QT_FSTAT(fileno(fh), &statBuf) != -1) { - if ((statBuf.st_mode & S_IFMT) == S_IFDIR) { - q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); - fclose(fh); - return false; - } + if (QFileSystemEngine::fillMetaData(QT_FILENO(fh), metaData) + && metaData.isDirectory()) { + q->setError(QFile::OpenError, QLatin1String("file to open is a directory")); + fclose(fh); + return false; } } @@ -626,123 +622,30 @@ QFileInfoList QFSFileEngine::drives() return ret; } -bool QFSFileEnginePrivate::doStat() const +bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const { - if (!tried_stat) { - tried_stat = true; - could_stat = false; - - if (fh && fileEntry.isEmpty()) { - // ### actually covers two cases: d->fh and when the file is not open - could_stat = (QT_FSTAT(QT_FILENO(fh), &st) == 0); - } else if (fd == -1) { - // ### actually covers two cases: d->fh and when the file is not open -#if defined(Q_OS_SYMBIAN) - // Optimisation for Symbian where fileFlags() calls both doStat() and isSymlink(), but rarely on real links. - // When the filename is not a link, lstat will return the same info as stat, but this also removes - // any need for a further call to lstat to check if the file is a link. - need_lstat = false; - could_stat = (QT_LSTAT(fileEntry.nativeFilePath().constData(), &st) == 0); - is_link = could_stat ? S_ISLNK(st.st_mode) : false; - // if it turns out this was a link, we can call stat too. - if (is_link) -#endif - could_stat = (QT_STAT(fileEntry.nativeFilePath().constData(), &st) == 0); - } else { - could_stat = (QT_FSTAT(fd, &st) == 0); - } - } - return could_stat; -} + if (!tried_stat || !metaData.hasFlags(flags)) { + tried_stat = 1; -bool QFSFileEnginePrivate::isSymlink() const -{ - if (need_lstat) { - need_lstat = false; + int localFd = fd; + if (fh && fileEntry.isEmpty()) + localFd = QT_FILENO(fh); + if (localFd != -1) + QFileSystemEngine::fillMetaData(localFd, metaData); - QT_STATBUF st; // don't clobber our main one - is_link = (QT_LSTAT(fileEntry.nativeFilePath().constData(), &st) == 0) ? S_ISLNK(st.st_mode) : false; + if (metaData.missingFlags(flags) && !fileEntry.isEmpty()) + QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags)); } - return is_link; -} -#if defined(Q_OS_SYMBIAN) -static bool _q_isSymbianHidden(const QString &path, bool isDir) -{ - RFs rfs = qt_s60GetRFs(); - QFileInfo fi(path); - QString absPath = fi.absoluteFilePath(); - if (isDir && !absPath.endsWith(QLatin1Char('/'))) - absPath.append(QLatin1Char('/')); - QString native(QDir::toNativeSeparators(absPath)); - TPtrC ptr(qt_QString2TPtrC(native)); - TUint attributes; - TInt err = rfs.Att(ptr, attributes); - return (err == KErrNone && (attributes & KEntryAttHidden)); + return metaData.exists(); } -#endif -#if !defined(QWS) && defined(Q_OS_MAC) -static bool _q_isMacHidden(const QString &path) -{ - OSErr err = noErr; - - FSRef fsRef; - - err = FSPathMakeRefWithOptions(reinterpret_cast(QFile::encodeName(QDir::cleanPath(path)).constData()), - kFSPathMakeRefDoNotFollowLeafSymlink, &fsRef, 0); - if (err != noErr) - return false; - - FSCatalogInfo catInfo; - err = FSGetCatalogInfo(&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL); - if (err != noErr) - return false; - - FileInfo * const fileInfo = reinterpret_cast(&catInfo.finderInfo); - bool result = (fileInfo->finderFlags & kIsInvisible); - return result; -} -#endif - -QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFileEngine::FileFlags type) const +bool QFSFileEnginePrivate::isSymlink() const { - QAbstractFileEngine::FileFlags ret = 0; + if (!metaData.hasFlags(QFileSystemMetaData::LinkType)) + QFileSystemEngine::fillMetaData(fileEntry, metaData, QFileSystemMetaData::LinkType); - if (st.st_mode & S_IRUSR) - ret |= QAbstractFileEngine::ReadOwnerPerm; - if (st.st_mode & S_IWUSR) - ret |= QAbstractFileEngine::WriteOwnerPerm; - if (st.st_mode & S_IXUSR) - ret |= QAbstractFileEngine::ExeOwnerPerm; - if (st.st_mode & S_IRGRP) - ret |= QAbstractFileEngine::ReadGroupPerm; - if (st.st_mode & S_IWGRP) - ret |= QAbstractFileEngine::WriteGroupPerm; - if (st.st_mode & S_IXGRP) - ret |= QAbstractFileEngine::ExeGroupPerm; - if (st.st_mode & S_IROTH) - ret |= QAbstractFileEngine::ReadOtherPerm; - if (st.st_mode & S_IWOTH) - ret |= QAbstractFileEngine::WriteOtherPerm; - if (st.st_mode & S_IXOTH) - ret |= QAbstractFileEngine::ExeOtherPerm; - - // calculate user permissions - if (type & QAbstractFileEngine::ReadUserPerm) { - if (QT_ACCESS(fileEntry.nativeFilePath().constData(), R_OK) == 0) - ret |= QAbstractFileEngine::ReadUserPerm; - } - if (type & QAbstractFileEngine::WriteUserPerm) { - if (QT_ACCESS(fileEntry.nativeFilePath().constData(), W_OK) == 0) - ret |= QAbstractFileEngine::WriteUserPerm; - } - if (type & QAbstractFileEngine::ExeUserPerm) { - if (QT_ACCESS(fileEntry.nativeFilePath().constData(), X_OK) == 0) - ret |= QAbstractFileEngine::ExeUserPerm; - } - - return ret; + return metaData.isLink(); } /*! @@ -751,82 +654,71 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFil QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const { Q_D(const QFSFileEngine); - // Force a stat, so that we're guaranteed to get up-to-date results - if (type & Refresh) { - d->tried_stat = 0; - d->need_lstat = 1; - } + + if (type & Refresh) + d->metaData.clear(); QAbstractFileEngine::FileFlags ret = 0; + if (type & FlagsMask) ret |= LocalDiskFlag; - bool exists = d->doStat(); - if (!exists && !d->isSymlink()) + + bool exists; + { + QFileSystemMetaData::MetaDataFlags queryFlags = 0; + + queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type)) + & QFileSystemMetaData::Permissions; + + if (type & TypesMask) + queryFlags |= QFileSystemMetaData::AliasType + | QFileSystemMetaData::LinkType + | QFileSystemMetaData::FileType + | QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::BundleType; + + if (type & FlagsMask) + queryFlags |= QFileSystemMetaData::HiddenAttribute + | QFileSystemMetaData::ExistsAttribute; + + queryFlags |= QFileSystemMetaData::LinkType; + + exists = d->doStat(queryFlags); + } + + if (!exists && !d->metaData.isLink()) return ret; if (exists && (type & PermsMask)) - ret |= d->getPermissions(type); + ret |= FileFlags(uint(d->metaData.permissions())); + if (type & TypesMask) { -#if !defined(QWS) && defined(Q_OS_MAC) - bool foundAlias = false; - { - FSRef fref; - if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->fileEntry.filePath())).data(), - &fref, NULL) == noErr) { - Boolean isAlias, isFolder; - if (FSIsAliasFile(&fref, &isAlias, &isFolder) == noErr && isAlias) { - foundAlias = true; - ret |= LinkType; - } - } - } - if (!foundAlias) -#endif - { - if ((type & LinkType) && d->isSymlink()) + if (d->metaData.isAlias()) { + ret |= LinkType; + } else { + if ((type & LinkType) && d->metaData.isLink()) ret |= LinkType; - if (exists && (d->st.st_mode & S_IFMT) == S_IFREG) - ret |= FileType; - else if (exists && (d->st.st_mode & S_IFMT) == S_IFDIR) - ret |= DirectoryType; -#if !defined(QWS) && defined(Q_OS_MAC) - if ((ret & DirectoryType) && (type & BundleType)) { - QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(d->fileEntry.filePath()), - kCFURLPOSIXPathStyle, true); - UInt32 type, creator; - if (CFBundleGetPackageInfoInDirectory(url, &type, &creator)) - ret |= BundleType; + if (exists) { + if (d->metaData.isFile()) { + ret |= FileType; + } else if (d->metaData.isDirectory()) { + ret |= DirectoryType; + if ((type & BundleType) && d->metaData.isBundle()) + ret |= BundleType; + } } -#endif } } + if (type & FlagsMask) { if (exists) ret |= ExistsFlag; - if (d->fileEntry.isRoot()) { + if (d->fileEntry.isRoot()) ret |= RootFlag; - } else { -#if defined(Q_OS_SYMBIAN) - // In Symbian, all symlinks have hidden attribute for some reason; - // lets make them visible for better compatibility with other platforms. - // If somebody actually wants a hidden link, then they are out of luck. - if (!d->isSymlink() && _q_isSymbianHidden(d->fileEntry.filePath(), ret & DirectoryType)) - ret |= HiddenFlag; -#else - QString baseName = fileName(BaseName); - if ((baseName.size() > 0 && baseName.at(0) == QLatin1Char('.')) -# if !defined(QWS) && defined(Q_OS_MAC) - || _q_isMacHidden(d->fileEntry.filePath()) -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - || d->st.st_flags & UF_HIDDEN -# endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 -# endif - ) { - ret |= HiddenFlag; - } -#endif - } + else if (d->metaData.isHidden()) + ret |= HiddenFlag; } + return ret; } @@ -994,7 +886,8 @@ QString QFSFileEngine::fileName(FileName file) const #endif if (len > 0) { QString ret; - if (d->doStat() && S_ISDIR(d->st.st_mode) && s[0] != '/') { + if (d->doStat(QFileSystemMetaData::DirectoryType) + && d->metaData.isDirectory() && s[0] != '/') { QDir parent(d->fileEntry.filePath()); parent.cdUp(); ret = parent.path(); @@ -1057,12 +950,10 @@ uint QFSFileEngine::ownerId(FileOwner own) const { Q_D(const QFSFileEngine); static const uint nobodyID = (uint) -2; - if (d->doStat()) { - if (own == OwnerUser) - return d->st.st_uid; - else - return d->st.st_gid; - } + + if (d->doStat(QFileSystemMetaData::OwnerIds)) + return d->metaData.ownerId(own); + return nobodyID; } @@ -1170,16 +1061,11 @@ bool QFSFileEngine::setSize(qint64 size) QDateTime QFSFileEngine::fileTime(FileTime time) const { Q_D(const QFSFileEngine); - QDateTime ret; - if (d->doStat()) { - if (time == CreationTime) - ret.setTime_t(d->st.st_ctime ? d->st.st_ctime : d->st.st_mtime); - else if (time == ModificationTime) - ret.setTime_t(d->st.st_mtime); - else if (time == AccessTime) - ret.setTime_t(d->st.st_atime); - } - return ret; + + if (d->doStat(QFileSystemMetaData::Times)) + return d->metaData.fileTime(time); + + return QDateTime(); } uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) @@ -1199,8 +1085,8 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla // If we know the mapping will extend beyond EOF, fail early to avoid // undefined behavior. Otherwise, let mmap have its say. - if (doStat() - && (QT_OFF_T(size) > st.st_size - QT_OFF_T(offset))) + if (doStat(QFileSystemMetaData::SizeAttribute) + && (QT_OFF_T(size) > metaData.size() - QT_OFF_T(offset))) qWarning("QFSFileEngine::map: Mapping a file beyond its size is not portable"); int access = 0; -- cgit v0.12 From a59924437dadf4ea3b972a528f449ebb2b760d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 3 Sep 2010 10:32:20 +0200 Subject: QAbstractFileEngine: Exposing custom file engine handlers So we can invoke custom handlers from QFileSystemEngine. --- src/corelib/io/qabstractfileengine.cpp | 35 ++++++++++++++++++++++++---------- src/corelib/io/qabstractfileengine_p.h | 2 ++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index 37a093c..e055e7b 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -149,6 +149,29 @@ QAbstractFileEngineHandler::~QAbstractFileEngineHandler() } } +/* + \ìnternal + + Handles calls to custom file engine handlers. +*/ +QAbstractFileEngine *qt_custom_file_engine_handler_create(const QString &path) +{ + QAbstractFileEngine *engine = 0; + + if (qt_file_engine_handlers_in_use) { + QReadLocker locker(fileEngineHandlerMutex()); + + // check for registered handlers that can load the file + QAbstractFileEngineHandlerList *handlers = fileEngineHandlers(); + for (int i = 0; i < handlers->size(); i++) { + if ((engine = handlers->at(i)->create(path))) + break; + } + } + + return engine; +} + /*! \fn QAbstractFileEngine *QAbstractFileEngineHandler::create(const QString &fileName) const @@ -177,16 +200,8 @@ QAbstractFileEngineHandler::~QAbstractFileEngineHandler() */ QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName) { - if (qt_file_engine_handlers_in_use) { - QReadLocker locker(fileEngineHandlerMutex()); - - // check for registered handlers that can load the file - QAbstractFileEngineHandlerList *handlers = fileEngineHandlers(); - for (int i = 0; i < handlers->size(); i++) { - if (QAbstractFileEngine *ret = handlers->at(i)->create(fileName)) - return ret; - } - } + if (QAbstractFileEngine *engine = qt_custom_file_engine_handler_create(filePath)) + return engine; #ifdef QT_BUILD_CORE_LIB for (int prefixSeparator = 0; prefixSeparator < fileName.size(); ++prefixSeparator) { diff --git a/src/corelib/io/qabstractfileengine_p.h b/src/corelib/io/qabstractfileengine_p.h index e1eba30..075ec81 100644 --- a/src/corelib/io/qabstractfileengine_p.h +++ b/src/corelib/io/qabstractfileengine_p.h @@ -74,6 +74,8 @@ public: Q_DECLARE_PUBLIC(QAbstractFileEngine) }; +QAbstractFileEngine *qt_custom_file_engine_handler_create(const QString &path); + QT_END_NAMESPACE #endif // QABSTRACTFILEENGINE_P_H -- cgit v0.12 From 367514db5f041de7cd5d36fa0a260dcadcc54a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 3 Sep 2010 19:33:52 +0200 Subject: Split QAbstractFileEngine::create The new, ugly-named resolveEntryAndCreateLegacyEngine will never instantiate QFSFileEngine and uses the QFileSystemEngine API to check if files exist, when necessary. This way, we reduce allocations of QFSFileEngine when resolving paths. Clients of the QAbstractFileEngine API will be able to opt-out of using QFSFileEngine altogether. Reviewed-by: Thomas Zander --- src/corelib/io/qabstractfileengine.cpp | 54 +++++---------------- src/corelib/io/qfilesystemengine.cpp | 87 ++++++++++++++++++++++++++++++++++ src/corelib/io/qfilesystemengine_p.h | 2 + 3 files changed, 102 insertions(+), 41 deletions(-) diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index e055e7b..67109aa 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -52,6 +52,10 @@ #include "qdiriterator.h" #include "qstringbuilder.h" +#include +#include +#include + QT_BEGIN_NAMESPACE /*! @@ -200,49 +204,17 @@ QAbstractFileEngine *qt_custom_file_engine_handler_create(const QString &path) */ QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName) { - if (QAbstractFileEngine *engine = qt_custom_file_engine_handler_create(filePath)) - return engine; - -#ifdef QT_BUILD_CORE_LIB - for (int prefixSeparator = 0; prefixSeparator < fileName.size(); ++prefixSeparator) { - QChar const ch = fileName[prefixSeparator]; - if (ch == QLatin1Char('/')) - break; - - if (ch == QLatin1Char(':')) { - if (prefixSeparator == 0) - return new QResourceFileEngine(fileName); - - if (prefixSeparator == 1) - break; - - const QStringList &paths = QDir::searchPaths(fileName.left(prefixSeparator)); - for (int i = 0; i < paths.count(); i++) { - QAbstractFileEngine *engine = create(paths.at(i) % QLatin1Char('/') % fileName.mid(prefixSeparator + 1)); - if (engine && (engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) { - return engine; - } - delete engine; - } - - break; - } - - // There's no need to fully validate the prefix here. Consulting the - // unicode tables could be expensive and validation is already - // performed in QDir::setSearchPaths. - // - // if (!ch.isLetterOrNumber()) - // break; - } + QFileSystemEntry entry(fileName); + QFileSystemMetaData metaData; + QAbstractFileEngine *engine = QFileSystemEngine::resolveEntryAndCreateLegacyEngine(entry, metaData); + +#ifndef QT_NO_FSFILEENGINE + if (!engine) + // fall back to regular file engine + return new QFSFileEngine(entry.filePath()); #endif -#ifdef QT_NO_FSFILEENGINE - return 0; -#else - // fall back to regular file engine - return new QFSFileEngine(fileName); -#endif + return engine; } /*! diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 04e53ce..a6c226e 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -42,6 +42,12 @@ #include "qfilesystemengine_p.h" #include #include +#include +#ifdef QT_BUILD_CORE_LIB +#include +#endif + +QT_BEGIN_NAMESPACE /*! \internal @@ -111,3 +117,84 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path) return QDir::cleanPath(tmpPath); } +static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &entry, QFileSystemMetaData &data, + QAbstractFileEngine *&engine) +{ + QString const &filePath = entry.filePath(); + if ((engine = qt_custom_file_engine_handler_create(filePath))) + return true; + +#if defined(QT_BUILD_CORE_LIB) + for (int prefixSeparator = 0; prefixSeparator < filePath.size(); ++prefixSeparator) { + QChar const ch = filePath[prefixSeparator]; + if (ch == QLatin1Char('/')) + break; + + if (ch == QLatin1Char(':')) { + if (prefixSeparator == 0) { + engine = new QResourceFileEngine(filePath); + return true; + } + + if (prefixSeparator == 1) + break; + + const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator)); + for (int i = 0; i < paths.count(); i++) { + entry = QFileSystemEntry(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1)); + // Recurse! + if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine)) { + // FIXME: This will over-stat if we recurse + if (engine) { + if (engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag) + return true; + delete engine; + engine = 0; + } else if (QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute) + && data.exists()) { + return true; + } + } + } + + // entry may have been clobbered at this point. + return false; + } + + // There's no need to fully validate the prefix here. Consulting the + // unicode tables could be expensive and validation is already + // performed in QDir::setSearchPaths. + // + // if (!ch.isLetterOrNumber()) + // break; + } +#endif // defined(QT_BUILD_CORE_LIB) + + return true; +} + +/*! + \internal + + Resolves the \a entry (see QDir::searchPaths) and returns an engine for + it, but never a QFSFileEngine. + + \returns a file engine that can be used to access the entry. Returns 0 if + QFileSystemEngine API should be used to query and interact with the file + system object. +*/ +QAbstractFileEngine *QFileSystemEngine::resolveEntryAndCreateLegacyEngine( + QFileSystemEntry &entry, QFileSystemMetaData &data) { + QFileSystemEntry copy = entry; + QAbstractFileEngine *engine = 0; + + if (_q_resolveEntryAndCreateLegacyEngine_recursive(copy, data, engine)) + // Reset entry to resolved copy. + entry = copy; + else + data.clear(); + + return engine; +} + +QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 182ccd6..990a5ff 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -88,6 +88,8 @@ public: static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data = 0); + static QAbstractFileEngine *resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry, + QFileSystemMetaData &data); private: static QString slowCanonicalized(const QString &path); }; -- cgit v0.12 From d1e1f1e83142f18d75c323b44a094d4df6762a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 6 Sep 2010 10:42:02 +0200 Subject: Fix over-stating in QAbstractFileEngine::create With recursive entry resolution, we might end up querying the engine for an entry once per recursion level. There was also the possibility that stale data would remain in the meta data instance. When resolving an entry, we now check for its existence at the leaf level and handle clean-up right away. Reviewed-by: Thomas Zander --- src/corelib/io/qfilesystemengine.cpp | 48 ++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index a6c226e..8f5b98a 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -117,12 +117,38 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path) return QDir::cleanPath(tmpPath); } +static inline bool _q_checkEntry(QFileSystemEntry &entry, QFileSystemMetaData &data, bool resolvingEntry) +{ + if (resolvingEntry) { + if (!QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute) + || !data.exists()) { + data.clear(); + return false; + } + } + + return true; +} + +static inline bool _q_checkEntry(QAbstractFileEngine *&engine, bool resolvingEntry) +{ + if (resolvingEntry) { + if (!engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag) { + delete engine; + engine = 0; + return false; + } + } + + return true; +} + static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &entry, QFileSystemMetaData &data, - QAbstractFileEngine *&engine) + QAbstractFileEngine *&engine, bool resolvingEntry = false) { QString const &filePath = entry.filePath(); if ((engine = qt_custom_file_engine_handler_create(filePath))) - return true; + return _q_checkEntry(engine, resolvingEntry); #if defined(QT_BUILD_CORE_LIB) for (int prefixSeparator = 0; prefixSeparator < filePath.size(); ++prefixSeparator) { @@ -133,7 +159,7 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent if (ch == QLatin1Char(':')) { if (prefixSeparator == 0) { engine = new QResourceFileEngine(filePath); - return true; + return _q_checkEntry(engine, resolvingEntry); } if (prefixSeparator == 1) @@ -143,18 +169,8 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent for (int i = 0; i < paths.count(); i++) { entry = QFileSystemEntry(paths.at(i) % QLatin1Char('/') % filePath.mid(prefixSeparator + 1)); // Recurse! - if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine)) { - // FIXME: This will over-stat if we recurse - if (engine) { - if (engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag) - return true; - delete engine; - engine = 0; - } else if (QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute) - && data.exists()) { - return true; - } - } + if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true)) + return true; } // entry may have been clobbered at this point. @@ -170,7 +186,7 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent } #endif // defined(QT_BUILD_CORE_LIB) - return true; + return _q_checkEntry(entry, data, resolvingEntry); } /*! -- cgit v0.12 From 8f6f2adc2a8eee620bfe342f211035948a3fedc8 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 3 Sep 2010 15:27:58 +0200 Subject: Move resolving a symlink to the qfilesystemengine_unix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_p.h | 2 +- src/corelib/io/qfilesystemengine_unix.cpp | 74 ++++++++++++++++++++++++++++++- src/corelib/io/qfilesystemengine_win.cpp | 2 +- src/corelib/io/qfsfileengine_unix.cpp | 70 +---------------------------- 4 files changed, 76 insertions(+), 72 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 990a5ff..94fb4e5 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -64,7 +64,7 @@ class QFileSystemEngine public: static bool isCaseSensitive(); - static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link); + static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data); static QFileSystemEntry canonicalName(const QFileSystemEntry &entry); static QFileSystemEntry absoluteName(const QFileSystemEntry &entry); diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 6b3c157..755298d 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -163,9 +163,79 @@ bool QFileSystemEngine::isCaseSensitive() } //static -QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) +QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data) { - return link; // TODO implement +#if defined(__GLIBC__) && !defined(PATH_MAX) +#define PATH_CHUNK_SIZE 256 + char *s = 0; + int len = -1; + int size = PATH_CHUNK_SIZE; + + while (1) { + s = (char *) ::realloc(s, size); + Q_CHECK_PTR(s); + len = ::readlink(link.nativeFilePath().constData(), s, size); + if (len < 0) { + ::free(s); + break; + } + if (len < size) { + break; + } + size *= 2; + } +#else + char s[PATH_MAX+1]; + int len = readlink(link.nativeFilePath().constData(), s, PATH_MAX); +#endif + if (len > 0) { + QString ret; + if (!data.hasFlags(QFileSystemMetaData::DirectoryType)) + fillMetaData(link, data, QFileSystemMetaData::DirectoryType); + if (data.isDirectory() && s[0] != '/') { + QDir parent(link.filePath()); + parent.cdUp(); + ret = parent.path(); + if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) + ret += QLatin1Char('/'); + } + s[len] = '\0'; + ret += QFile::decodeName(QByteArray(s)); +#if defined(__GLIBC__) && !defined(PATH_MAX) + ::free(s); +#endif + + if (!ret.startsWith(QLatin1Char('/'))) { + if (link.filePath().startsWith(QLatin1Char('/'))) { + ret.prepend(link.filePath().left(link.filePath().lastIndexOf(QLatin1Char('/'))) + + QLatin1Char('/')); + } else { + ret.prepend(QDir::currentPath() + QLatin1Char('/')); + } + } + ret = QDir::cleanPath(ret); + if (ret.size() > 1 && ret.endsWith(QLatin1Char('/'))) + ret.chop(1); + return QFileSystemEntry(ret); + } +#if !defined(QWS) && defined(Q_OS_MAC) + { + FSRef fref; + if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) { + // TODO get the meta data info from the QFileSystemMetaData object + Boolean isAlias, isFolder; + if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) { + AliasHandle alias; + if (FSNewAlias(0, &fref, &alias) == noErr && alias) { + QCFString cfstr; + if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) + return QFileSystemEntry(QCFString::toQString(cfstr)); + } + } + } + } +#endif + return QFileSystemEntry(); } //static diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index ef47fe5..8572506 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -49,7 +49,7 @@ bool QFileSystemEngine::isCaseSensitive() } //static -QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) +QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data) { return link; // TODO implement } diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 71a604a..c7df5ed 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -861,75 +861,9 @@ QString QFSFileEngine::fileName(FileName file) const return entry.filePath(); } else if (file == LinkName) { if (d->isSymlink()) { -#if defined(__GLIBC__) && !defined(PATH_MAX) -#define PATH_CHUNK_SIZE 256 - char *s = 0; - int len = -1; - int size = PATH_CHUNK_SIZE; - - while (1) { - s = (char *) ::realloc(s, size); - Q_CHECK_PTR(s); - len = ::readlink(d->fileEntry.nativeFilePath().constData(), s, size); - if (len < 0) { - ::free(s); - break; - } - if (len < size) { - break; - } - size *= 2; - } -#else - char s[PATH_MAX+1]; - int len = readlink(d->fileEntry.nativeFilePath().constData(), s, PATH_MAX); -#endif - if (len > 0) { - QString ret; - if (d->doStat(QFileSystemMetaData::DirectoryType) - && d->metaData.isDirectory() && s[0] != '/') { - QDir parent(d->fileEntry.filePath()); - parent.cdUp(); - ret = parent.path(); - if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) - ret += QLatin1Char('/'); - } - s[len] = '\0'; - ret += QFile::decodeName(QByteArray(s)); -#if defined(__GLIBC__) && !defined(PATH_MAX) - ::free(s); -#endif - - if (!ret.startsWith(QLatin1Char('/'))) { - if (d->fileEntry.filePath().startsWith(QLatin1Char('/'))) { - ret.prepend(d->fileEntry.filePath().left(d->fileEntry.filePath().lastIndexOf(QLatin1Char('/'))) - + QLatin1Char('/')); - } else { - ret.prepend(QDir::currentPath() + QLatin1Char('/')); - } - } - ret = QDir::cleanPath(ret); - if (ret.size() > 1 && ret.endsWith(QLatin1Char('/'))) - ret.chop(1); - return ret; - } + QFileSystemEntry entry = QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData); + return entry.filePath(); } -#if !defined(QWS) && defined(Q_OS_MAC) - { - FSRef fref; - if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(d->fileEntry.filePath())).data(), &fref, 0) == noErr) { - Boolean isAlias, isFolder; - if (FSResolveAliasFile(&fref, true, &isFolder, &isAlias) == noErr && isAlias) { - AliasHandle alias; - if (FSNewAlias(0, &fref, &alias) == noErr && alias) { - QCFString cfstr; - if (FSCopyAliasInfo(alias, 0, 0, &cfstr, 0, 0) == noErr) - return QCFString::toQString(cfstr); - } - } - } - } -#endif return QString(); } return d->fileEntry.filePath(); -- cgit v0.12 From 309f0d3d1f4bcc42249e738bae544750fe8cdb6a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 7 Sep 2010 11:11:29 +0100 Subject: Helper functions for converting Symbian OS TTime convert to/from QDateTime convert to/from time_t These functions are required for dealing with timestamps in native files, however they are generally useful for Qt/Symbian port as well. Reviewed-By: joao --- src/corelib/tools/qdatetime.cpp | 35 +++++++++++++++++++++++++++++++++++ src/corelib/tools/qdatetime_p.h | 6 ++++++ 2 files changed, 41 insertions(+) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ab7530d..f21aa2e 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -5837,6 +5837,41 @@ bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::S return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count); } +#ifdef Q_OS_SYMBIAN +const static TTime UnixEpochOffset(I64LIT(0xdcddb30f2f8000)); +const static TInt64 MinimumMillisecondTime(KMinTInt64 / 1000); +const static TInt64 MaximumMillisecondTime(KMaxTInt64 / 1000); +QDateTime qt_symbian_TTime_To_QDateTime(const TTime& time) +{ + TTimeIntervalMicroSeconds absolute = time.MicroSecondsFrom(UnixEpochOffset); + + return QDateTime::fromMSecsSinceEpoch(absolute.Int64() / 1000); +} + +TTime qt_symbian_QDateTime_To_TTime(const QDateTime& datetime) +{ + qint64 absolute = datetime.toMSecsSinceEpoch(); + if(absolute > MaximumMillisecondTime) + return TTime(KMaxTInt64); + if(absolute < MinimumMillisecondTime) + return TTime(KMinTInt64); + return TTime(absolute * 1000); +} + +time_t qt_symbian_TTime_To_time_t(const TTime& time) +{ + TTimeIntervalSeconds interval; + TInt err = time.SecondsFrom(UnixEpochOffset, interval); + if (err || interval.Int() < 0) + return (time_t) 0; + return (time_t) interval.Int(); +} + +TTime qt_symbian_time_t_To_TTime(time_t time) +{ + return UnixEpochOffset + TTimeIntervalSeconds(time); +} +#endif //Q_OS_SYMBIAN #endif // QT_BOOTSTRAPPED diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h index f10785e..8355ef7 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -275,6 +275,12 @@ Q_CORE_EXPORT bool operator==(const QDateTimeParser::SectionNode &s1, const QDat Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeParser::Sections) Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeParser::FieldInfo) +#ifdef Q_OS_SYMBIAN +QDateTime qt_symbian_TTime_To_QDateTime(const TTime& time); +TTime qt_symbian_QDateTime_To_TTime(const QDateTime& datetime); +time_t qt_symbian_TTime_To_time_t(const TTime& time); +TTime qt_symbian_time_t_To_TTime(time_t time); +#endif //Q_OS_SYMBIAN #endif // QT_BOOTSTRAPPED -- cgit v0.12 From a6611da5a67f2689586fd9367405dec2429f9cde Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 7 Sep 2010 11:50:51 +0100 Subject: Symbian OS implementation for QFileSystemMetaData There are three possible sources for metadata: RFs::Entry() - for files or directories in the filesystem (except roots) RFs::Volume() - for mounted drives (used for root directory) ::fstat() - for Open C file handles adopted via QFile::open(int, OpenMode) As a result of the ::fstat requirement, the code dealing with stat buffers is moved from qfilesystemengine_unix.cpp to the common qfilesystemengine.cpp Reviewed-By: joao --- src/corelib/io/qfilesystemengine.cpp | 72 +++++++++++++++++++++++++++ src/corelib/io/qfilesystemengine_symbian.cpp | 74 ++++++++++++++++++++++++++-- src/corelib/io/qfilesystemengine_unix.cpp | 63 ----------------------- src/corelib/io/qfilesystemmetadata_p.h | 46 ++++++++++++++++- 4 files changed, 187 insertions(+), 68 deletions(-) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 8f5b98a..0563a15 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -213,4 +213,76 @@ QAbstractFileEngine *QFileSystemEngine::resolveEntryAndCreateLegacyEngine( return engine; } +//these unix functions are in this file, because they are shared by symbian port +//for open C file handles. +#ifdef Q_OS_UNIX +//static +bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data) +{ + data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags; + data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags; + + QT_STATBUF statBuffer; + if (QT_FSTAT(fd, &statBuffer) == 0) { + data.fillFromStatBuf(statBuffer); + return true; + } + + return false; +} + +void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) +{ + // Permissions + if (statBuffer.st_mode & S_IRUSR) + entryFlags |= QFileSystemMetaData::OwnerReadPermission; + if (statBuffer.st_mode & S_IWUSR) + entryFlags |= QFileSystemMetaData::OwnerWritePermission; + if (statBuffer.st_mode & S_IXUSR) + entryFlags |= QFileSystemMetaData::OwnerExecutePermission; + + if (statBuffer.st_mode & S_IRGRP) + entryFlags |= QFileSystemMetaData::GroupReadPermission; + if (statBuffer.st_mode & S_IWGRP) + entryFlags |= QFileSystemMetaData::GroupWritePermission; + if (statBuffer.st_mode & S_IXGRP) + entryFlags |= QFileSystemMetaData::GroupExecutePermission; + + if (statBuffer.st_mode & S_IROTH) + entryFlags |= QFileSystemMetaData::OtherReadPermission; + if (statBuffer.st_mode & S_IWOTH) + entryFlags |= QFileSystemMetaData::OtherWritePermission; + if (statBuffer.st_mode & S_IXOTH) + entryFlags |= QFileSystemMetaData::OtherExecutePermission; + + // Type + if ((statBuffer.st_mode & S_IFMT) == S_IFREG) + entryFlags |= QFileSystemMetaData::FileType; + else if ((statBuffer.st_mode & S_IFMT) == S_IFDIR) + entryFlags |= QFileSystemMetaData::DirectoryType; + else + entryFlags |= QFileSystemMetaData::SequentialType; + + // Attributes + entryFlags |= QFileSystemMetaData::ExistsAttribute; + size_ = statBuffer.st_size; +#if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if (statBuffer.st_flags & UF_HIDDEN) { + entryFlags |= QFileSystemMetaData::HiddenAttribute; + knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; + } +#endif + + // Times +#ifdef Q_OS_SYMBIAN + modificationTime_ = qt_symbian_time_t_To_TTime(statBuffer.st_mtime); +#else + creationTime_ = statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime; + modificationTime_ = statBuffer.st_mtime; + accessTime_ = statBuffer.st_atime; +#endif +} + +#endif + QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 2798bdf..19f149a 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -108,13 +108,76 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) //static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { - return QString(); // TODO implement; + Q_UNUSED(entry); + return QString(); +} + +void QFileSystemMetaData::fillFromTEntry(const TEntry& entry) +{ + //Symbian doesn't have unix type file permissions + entryFlags |= QFileSystemMetaData::Permissions; + if(entry.IsReadOnly()) { + entryFlags &= ~(QFileSystemMetaData::WritePermissions); + } + //set the type + if(entry.IsDir()) + entryFlags |= QFileSystemMetaData::DirectoryType; + else + entryFlags |= QFileSystemMetaData::FileType; + + //set the attributes + entryFlags |= QFileSystemMetaData::ExistsAttribute; + if(entry.IsHidden()) + entryFlags |= QFileSystemMetaData::HiddenAttribute; + +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API + size_ = entry.FileSize(); +#else + size_ = (TUint)(entry.iSize); +#endif + + modificationTime_ = entry.iModified; +} + +void QFileSystemMetaData::fillFromVolumeInfo(const TVolumeInfo& info) +{ + entryFlags |= QFileSystemMetaData::ExistsAttribute; + entryFlags |= QFileSystemMetaData::Permissions; + if(info.iDrive.iDriveAtt & KDriveAttRom) { + entryFlags &= ~(QFileSystemMetaData::WritePermissions); + } + entryFlags |= QFileSystemMetaData::DirectoryType; + size_ = info.iSize; + modificationTime_ = qt_symbian_time_t_To_TTime(0); } //static bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { - return false; // TODO implement; + if (what & QFileSystemMetaData::SymbianTEntryFlags) { + RFs& fs(qt_s60GetRFs()); + TInt err; + data.entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); + if (entry.isRoot()) { + //Root directories don't have an entry, and Entry() returns KErrBadName. + //Therefore get information about the volume instead. + TInt drive; + err = RFs::CharToDrive(TChar(entry.nativeFilePath().at(0).unicode()), drive); + if (!err) { + TVolumeInfo info; + err = fs.Volume(info, drive); + if (!err) + data.fillFromVolumeInfo(info); + } + } else { + TEntry ent; + err = fs.Entry(qt_QString2TPtrC(absoluteName(entry).nativeFilePath()), ent); + if (!err) + data.fillFromTEntry(ent); + } + data.knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags; + } + return data.hasFlags(what); } //static @@ -207,7 +270,12 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per else setmask = KEntryAttReadOnly; TInt err = fs.SetAtt(qt_QString2TPtrC(targetpath), setmask, clearmask); - return err != KErrNone; // TODO error reporting, metadata update; + if (data && !err) { + data->entryFlags &= ~QFileSystemMetaData::Permissions; + data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions)); + data->knownFlagsMask |= QFileSystemMetaData::Permissions; + } + return err != KErrNone; // TODO error reporting } QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 755298d..f26a8c0 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -105,54 +105,6 @@ static inline bool _q_isMacHidden(const char *nativePath) } #endif -void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) -{ - // Permissions - if (statBuffer.st_mode & S_IRUSR) - entryFlags |= QFileSystemMetaData::OwnerReadPermission; - if (statBuffer.st_mode & S_IWUSR) - entryFlags |= QFileSystemMetaData::OwnerWritePermission; - if (statBuffer.st_mode & S_IXUSR) - entryFlags |= QFileSystemMetaData::OwnerExecutePermission; - - if (statBuffer.st_mode & S_IRGRP) - entryFlags |= QFileSystemMetaData::GroupReadPermission; - if (statBuffer.st_mode & S_IWGRP) - entryFlags |= QFileSystemMetaData::GroupWritePermission; - if (statBuffer.st_mode & S_IXGRP) - entryFlags |= QFileSystemMetaData::GroupExecutePermission; - - if (statBuffer.st_mode & S_IROTH) - entryFlags |= QFileSystemMetaData::OtherReadPermission; - if (statBuffer.st_mode & S_IWOTH) - entryFlags |= QFileSystemMetaData::OtherWritePermission; - if (statBuffer.st_mode & S_IXOTH) - entryFlags |= QFileSystemMetaData::OtherExecutePermission; - - // Type - if ((statBuffer.st_mode & S_IFMT) == S_IFREG) - entryFlags |= QFileSystemMetaData::FileType; - else if ((statBuffer.st_mode & S_IFMT) == S_IFDIR) - entryFlags |= QFileSystemMetaData::DirectoryType; - else - entryFlags |= QFileSystemMetaData::SequentialType; - - // Attributes - entryFlags |= QFileSystemMetaData::ExistsAttribute; - size_ = statBuffer.st_size; -#if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (statBuffer.st_flags & UF_HIDDEN) { - entryFlags |= QFileSystemMetaData::HiddenAttribute; - knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; - } -#endif - - // Times - creationTime_ = statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime; - modificationTime_ = statBuffer.st_mtime; - accessTime_ = statBuffer.st_atime; -} - bool QFileSystemEngine::isCaseSensitive() { #if defined(Q_OS_SYMBIAN) @@ -329,21 +281,6 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) } //static -bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data) -{ - data.entryFlags &= ~QFileSystemMetaData::PosixStatFlags; - data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags; - - QT_STATBUF statBuffer; - if (QT_FSTAT(fd, &statBuffer) == 0) { - data.fillFromStatBuf(statBuffer); - return true; - } - - return false; -} - -//static bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 5914eb3..f140319 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -60,6 +60,9 @@ // Platform-specific includes #if defined(Q_OS_WIN) +#elif defined(Q_OS_SYMBIAN) +#include +#include "qdatetime_p.h" #else #endif @@ -86,10 +89,18 @@ struct QFileSystemMetaData UserPermissions = UserReadPermission | UserWritePermission | UserExecutePermission, OwnerPermissions = OwnerReadPermission | OwnerWritePermission | OwnerExecutePermission, + ReadPermissions = OtherReadPermission | GroupReadPermission | UserReadPermission | OwnerReadPermission, + WritePermissions = OtherWritePermission | GroupWritePermission | UserWritePermission | OwnerWritePermission, + ExecutePermissions = OtherExecutePermission | GroupExecutePermission | UserExecutePermission | OwnerExecutePermission, + Permissions = OtherPermissions | GroupPermissions | UserPermissions | OwnerPermissions, // Type +#ifdef Q_OS_SYMBIAN + LinkType = 0, +#else LinkType = 0x00010000, +#endif FileType = 0x00020000, DirectoryType = 0x00040000, #if !defined(QWS) && defined(Q_OS_MAC) @@ -137,6 +148,13 @@ struct QFileSystemMetaData | QFileSystemMetaData::Times | QFileSystemMetaData::OwnerIds, + SymbianTEntryFlags = QFileSystemMetaData::Permissions + | QFileSystemMetaData::FileType + | QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::SequentialType + | QFileSystemMetaData::Attributes + | QFileSystemMetaData::Times, + AllMetaDataFlags = 0xFFFFFFFF }; @@ -181,7 +199,7 @@ struct QFileSystemMetaData QFile::Permissions permissions() const { return QFile::Permissions(Permissions & entryFlags); } -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) && !defined (Q_OS_SYMBIAN) QDateTime creationTime() const { return QDateTime::fromTime_t(creationTime_); } QDateTime modificationTime() const { return QDateTime::fromTime_t(modificationTime_); } QDateTime accessTime() const { return QDateTime::fromTime_t(accessTime_); } @@ -213,9 +231,31 @@ struct QFileSystemMetaData else return groupId(); } - +#endif +#ifdef Q_OS_UNIX void fillFromStatBuf(const QT_STATBUF &statBuffer); #endif +#ifdef Q_OS_SYMBIAN + QDateTime creationTime() const { return modificationTime(); } + QDateTime modificationTime() const { return qt_symbian_TTime_To_QDateTime(modificationTime_); } + QDateTime accessTime() const { return modificationTime(); } + + QDateTime fileTime(QAbstractFileEngine::FileTime time) const + { + Q_UNUSED(time); + return modificationTime(); + } + uint userId() const { return (uint) -2; } + uint groupId() const { return (uint) -2; } + uint ownerId(QAbstractFileEngine::FileOwner owner) const + { + Q_UNUSED(owner); + return (uint) -2; + } + + void fillFromTEntry(const TEntry& entry); + void fillFromVolumeInfo(const TVolumeInfo& info); +#endif private: friend class QFileSystemEngine; @@ -227,6 +267,8 @@ private: // Platform-specific data goes here: #if defined(Q_OS_WIN) +#elif defined(Q_OS_SYMBIAN) + TTime modificationTime_; #else time_t creationTime_; time_t modificationTime_; -- cgit v0.12 From bbbe13b676d297f0f5bfb754cdfe5ff1848c67b7 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 7 Sep 2010 16:47:02 +0100 Subject: Add missing function parameter to implementation To fix compile error due to header changes upstream Reviewed-By: Trust Me --- src/corelib/io/qfilesystemengine_symbian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 19f149a..45c3c10 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -53,7 +53,7 @@ bool QFileSystemEngine::isCaseSensitive() } //static -QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link) +QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data) { return link; // TODO implement } -- cgit v0.12 From 0b662bd90347d152bf7371f1554e7bd2175704d8 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 8 Sep 2010 14:02:19 +0100 Subject: Implement QFileSystemEngine::absoluteName for symbian OS Updated this function so that it passes the QFileInfo autotests. Now deals with raw drives "x:" Drive relative paths "x:foo.txt" Absolute paths missing a drive letter "/sys" Dirty absolute paths "c:/bar/../foo" Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 31 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 45c3c10..3638196 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -80,23 +80,40 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) //static QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) { - if (entry.isAbsolute()) + QString orig = entry.filePath(); + const bool needsDrive = (!orig.isEmpty() && orig.at(0).unicode() == '/'); + const bool isDriveLetter = (orig.size() == 2 && orig.at(1).unicode() == ':'); + const bool isDriveRelative = (orig.size() > 2 && orig.at(1).unicode() == ':' && orig.at(2).unicode() != '/'); + const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) || + orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/."))); + const bool isAbsolute = entry.isAbsolute(); + if (isAbsolute && + !(needsDrive || isDriveLetter || isDriveRelative || isDirty)) return entry; - QString orig = entry.filePath(); QString result; - if (orig.isEmpty() || !orig.startsWith('/')) { + if (needsDrive || isDriveLetter || isDriveRelative || !isAbsolute || orig.isEmpty()) { QFileSystemEntry cur(QFSFileEngine::currentPath()); - result = cur.filePath(); + if(needsDrive) + result = cur.filePath().left(2); + else if(isDriveRelative && cur.filePath().at(0) != orig.at(0)) + result = orig.left(2); // for BC, see tst_QFileInfo::absolutePath(:my.dll) + else + result = cur.filePath(); + if(isDriveLetter) { + result[0] = orig.at(0); //copy drive letter + orig.clear(); + } + if(isDriveRelative) { + orig = orig.mid(2); //discard the drive specifier from orig + } } - if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) { + if (!orig.isEmpty() && !(orig.length() == 1 && orig.at(0).unicode() == '.')) { if (!result.isEmpty() && !result.endsWith('/')) result.append('/'); result.append(orig); } - if (result.length() == 1 && result[0] == '/') - return QFileSystemEntry(result); const bool isDir = result.endsWith('/'); result = QDir::cleanPath(result); -- cgit v0.12 From f906303e7aa9a7b68f469d81e6bdac8499120338 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 8 Sep 2010 14:08:13 +0100 Subject: Disable tst_qfileinfo symlink tests on symbian Reviewed-By: joao --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 7659a75..9ec0572 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -72,6 +72,7 @@ #if defined(Q_OS_SYMBIAN) # define SRCDIR "" +# define NO_SYMLINKS #endif //TESTED_CLASS= @@ -1081,6 +1082,7 @@ void tst_QFileInfo::fileTimes_oldFile() void tst_QFileInfo::isSymLink_data() { +#ifndef NO_SYMLINKS QFile::remove("link.lnk"); QFile::remove("brokenlink.lnk"); QFile::remove("dummyfile"); @@ -1100,10 +1102,12 @@ void tst_QFileInfo::isSymLink_data() QTest::newRow("existent file") << SRCDIR "tst_qfileinfo.cpp" << false << ""; QTest::newRow("link") << "link.lnk" << true << QFileInfo(SRCDIR "tst_qfileinfo.cpp").absoluteFilePath(); QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath(); +#endif } void tst_QFileInfo::isSymLink() { +#ifndef NO_SYMLINKS QFETCH(QString, path); QFETCH(bool, isSymLink); QFETCH(QString, linkTarget); @@ -1111,6 +1115,9 @@ void tst_QFileInfo::isSymLink() QFileInfo fi(path); QCOMPARE(fi.isSymLink(), isSymLink); QCOMPARE(fi.symLinkTarget(), linkTarget); +#else + QSKIP("no symbolic link support on this platform", SkipAll); +#endif } void tst_QFileInfo::isHidden_data() -- cgit v0.12 From e4de050cc8e819a2751f94ac0429a0d7fe64e64a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 8 Sep 2010 15:15:45 +0100 Subject: Enable symbian IO code in the build This patch contains several changes that needed to be done atomically. The native file path im QFileSystemEntry is changed from 8 bit to 16 bit character set. QFsFileEngine has some new symbian specific code (as the unix code does not compile with the above change), and forwards more calls to the new QFileSystemEngine. Unix implementations of link, rename and remove are moved to the unix version of this class, so less ifdef'ing is needed. Finally, io.pri now selects the _symbian.cpp source files instead of the _unix.cpp equivalents when building for symbian. --- src/corelib/io/io.pri | 15 +- src/corelib/io/qfilesystemengine_unix.cpp | 8 +- src/corelib/io/qfilesystementry.cpp | 7 +- src/corelib/io/qfilesystementry_p.h | 6 +- src/corelib/io/qfsfileengine.cpp | 6 + src/corelib/io/qfsfileengine_p.h | 28 +++ src/corelib/io/qfsfileengine_unix.cpp | 343 +++++++++++++++++------------- 7 files changed, 250 insertions(+), 163 deletions(-) diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 7c3712e..4a20dfa 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -73,12 +73,17 @@ win32 { SOURCES += io/qfilesystemengine_win.cpp SOURCES += io/qfilesystemiterator_win.cpp } else:unix { - SOURCES += io/qfilesystemengine_unix.cpp - SOURCES += io/qfilesystemiterator_unix.cpp - SOURCES += io/qfsfileengine_unix.cpp SOURCES += io/qfsfileengine_iterator_unix.cpp - symbian:SOURCES += io/qprocess_symbian.cpp - else:SOURCES += io/qprocess_unix.cpp + SOURCES += io/qfsfileengine_unix.cpp + symbian { + SOURCES += io/qfilesystemengine_symbian.cpp + SOURCES += io/qprocess_symbian.cpp + SOURCES += io/qfilesystemiterator_symbian.cpp + } else { + SOURCES += io/qfilesystemengine_unix.cpp + SOURCES += io/qprocess_unix.cpp + SOURCES += io/qfilesystemiterator_unix.cpp + } macx-*: { HEADERS += io/qfilesystemwatcher_fsevents_p.h SOURCES += io/qfilesystemengine_mac.cpp diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index f26a8c0..8d77963 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -45,6 +45,8 @@ #include "qfsfileengine.h" #include // for realpath() +#include +#include #include #if defined(Q_OS_SYMBIAN) @@ -489,7 +491,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo //static bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) { - return false; // TODO implement; + return (::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0); } //static @@ -501,13 +503,13 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst //static bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) { - return false; // TODO implement; + return (::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0); } //static bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) { - return false; // TODO implement; + return (unlink(entry.nativeFilePath().constData()) == 0); } //static diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index c3ada48..f5009b4 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -121,7 +121,7 @@ QFileSystemEntry::NativePath QFileSystemEntry::nativeFilePath() const void QFileSystemEntry::resolveFilePath() const { if (m_filePath.isEmpty() && !m_nativeFilePath.isEmpty()) { -#ifdef Q_OS_WIN +#ifdef QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16 m_filePath = QDir::fromNativeSeparators(m_nativeFilePath); #else m_filePath = QDir::fromNativeSeparators(QFile::decodeName(m_nativeFilePath)); @@ -137,6 +137,8 @@ void QFileSystemEntry::resolveNativeFilePath() const if (isRelative()) filePath = fixIfRelativeUncPath(m_filePath); m_nativeFilePath = QFSFileEnginePrivate::longFileName(QDir::toNativeSeparators(filePath)); +#elif defined(QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16) + m_nativeFilePath = QDir::toNativeSeparators(m_filePath); #else m_nativeFilePath = QFile::encodeName(QDir::toNativeSeparators(m_filePath)); #endif @@ -199,11 +201,10 @@ bool QFileSystemEntry::isAbsolute() const return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/') #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) || (m_filePath.length() >= 2 - && ((m_filePath[0].isLetter() && m_filePath[1] == QLatin1Char(':')) + && ((m_filePath[0].isLetter() && m_filePath[1].unicode() == ':') || (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/')))) #endif ); - } #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 3786bb3..6b2cedd 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -56,13 +56,17 @@ #include #include +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) +#define QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16 +#endif + QT_BEGIN_NAMESPACE class QFileSystemEntry { public: -#ifndef Q_OS_WIN +#ifndef QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16 typedef QByteArray NativePath; #else typedef QString NativePath; diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 1b0a28c..089f1a1 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -364,6 +364,12 @@ bool QFSFileEnginePrivate::closeFdFh() if (closeFileHandle) { int ret; do { +#ifdef Q_OS_SYMBIAN + if (symbianFile.SubSessionHandle()) { + symbianFile.Close(); + ret = 0; + } else +#endif if (fh) { // Close buffered file. ret = fclose(fh) != 0 ? -1 : 0; diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 6e5f30e..a3733d8 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -60,6 +60,10 @@ #include #include +#ifdef Q_OS_SYMBIAN +#include +#endif + #ifndef QT_NO_FSFILEENGINE QT_BEGIN_NAMESPACE @@ -115,6 +119,30 @@ public: #endif FILE *fh; +#ifdef Q_OS_SYMBIAN +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API + RFile64 symbianFile; + TInt64 symbianFilePos; +#else + RFile symbianFile; + + /** + * The cursor position in the underlying file. This differs + * from devicePos because the latter is updated on calls to + * writeData, even if no data was physically transferred to + * the file, but instead stored in the write buffer. + * + * iFilePos is updated on calls to RFile::Read and + * RFile::Write. It is also updated on calls to seek() but + * RFile::Seek is not called when that happens because + * Symbian supports positioned reads and writes, saving a file + * server call, and because Symbian does not support seeking + * past the end of a file. + */ + TInt symbianFilePos; +#endif +#endif + #ifdef Q_WS_WIN HANDLE fileHandle; HANDLE mapHandle; diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index c7df5ed..048aa1b 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -197,6 +197,90 @@ static inline bool setCloseOnExec(int fd) return fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) != -1; } +#ifdef Q_OS_SYMBIAN +/*! + \internal +*/ +bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) +{ + Q_Q(QFSFileEngine); + + fh = 0; + fd = -1; + + QString fn(QFileSystemEngine::absoluteName(fileEntry).nativeFilePath()); + RFs& fs = qt_s60GetRFs(); + + TUint symbianMode = 0; + + if(openMode & QIODevice::ReadOnly) + symbianMode |= EFileRead; + if(openMode & QIODevice::WriteOnly) + symbianMode |= EFileWrite; + if(openMode & QIODevice::Text) + symbianMode |= EFileStreamText; + + // pre Symbian 9.4, file I/O is always unbuffered, and the enum values don't exist + if(QSysInfo::symbianVersion() >= QSysInfo::SV_9_4) { + if (openMode & QFile::Unbuffered) { + if (openMode & QIODevice::WriteOnly) + symbianMode |= 0x00001000; //EFileWriteDirectIO; + if (openMode & QIODevice::ReadOnly) + symbianMode |= 0x00004000; //EFileReadDirectIO; + } else { + if (openMode & QIODevice::WriteOnly) + symbianMode |= 0x00000800; //EFileWriteBuffered; + // use implementation defaults for read buffering + } + } + + // Until Qt supports file sharing, we can't support EFileShareReadersOrWriters safely, + // but Qt does this on other platforms and autotests rely on it. + // The reason is that Unix locks are only advisory - the application needs to test the + // lock after opening the file. Symbian and Windows locks are mandatory - opening a + // locked file will fail. + symbianMode |= EFileShareReadersOrWriters; + + TInt r; + //note QIODevice::Truncate only has meaning for read/write access + //write-only files are always truncated unless append is specified + //reference openModeToOpenFlags in qfsfileengine_unix.cpp + if ((openMode & QIODevice::Truncate) || (!(openMode & QIODevice::ReadOnly) && !(openMode & QIODevice::Append))) { + r = symbianFile.Replace(fs, qt_QString2TPtrC(fn), symbianMode); + } else { + r = symbianFile.Open(fs, qt_QString2TPtrC(fn), symbianMode); + if (r == KErrNotFound && (openMode & QIODevice::WriteOnly)) { + r = symbianFile.Create(fs, qt_QString2TPtrC(fn), symbianMode); + } + } + + if (r == KErrNone) { +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API + TInt64 size; +#else + TInt size; +#endif + r = symbianFile.Size(size); + if (r==KErrNone) { + if (openMode & QIODevice::Append) + symbianFilePos = size; + else + symbianFilePos = 0; + //TODO: port this (QFileSystemMetaData in open?) + //cachedSize = size; + } + } + + if (r != KErrNone) { + setSymbianError(r, QFile::OpenError, QLatin1String("open error")); + symbianFile.Close(); + return false; + } + + closeFileHandle = true; + return true; +} +#else /*! \internal */ @@ -293,6 +377,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) closeFileHandle = true; return true; } +#endif /*! \internal @@ -423,61 +508,64 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - bool ret = unlink(d->fileEntry.nativeFilePath().constData()) == 0; - if (!ret) + bool ret = QFileSystemEngine::removeFile(d->fileEntry); + if (!ret) { +#ifdef Q_OS_SYMBIAN + //TODO: error reporting + d->setSymbianError(KErrGeneral, QFile::RemoveError, QLatin1String("remove error")); +#else setError(QFile::RemoveError, qt_error_string(errno)); +#endif + } return ret; } bool QFSFileEngine::copy(const QString &newName) { -#if defined(Q_OS_SYMBIAN) Q_D(QFSFileEngine); - RFs rfs = qt_s60GetRFs(); - CFileMan* fm = NULL; - QString oldNative(QDir::toNativeSeparators(d->fileEntry.filePath())); - TPtrC oldPtr(qt_QString2TPtrC(oldNative)); - QFileInfo fi(newName); - QString absoluteNewName = fi.absoluteFilePath(); - QString newNative(QDir::toNativeSeparators(absoluteNewName)); - TPtrC newPtr(qt_QString2TPtrC(newNative)); - TRAPD (err, - fm = CFileMan::NewL(rfs); - RFile rfile; - err = rfile.Open(rfs, oldPtr, EFileShareReadersOrWriters); - if (err == KErrNone) { - err = fm->Copy(rfile, newPtr); - rfile.Close(); - } - ) // End TRAP - delete fm; - if (err == KErrNone) - return true; - d->setSymbianError(err, QFile::CopyError, QLatin1String("copy error")); - return false; + bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName)); + if (!ret) { +#ifdef Q_OS_SYMBIAN + //TODO: error reporting + d->setSymbianError(KErrGeneral, QFile::CopyError, QLatin1String("copy error")); #else - Q_UNUSED(newName); - // ### Add copy code for Unix here - setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); - return false; + // ### Add copy code for Unix to the filesystem engine + setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); + //setError(QFile::CopyError, qt_error_string(errno)); #endif + } + return ret; } bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - bool ret = ::rename(d->fileEntry.nativeFilePath().constData(), QFile::encodeName(newName).constData()) == 0; - if (!ret) + bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName)); + + if (!ret) { +#ifdef Q_OS_SYMBIAN + //TODO: error reporting + d->setSymbianError(KErrGeneral, QFile::RenameError, QLatin1String("rename error")); +#else setError(QFile::RenameError, qt_error_string(errno)); +#endif + } + return ret; } bool QFSFileEngine::link(const QString &newName) { Q_D(QFSFileEngine); - bool ret = ::symlink(d->fileEntry.nativeFilePath().constData(), QFile::encodeName(newName).constData()) == 0; - if (!ret) + bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName)); + if (!ret) { +#ifdef Q_OS_SYMBIAN + //TODO: error reporting + d->setSymbianError(KErrNotSupported, QFile::RenameError, QLatin1String("not supported")); +#else setError(QFile::RenameError, qt_error_string(errno)); +#endif + } return ret; } @@ -722,123 +810,6 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const return ret; } -#if defined(Q_OS_SYMBIAN) -QString QFSFileEngine::fileName(FileName file) const -{ - Q_D(const QFSFileEngine); - const QLatin1Char slashChar('/'); - if(file == BaseName) { - int slash = d->fileEntry.filePath().lastIndexOf(slashChar); - if(slash == -1) { - int colon = d->fileEntry.filePath().lastIndexOf(QLatin1Char(':')); - if(colon != -1) - return d->fileEntry.filePath().mid(colon + 1); - return d->fileEntry.filePath(); - } - return d->fileEntry.filePath().mid(slash + 1); - } else if(file == PathName) { - if(!d->fileEntry.filePath().size()) - return d->fileEntry.filePath(); - - int slash = d->fileEntry.filePath().lastIndexOf(slashChar); - if(slash == -1) { - if(d->fileEntry.filePath().length() >= 2 && d->fileEntry.filePath().at(1) == QLatin1Char(':')) - return d->fileEntry.filePath().left(2); - return QLatin1String("."); - } else { - if(!slash) - return QLatin1String("/"); - if(slash == 2 && d->fileEntry.filePath().length() >= 2 && d->fileEntry.filePath().at(1) == QLatin1Char(':')) - slash++; - return d->fileEntry.filePath().left(slash); - } - } else if(file == AbsoluteName || file == AbsolutePathName) { - QString ret; - if (!isRelativePathSymbian(d->fileEntry.filePath())) { - if (d->fileEntry.filePath().size() > 2 && d->fileEntry.filePath().at(1) == QLatin1Char(':') - && d->fileEntry.filePath().at(2) != slashChar){ - // It's a drive-relative path, so C:a.txt -> C:/currentpath/a.txt, - // or if it's different drive than current, Z:a.txt -> Z:/a.txt - QString currentPath = QDir::currentPath(); - if (0 == currentPath.left(1).compare(d->fileEntry.filePath().left(1), Qt::CaseInsensitive)) - ret = currentPath + slashChar + d->fileEntry.filePath().mid(2); - else - ret = d->fileEntry.filePath().left(2) + slashChar + d->fileEntry.filePath().mid(2); - } else if (d->fileEntry.filePath().startsWith(slashChar)) { - // It's a absolute path to the current drive, so /a.txt -> C:/a.txt - ret = QDir::currentPath().left(2) + d->fileEntry.filePath(); - } else { - ret = d->fileEntry.filePath(); - } - } else { - ret = QDir::currentPath() + slashChar + d->fileEntry.filePath(); - } - - // The path should be absolute at this point. - // From the docs : - // Absolute paths begin with the directory separator "/" - // (optionally preceded by a drive specification under Windows). - if (ret.at(0) != slashChar) { - Q_ASSERT(ret.length() >= 2); - Q_ASSERT(ret.at(0).isLetter()); - Q_ASSERT(ret.at(1) == QLatin1Char(':')); - - // Force uppercase drive letters. - ret[0] = ret.at(0).toUpper(); - } - - // Clean up the path - bool isDir = ret.endsWith(slashChar); - ret = QDir::cleanPath(ret); - if (isDir && !ret.endsWith(slashChar)) - ret += slashChar; - - if (file == AbsolutePathName) { - int slash = ret.lastIndexOf(slashChar); - if (slash < 0) - return ret; - else if (ret.at(0) != slashChar && slash == 2) - return ret.left(3); // include the slash - else - return ret.left(slash > 0 ? slash : 1); - } - return ret; - } else if(file == CanonicalName || file == CanonicalPathName) { - QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry)); - if (file == CanonicalPathName) - return entry.path(); - return entry.filePath(); - } else if(file == LinkName) { - if (d->isSymlink()) { - char s[PATH_MAX+1]; - int len = readlink(d->fileEntry.nativeFilePath().constData(), s, PATH_MAX); - if (len > 0) { - s[len] = '\0'; - QString ret = QFile::decodeName(QByteArray(s)); - - if (isRelativePathSymbian(ret)) { - if (!isRelativePathSymbian(d->fileEntry.filePath())) { - ret.prepend(d->fileEntry.filePath().left(d->fileEntry.filePath().lastIndexOf(slashChar)) - + slashChar); - } else { - ret.prepend(QDir::currentPath() + slashChar); - } - } - ret = QDir::cleanPath(ret); - if (ret.size() > 1 && ret.endsWith(slashChar)) - ret.chop(1); - return ret; - } - } - return QString(); - } else if(file == BundleName) { - return QString(); - } - return d->fileEntry.filePath(); -} - -#else - QString QFSFileEngine::fileName(FileName file) const { Q_D(const QFSFileEngine); @@ -868,7 +839,6 @@ QString QFSFileEngine::fileName(FileName file) const } return d->fileEntry.filePath(); } -#endif // Q_OS_SYMBIAN bool QFSFileEngine::isRelativePath() const { @@ -939,6 +909,51 @@ QString QFSFileEngine::owner(FileOwner own) const return QString(); } +#ifdef Q_OS_SYMBIAN +bool QFSFileEngine::setPermissions(uint perms) +{ + Q_D(QFSFileEngine); + //TODO: connect up error reporting properly + if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), 0)) { + setError(QFile::PermissionsError, QString()); + return false; + } + return true; +} + +bool QFSFileEngine::setSize(qint64 size) +{ + Q_D(QFSFileEngine); + bool ret = false; + TInt err = KErrNone; + if (d->symbianFile.SubSessionHandle()) { + TInt err = d->symbianFile.SetSize(size); + ret = (err == KErrNone); + } + if (d->fd != -1) + ret = QT_FTRUNCATE(d->fd, size) == 0; + else if (d->fh) + ret = QT_FTRUNCATE(QT_FILENO(d->fh), size) == 0; + else { + RFile tmp; + QString symbianFilename(d->fileEntry.nativeFilePath()); + err = tmp.Open(qt_s60GetRFs(), qt_QString2TPtrC(symbianFilename), EFileWrite); + if (err == KErrNone) + { + err = tmp.SetSize(size); + tmp.Close(); + } + ret = (err == KErrNone); + } + if (!ret) { + if (err) + d->setSymbianError(err, QFile::ResizeError, QString()); + else + setError(QFile::ResizeError, qt_error_string(errno)); + } + return ret; +} +#else bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); @@ -991,6 +1006,7 @@ bool QFSFileEngine::setSize(qint64 size) setError(QFile::ResizeError, qt_error_string(errno)); return ret; } +#endif QDateTime QFSFileEngine::fileTime(FileTime time) const { @@ -1002,6 +1018,30 @@ QDateTime QFSFileEngine::fileTime(FileTime time) const return QDateTime(); } +#ifdef Q_OS_SYMBIAN +uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) +{ + //Q_Q(QFSFileEngine); + Q_UNUSED(flags) + Q_UNUSED(offset) + Q_UNUSED(size) + return 0; + //TODO: use RFileMap when available in symbian^4 +} + +bool QFSFileEnginePrivate::unmap(uchar *ptr) +{ + //TODO: RFileMap as the value in maps, unmap it here when API is available... + //Q_Q(QFSFileEngine); + //if (!maps.contains(ptr)) { + // q->setError(QFile::PermissionsError, qt_error_string(EACCES)); + // return false; + //} + Q_UNUSED(ptr) + + return false; +} +#else uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) { Q_Q(QFSFileEngine); @@ -1092,6 +1132,7 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) maps.remove(ptr); return true; } +#endif QT_END_NAMESPACE -- cgit v0.12 From 97e8a289380202da7041e40574d58b08a91e0fd0 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 8 Sep 2010 20:20:12 +0100 Subject: Fixes for tst_qfileinfo Use case insensitive comparison on symbian/windows for the absFilePath test. - it expected "c:\\home\\andy\\tmp.txt" to resolve to "C:/home/andy/tmp.txt" - but there is no reason for the drive letter to be changed to uppercase - however it's not wrong either since the FS is case insensitive. Enable isWritable test on symbian - it was skipped for no good reason Reviewed-By: joao --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 9ec0572..08cb68d 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -514,7 +514,11 @@ void tst_QFileInfo::absFilePath() QFETCH(QString, expected); QFileInfo fi(file); +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + QVERIFY(QString::compare(fi.absoluteFilePath(), expected, Qt::CaseInsensitive) == 0); +#else QCOMPARE(fi.absoluteFilePath(), expected); +#endif } void tst_QFileInfo::canonicalPath() @@ -1432,10 +1436,6 @@ void tst_QFileInfo::brokenShortcut() void tst_QFileInfo::isWritable() { -#ifdef Q_OS_SYMBIAN - QSKIP("Currently skipped on Symbian OS, but surely there is a writeable file somewhere???", SkipAll); -#endif - QFile tempfile("tempfile.txt"); tempfile.open(QIODevice::WriteOnly); tempfile.write("This file is generated by the QFileInfo autotest."); @@ -1453,7 +1453,7 @@ void tst_QFileInfo::isWritable() QVERIFY(fi.exists()); QVERIFY(!fi.isWritable()); #endif -#ifdef Q_OS_UNIX +#if defined (Q_OS_UNIX) && !defined (Q_OS_SYMBIAN) if (::getuid() == 0) QVERIFY(QFileInfo("/etc/passwd").isWritable()); else -- cgit v0.12 From 927469d518afa64d8ec8dc54e6169fa43b54cd96 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 8 Sep 2010 20:24:45 +0100 Subject: Fixes for isRoot() on symbian Because "/" is considered to be a root directory, root paths must be converted to absolute paths before volume info can be retrieved. Also special handling in absoluteName is needed to avoid creating "c://" Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 3638196..1205274 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -115,9 +115,10 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) } const bool isDir = result.endsWith('/'); + const bool isRoot = entry.isRoot(); result = QDir::cleanPath(result); - if (isDir) + if (isDir && !isRoot) result.append(QLatin1Char('/')); return QFileSystemEntry(result); } @@ -175,11 +176,12 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM RFs& fs(qt_s60GetRFs()); TInt err; data.entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); - if (entry.isRoot()) { + QFileSystemEntry absentry(absoluteName(entry)); + if (absentry.isRoot()) { //Root directories don't have an entry, and Entry() returns KErrBadName. //Therefore get information about the volume instead. TInt drive; - err = RFs::CharToDrive(TChar(entry.nativeFilePath().at(0).unicode()), drive); + err = RFs::CharToDrive(TChar(absentry.nativeFilePath().at(0).unicode()), drive); if (!err) { TVolumeInfo info; err = fs.Volume(info, drive); @@ -188,7 +190,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } } else { TEntry ent; - err = fs.Entry(qt_QString2TPtrC(absoluteName(entry).nativeFilePath()), ent); + err = fs.Entry(qt_QString2TPtrC(absentry.nativeFilePath()), ent); if (!err) data.fillFromTEntry(ent); } -- cgit v0.12 From d95b3bf38b9c25a38ade7c92fd434e42346729bd Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 8 Sep 2010 20:28:17 +0100 Subject: Implement basic symbian native file IO to QFsFileEngine Enough functionality to be able to read/write files for the tst_qfileinfo autotest to pass. Reviewed-By: joao --- src/corelib/io/qfsfileengine.cpp | 6 ++- src/corelib/io/qfsfileengine_unix.cpp | 95 +++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 089f1a1..9c8df39 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -352,7 +352,11 @@ bool QFSFileEngine::close() bool QFSFileEnginePrivate::closeFdFh() { Q_Q(QFSFileEngine); - if (fd == -1 && !fh) + if (fd == -1 && !fh +#ifdef Q_OS_SYMBIAN + && !symbianFile.SubSessionHandle() +#endif + ) return false; // Flush the file if it's buffered, and if the last flush didn't fail. diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 048aa1b..e4c6f09 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -393,6 +393,10 @@ bool QFSFileEnginePrivate::nativeClose() */ bool QFSFileEnginePrivate::nativeFlush() { +#ifdef Q_OS_SYMBIAN + if (symbianFile.SubSessionHandle()) + return (KErrNone == symbianFile.Flush()); +#endif return fh ? flushFh() : fd != -1; } @@ -403,6 +407,23 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) { Q_Q(QFSFileEngine); +#ifdef Q_OS_SYMBIAN + if (symbianFile.SubSessionHandle()) { + if(len > KMaxTInt) { + //this check is more likely to catch a corrupt length, since it isn't possible to allocate 2GB buffers (yet..) + q->setError(QFile::ReadError, QLatin1String("Maximum 2GB in single read on this platform")); + return -1; + } + TPtr8 ptr(reinterpret_cast(data), static_cast(len)); + TInt r = symbianFile.Read(ptr); + if (r != KErrNone) + { + setSymbianError(r, QFile::ReadError, QLatin1String("read error")); + return -1; + } + return qint64(ptr.Length()); + } +#endif if (fh && nativeIsSequential()) { size_t readBytes = 0; int oldFlags = fcntl(QT_FILENO(fh), F_GETFL); @@ -470,6 +491,24 @@ qint64 QFSFileEnginePrivate::nativeReadLine(char *data, qint64 maxlen) */ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) { + Q_Q(QFSFileEngine); +#ifdef Q_OS_SYMBIAN + if (symbianFile.SubSessionHandle()) { + if(len > KMaxTInt) { + //this check is more likely to catch a corrupt length, since it isn't possible to allocate 2GB buffers (yet..) + q->setError(QFile::WriteError, QLatin1String("Maximum 2GB in single write on this platform")); + return -1; + } + const TPtrC8 ptr(reinterpret_cast(data), static_cast(len)); + TInt r = symbianFile.Write(ptr); + if (r != KErrNone) + { + setSymbianError(r, QFile::WriteError, QLatin1String("write error")); + return -1; + } + return len; + } +#endif return writeFdFh(data, len); } @@ -478,6 +517,22 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) */ qint64 QFSFileEnginePrivate::nativePos() const { +#ifdef Q_OS_SYMBIAN + if (symbianFile.SubSessionHandle()) { +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API + qint64 pos; +#else + TInt pos; +#endif + TInt err = symbianFile.Seek(ESeekCurrent, pos); + if(err != KErrNone) { + //TODO: error reporting + //setSymbianError(err, QFile::PositionError, QLatin1String("seek failed")); + return -1; + } + return pos; + } +#endif return posFdFh(); } @@ -486,6 +541,27 @@ qint64 QFSFileEnginePrivate::nativePos() const */ bool QFSFileEnginePrivate::nativeSeek(qint64 pos) { +#ifdef Q_OS_SYMBIAN + Q_Q(QFSFileEngine); + if (symbianFile.SubSessionHandle()) { +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API + TInt r = symbianFile.Seek(ESeekStart, pos); +#else + if(pos > KMaxTInt) { + q->setError(QFile::PositionError, QLatin1String("Maximum 2GB file position on this platform")); + return false; + } + TInt pos32(pos); + TInt r = symbianFile.Seek(ESeekStart, pos32); +#endif + if (r != KErrNone) + { + setSymbianError(r, QFile::PositionError, QLatin1String("seek failed")); + return false; + } + return true; + } +#endif return seekFdFh(pos); } @@ -502,6 +578,10 @@ int QFSFileEnginePrivate::nativeHandle() const */ bool QFSFileEnginePrivate::nativeIsSequential() const { +#ifdef Q_OS_SYMBIAN + if (symbianFile.SubSessionHandle()) + return false; +#endif return isSequentialFdFh(); } @@ -571,6 +651,21 @@ bool QFSFileEngine::link(const QString &newName) qint64 QFSFileEnginePrivate::nativeSize() const { +#ifdef Q_OS_SYMBIAN + if (symbianFile.SubSessionHandle()) { +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API + qint64 size; +#else + TInt size; +#endif + TInt err = symbianFile.Size(size); + if(err != KErrNone) { + //TODO: error reporting + return 0; + } + return size; + } +#endif return sizeFdFh(); } -- cgit v0.12 From 311f346e49f6d033121840f8740710666c920640 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 9 Sep 2010 11:11:02 +0100 Subject: Update Symbian DEF files To allow file-engines-refactor branch to build. Reviewed-By: Trust Me --- src/s60installs/bwins/QtCoreu.def | 54 +++++++++++++++++++++++++++++++++---- src/s60installs/bwins/QtGuiu.def | 57 ++++++++++++++++++++++++++++++++++++--- src/s60installs/eabi/QtCoreu.def | 46 ++++++++++++++++++++++++++++--- src/s60installs/eabi/QtGuiu.def | 56 +++++++++++++++++++++++++++++++++++--- 4 files changed, 197 insertions(+), 16 deletions(-) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 1a79f63..052ec9a 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -59,7 +59,7 @@ EXPORTS ??0QChildEvent@@QAE@W4Type@QEvent@@PAVQObject@@@Z @ 58 NONAME ; QChildEvent::QChildEvent(enum QEvent::Type, class QObject *) ??0QCoreApplication@@IAE@AAVQCoreApplicationPrivate@@@Z @ 59 NONAME ; QCoreApplication::QCoreApplication(class QCoreApplicationPrivate &) ??0QCoreApplication@@QAE@AAHPAPAD@Z @ 60 NONAME ; QCoreApplication::QCoreApplication(int &, char * *) - ??0QCoreApplicationPrivate@@QAE@AAHPAPAD@Z @ 61 NONAME ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *) + ??0QCoreApplicationPrivate@@QAE@AAHPAPAD@Z @ 61 NONAME ABSENT ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *) ??0QCryptographicHash@@QAE@W4Algorithm@0@@Z @ 62 NONAME ; QCryptographicHash::QCryptographicHash(enum QCryptographicHash::Algorithm) ??0QDataStream@@QAE@ABVQByteArray@@@Z @ 63 NONAME ; QDataStream::QDataStream(class QByteArray const &) ??0QDataStream@@QAE@PAVQByteArray@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z @ 64 NONAME ; QDataStream::QDataStream(class QByteArray *, class QFlags) @@ -1440,8 +1440,8 @@ EXPORTS ?d_func@QBuffer@@ABEPBVQBufferPrivate@@XZ @ 1439 NONAME ; class QBufferPrivate const * QBuffer::d_func(void) const ?d_func@QCoreApplication@@AAEPAVQCoreApplicationPrivate@@XZ @ 1440 NONAME ; class QCoreApplicationPrivate * QCoreApplication::d_func(void) ?d_func@QCoreApplication@@ABEPBVQCoreApplicationPrivate@@XZ @ 1441 NONAME ; class QCoreApplicationPrivate const * QCoreApplication::d_func(void) const - ?d_func@QDir@@AAEPAVQDirPrivate@@XZ @ 1442 NONAME ; class QDirPrivate * QDir::d_func(void) - ?d_func@QDir@@ABEPBVQDirPrivate@@XZ @ 1443 NONAME ; class QDirPrivate const * QDir::d_func(void) const + ?d_func@QDir@@AAEPAVQDirPrivate@@XZ @ 1442 NONAME ABSENT ; class QDirPrivate * QDir::d_func(void) + ?d_func@QDir@@ABEPBVQDirPrivate@@XZ @ 1443 NONAME ABSENT ; class QDirPrivate const * QDir::d_func(void) const ?d_func@QEventDispatcherSymbian@@AAEPAVQAbstractEventDispatcherPrivate@@XZ @ 1444 NONAME ; class QAbstractEventDispatcherPrivate * QEventDispatcherSymbian::d_func(void) ?d_func@QEventDispatcherSymbian@@ABEPBVQAbstractEventDispatcherPrivate@@XZ @ 1445 NONAME ; class QAbstractEventDispatcherPrivate const * QEventDispatcherSymbian::d_func(void) const ?d_func@QEventLoop@@AAEPAVQEventLoopPrivate@@XZ @ 1446 NONAME ; class QEventLoopPrivate * QEventLoop::d_func(void) @@ -3123,7 +3123,7 @@ EXPORTS ?reset@QMetaProperty@@QBE_NPAVQObject@@@Z @ 3122 NONAME ; bool QMetaProperty::reset(class QObject *) const ?reset@QTextStream@@QAEXXZ @ 3123 NONAME ; void QTextStream::reset(void) ?resetCurrentSender@QObjectPrivate@@SAXPAVQObject@@PAUSender@1@1@Z @ 3124 NONAME ; void QObjectPrivate::resetCurrentSender(class QObject *, struct QObjectPrivate::Sender *, struct QObjectPrivate::Sender *) - ?resetDeleteWatch@QObjectPrivate@@SAXPAV1@PAHH@Z @ 3125 NONAME ; void QObjectPrivate::resetDeleteWatch(class QObjectPrivate *, int *, int) + ?resetDeleteWatch@QObjectPrivate@@SAXPAV1@PAHH@Z @ 3125 NONAME ABSENT ; void QObjectPrivate::resetDeleteWatch(class QObjectPrivate *, int *, int) ?resetStatus@QDataStream@@QAEXXZ @ 3126 NONAME ; void QDataStream::resetStatus(void) ?resetStatus@QTextStream@@QAEXXZ @ 3127 NONAME ; void QTextStream::resetStatus(void) ?resize@QBitArray@@QAEXH@Z @ 3128 NONAME ; void QBitArray::resize(int) @@ -3296,7 +3296,7 @@ EXPORTS ?setDefault@QLocale@@SAXABV1@@Z @ 3295 NONAME ; void QLocale::setDefault(class QLocale const &) ?setDefaultFormat@QSettings@@SAXW4Format@1@@Z @ 3296 NONAME ; void QSettings::setDefaultFormat(enum QSettings::Format) ?setDefaultState@QHistoryState@@QAEXPAVQAbstractState@@@Z @ 3297 NONAME ; void QHistoryState::setDefaultState(class QAbstractState *) - ?setDeleteWatch@QObjectPrivate@@SAPAHPAV1@PAH@Z @ 3298 NONAME ; int * QObjectPrivate::setDeleteWatch(class QObjectPrivate *, int *) + ?setDeleteWatch@QObjectPrivate@@SAPAHPAV1@PAH@Z @ 3298 NONAME ABSENT ; int * QObjectPrivate::setDeleteWatch(class QObjectPrivate *, int *) ?setDevice@QDataStream@@QAEXPAVQIODevice@@@Z @ 3299 NONAME ; void QDataStream::setDevice(class QIODevice *) ?setDevice@QTextStream@@QAEXPAVQIODevice@@@Z @ 3300 NONAME ; void QTextStream::setDevice(class QIODevice *) ?setDevice@QXmlStreamReader@@QAEXPAVQIODevice@@@Z @ 3301 NONAME ; void QXmlStreamReader::setDevice(class QIODevice *) @@ -4482,4 +4482,48 @@ EXPORTS ?textDirection@QLocale@@QBE?AW4LayoutDirection@Qt@@XZ @ 4481 NONAME ; enum Qt::LayoutDirection QLocale::textDirection(void) const ?msecsSinceReference@QElapsedTimer@@QBE_JXZ @ 4482 NONAME ; long long QElapsedTimer::msecsSinceReference(void) const ?selectThread@QEventDispatcherSymbian@@AAEAAVQSelectThread@@XZ @ 4483 NONAME ; class QSelectThread & QEventDispatcherSymbian::selectThread(void) + ??0QCoreApplication@@QAE@AAHPAPADH@Z @ 4484 NONAME ; QCoreApplication::QCoreApplication(int &, char * *, int) + ??0QCoreApplicationPrivate@@QAE@AAHPAPADI@Z @ 4485 NONAME ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *, unsigned int) + ?connect@QObject@@SA_NPBV1@ABVQMetaMethod@@01W4ConnectionType@Qt@@@Z @ 4486 NONAME ; bool QObject::connect(class QObject const *, class QMetaMethod const &, class QObject const *, class QMetaMethod const &, enum Qt::ConnectionType) + ?contains@QString@@QBE?AVQBool@@ABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4487 NONAME ; class QBool QString::contains(class QStringRef const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@ABV1@W4CaseSensitivity@Qt@@@Z @ 4488 NONAME ; class QBool QStringRef::contains(class QStringRef const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@ABVQString@@W4CaseSensitivity@Qt@@@Z @ 4489 NONAME ; class QBool QStringRef::contains(class QString const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@VQChar@@W4CaseSensitivity@Qt@@@Z @ 4490 NONAME ; class QBool QStringRef::contains(class QChar, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@VQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4491 NONAME ; class QBool QStringRef::contains(class QLatin1String, enum Qt::CaseSensitivity) const + ?count@QString@@QBEHABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4492 NONAME ; int QString::count(class QStringRef const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHABV1@W4CaseSensitivity@Qt@@@Z @ 4493 NONAME ; int QStringRef::count(class QStringRef const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHABVQString@@W4CaseSensitivity@Qt@@@Z @ 4494 NONAME ; int QStringRef::count(class QString const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHVQChar@@W4CaseSensitivity@Qt@@@Z @ 4495 NONAME ; int QStringRef::count(class QChar, enum Qt::CaseSensitivity) const + ?disconnect@QObject@@SA_NPBV1@ABVQMetaMethod@@01@Z @ 4496 NONAME ; bool QObject::disconnect(class QObject const *, class QMetaMethod const &, class QObject const *, class QMetaMethod const &) + ?endsWith@QString@@QBE_NABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4497 NONAME ; bool QString::endsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NABV1@W4CaseSensitivity@Qt@@@Z @ 4498 NONAME ; bool QStringRef::endsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NABVQString@@W4CaseSensitivity@Qt@@@Z @ 4499 NONAME ; bool QStringRef::endsWith(class QString const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NVQChar@@W4CaseSensitivity@Qt@@@Z @ 4500 NONAME ; bool QStringRef::endsWith(class QChar, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NVQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4501 NONAME ; bool QStringRef::endsWith(class QLatin1String, enum Qt::CaseSensitivity) const + ?indexOf@QString@@QBEHABVQStringRef@@HW4CaseSensitivity@Qt@@@Z @ 4502 NONAME ; int QString::indexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHABV1@HW4CaseSensitivity@Qt@@@Z @ 4503 NONAME ; int QStringRef::indexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHABVQString@@HW4CaseSensitivity@Qt@@@Z @ 4504 NONAME ; int QStringRef::indexOf(class QString const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHVQChar@@HW4CaseSensitivity@Qt@@@Z @ 4505 NONAME ; int QStringRef::indexOf(class QChar, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHVQLatin1String@@HW4CaseSensitivity@Qt@@@Z @ 4506 NONAME ; int QStringRef::indexOf(class QLatin1String, int, enum Qt::CaseSensitivity) const + ?isLocalFile@QUrl@@QBE_NXZ @ 4507 NONAME ; bool QUrl::isLocalFile(void) const + ?lastIndexOf@QString@@QBEHABVQStringRef@@HW4CaseSensitivity@Qt@@@Z @ 4508 NONAME ; int QString::lastIndexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHABV1@HW4CaseSensitivity@Qt@@@Z @ 4509 NONAME ; int QStringRef::lastIndexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHABVQString@@HW4CaseSensitivity@Qt@@@Z @ 4510 NONAME ; int QStringRef::lastIndexOf(class QString const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHVQChar@@HW4CaseSensitivity@Qt@@@Z @ 4511 NONAME ; int QStringRef::lastIndexOf(class QChar, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHVQLatin1String@@HW4CaseSensitivity@Qt@@@Z @ 4512 NONAME ; int QStringRef::lastIndexOf(class QLatin1String, int, enum Qt::CaseSensitivity) const + ?lockInline@QMutex@@QAEXXZ @ 4513 NONAME ; void QMutex::lockInline(void) + ?lockInternal@QMutex@@AAEXXZ @ 4514 NONAME ; void QMutex::lockInternal(void) + ?nativeKey@QSharedMemory@@QBE?AVQString@@XZ @ 4515 NONAME ; class QString QSharedMemory::nativeKey(void) const + ?senderSignalIndex@QObject@@IBEHXZ @ 4516 NONAME ; int QObject::senderSignalIndex(void) const + ?setNativeKey@QSharedMemory@@QAEXABVQString@@@Z @ 4517 NONAME ; void QSharedMemory::setNativeKey(class QString const &) + ?startsWith@QString@@QBE_NABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4518 NONAME ; bool QString::startsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NABV1@W4CaseSensitivity@Qt@@@Z @ 4519 NONAME ; bool QStringRef::startsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NABVQString@@W4CaseSensitivity@Qt@@@Z @ 4520 NONAME ; bool QStringRef::startsWith(class QString const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NVQChar@@W4CaseSensitivity@Qt@@@Z @ 4521 NONAME ; bool QStringRef::startsWith(class QChar, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NVQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4522 NONAME ; bool QStringRef::startsWith(class QLatin1String, enum Qt::CaseSensitivity) const + ?tryLockInline@QMutex@@QAE_NXZ @ 4523 NONAME ; bool QMutex::tryLockInline(void) + ?unlockInline@QMutex@@QAEXXZ @ 4524 NONAME ; void QMutex::unlockInline(void) + ?unlockInternal@QMutex@@AAEXXZ @ 4525 NONAME ; void QMutex::unlockInternal(void) + ?waitForDone@QThreadPool@@QAE_NH@Z @ 4526 NONAME ; bool QThreadPool::waitForDone(int) + ?app_compile_version@QCoreApplicationPrivate@@2HA @ 4527 NONAME ; int QCoreApplicationPrivate::app_compile_version diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 90c0878..b2ac45e 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -35,7 +35,7 @@ EXPORTS ??0QApplication@@QAE@AAHPAPADW4Type@0@H@Z @ 34 NONAME ; QApplication::QApplication(int &, char * *, enum QApplication::Type, int) ??0QApplication@@QAE@AAHPAPAD_NH@Z @ 35 NONAME ; QApplication::QApplication(int &, char * *, bool, int) ??0QApplication@@QAE@P6APAVCApaApplication@@XZAAHPAPADH@Z @ 36 NONAME ; QApplication::QApplication(class CApaApplication * (*)(void), int &, char * *, int) - ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@@Z @ 37 NONAME ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type) + ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@@Z @ 37 NONAME ABSENT ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type) ??0QBitmap@@QAE@ABVQPixmap@@@Z @ 38 NONAME ; QBitmap::QBitmap(class QPixmap const &) ??0QBitmap@@QAE@ABVQSize@@@Z @ 39 NONAME ; QBitmap::QBitmap(class QSize const &) ??0QBitmap@@QAE@ABVQString@@PBD@Z @ 40 NONAME ; QBitmap::QBitmap(class QString const &, char const *) @@ -4148,7 +4148,7 @@ EXPORTS ?ensureSceneTransformRecursive@QGraphicsItemPrivate@@QAEXPAPAVQGraphicsItem@@@Z @ 4147 NONAME ; void QGraphicsItemPrivate::ensureSceneTransformRecursive(class QGraphicsItem * *) ?ensureSequentialSiblingIndex@QGraphicsItemPrivate@@QAEXXZ @ 4148 NONAME ; void QGraphicsItemPrivate::ensureSequentialSiblingIndex(void) ?ensureSortedChildren@QGraphicsItemPrivate@@QAEXXZ @ 4149 NONAME ; void QGraphicsItemPrivate::ensureSortedChildren(void) - ?ensureSpace@QTextEngine@@QBEXH@Z @ 4150 NONAME ; void QTextEngine::ensureSpace(int) const + ?ensureSpace@QTextEngine@@QBEXH@Z @ 4150 NONAME ABSENT ; void QTextEngine::ensureSpace(int) const ?ensureVisible@QGraphicsItem@@QAEXABVQRectF@@HH@Z @ 4151 NONAME ; void QGraphicsItem::ensureVisible(class QRectF const &, int, int) ?ensureVisible@QGraphicsItem@@QAEXMMMMHH@Z @ 4152 NONAME ; void QGraphicsItem::ensureVisible(float, float, float, float, int, int) ?ensureVisible@QGraphicsView@@QAEXABVQRectF@@HH@Z @ 4153 NONAME ; void QGraphicsView::ensureVisible(class QRectF const &, int, int) @@ -12511,7 +12511,7 @@ EXPORTS ?staticMetaObject@QFileSystemModel@@2UQMetaObject@@B @ 12510 NONAME ; struct QMetaObject const QFileSystemModel::staticMetaObject ?staticMetaObject@QKeyEventTransition@@2UQMetaObject@@B @ 12511 NONAME ; struct QMetaObject const QKeyEventTransition::staticMetaObject ?staticMetaObject@QLayout@@2UQMetaObject@@B @ 12512 NONAME ; struct QMetaObject const QLayout::staticMetaObject - ?app_compile_version@QApplicationPrivate@@2HA @ 12513 NONAME ; int QApplicationPrivate::app_compile_version + ?app_compile_version@QApplicationPrivate@@2HA @ 12513 NONAME ABSENT ; int QApplicationPrivate::app_compile_version ?spacerItemFactoryMethod@QLayoutPrivate@@2P6APAVQSpacerItem@@PBVQLayout@@HHW4Policy@QSizePolicy@@1@ZA @ 12514 NONAME ; class QSpacerItem * (*QLayoutPrivate::spacerItemFactoryMethod)(class QLayout const *, int, int, enum QSizePolicy::Policy, enum QSizePolicy::Policy) ?allWidgets@QWidgetPrivate@@2PAV?$QSet@PAVQWidget@@@@A @ 12515 NONAME ; class QSet * QWidgetPrivate::allWidgets ?effectiveFocusWidget@QWidgetPrivate@@QAEPAVQWidget@@XZ @ 12516 NONAME ; class QWidget * QWidgetPrivate::effectiveFocusWidget(void) @@ -12522,7 +12522,7 @@ EXPORTS ?addCacheData@QVectorPath@@QBEPAUCacheEntry@1@PAVQPaintEngineEx@@PAXP6AX01@Z@Z @ 12521 NONAME ; struct QVectorPath::CacheEntry * QVectorPath::addCacheData(class QPaintEngineEx *, void *, void (*)(class QPaintEngineEx *, void *)) const ?discardUpdateRequest@QGraphicsItemPrivate@@QBE_N_N00@Z @ 12522 NONAME ; bool QGraphicsItemPrivate::discardUpdateRequest(bool, bool, bool) const ?makeCacheable@QVectorPath@@QBEXXZ @ 12523 NONAME ; void QVectorPath::makeCacheable(void) const - ??0Tab@QTextOption@@QAE@ABU01@@Z @ 12524 NONAME ; QTextOption::Tab::Tab(struct QTextOption::Tab const &) + ??0Tab@QTextOption@@QAE@ABU01@@Z @ 12524 NONAME ABSENT ; QTextOption::Tab::Tab(struct QTextOption::Tab const &) ?effectiveBoundingRect@QGraphicsItemPrivate@@QBE?AVQRectF@@ABV2@@Z @ 12525 NONAME ; class QRectF QGraphicsItemPrivate::effectiveBoundingRect(class QRectF const &) const ?glyphCache@QFontEngine@@QBEPAVQFontEngineGlyphCache@@PAXW4Type@2@ABVQTransform@@@Z @ 12526 NONAME ; class QFontEngineGlyphCache * QFontEngine::glyphCache(void *, enum QFontEngineGlyphCache::Type, class QTransform const &) const ?qt_blurImage@@YAXAAVQImage@@M_NH@Z @ 12527 NONAME ; void qt_blurImage(class QImage &, float, bool, int) @@ -12886,4 +12886,53 @@ EXPORTS ?zScaleChanged@QGraphicsScale@@IAEXXZ @ 12885 NONAME ; void QGraphicsScale::zScaleChanged(void) ?xScaleChanged@QGraphicsScale@@IAEXXZ @ 12886 NONAME ; void QGraphicsScale::xScaleChanged(void) ?yScaleChanged@QGraphicsScale@@IAEXXZ @ 12887 NONAME ; void QGraphicsScale::yScaleChanged(void) + ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@H@Z @ 12888 NONAME ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type, int) + ??0QGlyphs@@QAE@ABV0@@Z @ 12889 NONAME ; QGlyphs::QGlyphs(class QGlyphs const &) + ??0QGlyphs@@QAE@XZ @ 12890 NONAME ; QGlyphs::QGlyphs(void) + ??1QGlyphs@@QAE@XZ @ 12891 NONAME ; QGlyphs::~QGlyphs(void) + ??4QGlyphs@@QAEAAV0@ABV0@@Z @ 12892 NONAME ; class QGlyphs & QGlyphs::operator=(class QGlyphs const &) + ??8QGlyphs@@QBE_NABV0@@Z @ 12893 NONAME ; bool QGlyphs::operator==(class QGlyphs const &) const + ??9QGlyphs@@QBE_NABV0@@Z @ 12894 NONAME ; bool QGlyphs::operator!=(class QGlyphs const &) const + ??HQGlyphs@@ABE?AV0@ABV0@@Z @ 12895 NONAME ; class QGlyphs QGlyphs::operator+(class QGlyphs const &) const + ??MQItemSelectionRange@@QBE_NABV0@@Z @ 12896 NONAME ; bool QItemSelectionRange::operator<(class QItemSelectionRange const &) const + ??YQGlyphs@@AAEAAV0@ABV0@@Z @ 12897 NONAME ; class QGlyphs & QGlyphs::operator+=(class QGlyphs const &) + ?_q_aboutToQuit@QApplicationPrivate@@QAEXXZ @ 12898 NONAME ; void QApplicationPrivate::_q_aboutToQuit(void) + ?buddy@QAbstractProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 12899 NONAME ; class QModelIndex QAbstractProxyModel::buddy(class QModelIndex const &) const + ?canFetchMore@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 12900 NONAME ; bool QAbstractProxyModel::canFetchMore(class QModelIndex const &) const + ?clear@QGlyphs@@QAEXXZ @ 12901 NONAME ; void QGlyphs::clear(void) + ?clipBoundingRect@QPainter@@QBE?AVQRectF@@XZ @ 12902 NONAME ; class QRectF QPainter::clipBoundingRect(void) const + ?createExplicitFont@QFontEngine@@UBE?AVQFont@@XZ @ 12903 NONAME ; class QFont QFontEngine::createExplicitFont(void) const + ?createExplicitFontWithName@QFontEngine@@IBE?AVQFont@@ABVQString@@@Z @ 12904 NONAME ; class QFont QFontEngine::createExplicitFontWithName(class QString const &) const + ?detach@QGlyphs@@AAEXXZ @ 12905 NONAME ; void QGlyphs::detach(void) + ?drawGlyphs@QPainter@@QAEXABVQPointF@@ABVQGlyphs@@@Z @ 12906 NONAME ; void QPainter::drawGlyphs(class QPointF const &, class QGlyphs const &) + ?ensureSpace@QTextEngine@@QBE_NH@Z @ 12907 NONAME ; bool QTextEngine::ensureSpace(int) const + ?fetchMore@QAbstractProxyModel@@UAEXABVQModelIndex@@@Z @ 12908 NONAME ; void QAbstractProxyModel::fetchMore(class QModelIndex const &) + ?fill@QImage@@QAEXABVQColor@@@Z @ 12909 NONAME ; void QImage::fill(class QColor const &) + ?fill@QImage@@QAEXW4GlobalColor@Qt@@@Z @ 12910 NONAME ; void QImage::fill(enum Qt::GlobalColor) + ?fillInPendingGlyphs@QTextureGlyphCache@@QAEXXZ @ 12911 NONAME ; void QTextureGlyphCache::fillInPendingGlyphs(void) + ?font@QGlyphs@@QBE?AVQFont@@XZ @ 12912 NONAME ; class QFont QGlyphs::font(void) const + ?get@QFontPrivate@@SAPAV1@ABVQFont@@@Z @ 12913 NONAME ; class QFontPrivate * QFontPrivate::get(class QFont const &) + ?glyphIndexes@QGlyphs@@QBE?AV?$QVector@I@@XZ @ 12914 NONAME ; class QVector QGlyphs::glyphIndexes(void) const + ?glyphs@QTextFragment@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 12915 NONAME ; class QList QTextFragment::glyphs(void) const + ?glyphs@QTextLayout@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 12916 NONAME ; class QList QTextLayout::glyphs(void) const + ?glyphs@QTextLine@@ABE?AV?$QList@VQGlyphs@@@@HH@Z @ 12917 NONAME ; class QList QTextLine::glyphs(int, int) const + ?hasChildren@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 12918 NONAME ; bool QAbstractProxyModel::hasChildren(class QModelIndex const &) const + ?hasHeightForWidth@QWidgetPrivate@@UBE_NXZ @ 12919 NONAME ; bool QWidgetPrivate::hasHeightForWidth(void) const + ?heightForWidth@QTabWidget@@UBEHH@Z @ 12920 NONAME ; int QTabWidget::heightForWidth(int) const + ?inFontUcs4@QFontMetrics@@QBE_NI@Z @ 12921 NONAME ; bool QFontMetrics::inFontUcs4(unsigned int) const + ?inFontUcs4@QFontMetricsF@@QBE_NI@Z @ 12922 NONAME ; bool QFontMetricsF::inFontUcs4(unsigned int) const + ?mimeData@QAbstractProxyModel@@UBEPAVQMimeData@@ABV?$QList@VQModelIndex@@@@@Z @ 12923 NONAME ; class QMimeData * QAbstractProxyModel::mimeData(class QList const &) const + ?mimeTypes@QAbstractProxyModel@@UBE?AVQStringList@@XZ @ 12924 NONAME ; class QStringList QAbstractProxyModel::mimeTypes(void) const + ?minimumSizeHint@QCheckBox@@UBE?AVQSize@@XZ @ 12925 NONAME ; class QSize QCheckBox::minimumSizeHint(void) const + ?minimumSizeHint@QRadioButton@@UBE?AVQSize@@XZ @ 12926 NONAME ; class QSize QRadioButton::minimumSizeHint(void) const + ?positions@QGlyphs@@QBE?AV?$QVector@VQPointF@@@@XZ @ 12927 NONAME ; class QVector QGlyphs::positions(void) const + ?removeItem@QGraphicsGridLayout@@QAEXPAVQGraphicsLayoutItem@@@Z @ 12928 NONAME ; void QGraphicsGridLayout::removeItem(class QGraphicsLayoutItem *) + ?resizeCache@QTextureGlyphCache@@QAEXHH@Z @ 12929 NONAME ; void QTextureGlyphCache::resizeCache(int, int) + ?setFont@QGlyphs@@QAEXABVQFont@@@Z @ 12930 NONAME ; void QGlyphs::setFont(class QFont const &) + ?setGlyphIndexes@QGlyphs@@QAEXABV?$QVector@I@@@Z @ 12931 NONAME ; void QGlyphs::setGlyphIndexes(class QVector const &) + ?setItemData@QAbstractProxyModel@@UAE_NABVQModelIndex@@ABV?$QMap@HVQVariant@@@@@Z @ 12932 NONAME ; bool QAbstractProxyModel::setItemData(class QModelIndex const &, class QMap const &) + ?setPositions@QGlyphs@@QAEXABV?$QVector@VQPointF@@@@@Z @ 12933 NONAME ; void QGlyphs::setPositions(class QVector const &) + ?sort@QAbstractProxyModel@@UAEXHW4SortOrder@Qt@@@Z @ 12934 NONAME ; void QAbstractProxyModel::sort(int, enum Qt::SortOrder) + ?span@QAbstractProxyModel@@UBE?AVQSize@@ABVQModelIndex@@@Z @ 12935 NONAME ; class QSize QAbstractProxyModel::span(class QModelIndex const &) const + ?supportedDropActions@QAbstractProxyModel@@UBE?AV?$QFlags@W4DropAction@Qt@@@@XZ @ 12936 NONAME ; class QFlags QAbstractProxyModel::supportedDropActions(void) const diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 46c4885..b1b3b65 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -620,8 +620,8 @@ EXPORTS _ZN14QObjectPrivate11clearGuardsEP7QObject @ 619 NONAME _ZN14QObjectPrivate13addConnectionEiPNS_10ConnectionE @ 620 NONAME _ZN14QObjectPrivate14deleteChildrenEv @ 621 NONAME - _ZN14QObjectPrivate14setDeleteWatchEPS_Pi @ 622 NONAME - _ZN14QObjectPrivate16resetDeleteWatchEPS_Pii @ 623 NONAME + _ZN14QObjectPrivate14setDeleteWatchEPS_Pi @ 622 NONAME ABSENT + _ZN14QObjectPrivate16resetDeleteWatchEPS_Pii @ 623 NONAME ABSENT _ZN14QObjectPrivate16setCurrentSenderEP7QObjectPNS_6SenderE @ 624 NONAME ABSENT _ZN14QObjectPrivate16setParent_helperEP7QObject @ 625 NONAME _ZN14QObjectPrivate18resetCurrentSenderEP7QObjectPNS_6SenderES3_ @ 626 NONAME ABSENT @@ -1274,8 +1274,8 @@ EXPORTS _ZN23QCoreApplicationPrivate34sendThroughApplicationEventFiltersEP7QObjectP6QEvent @ 1273 NONAME _ZN23QCoreApplicationPrivate35appendApplicationPathToLibraryPathsEv @ 1274 NONAME _ZN23QCoreApplicationPrivate7attribsE @ 1275 NONAME DATA 4 - _ZN23QCoreApplicationPrivateC1ERiPPc @ 1276 NONAME - _ZN23QCoreApplicationPrivateC2ERiPPc @ 1277 NONAME + _ZN23QCoreApplicationPrivateC1ERiPPc @ 1276 NONAME ABSENT + _ZN23QCoreApplicationPrivateC2ERiPPc @ 1277 NONAME ABSENT _ZN23QCoreApplicationPrivateD0Ev @ 1278 NONAME _ZN23QCoreApplicationPrivateD1Ev @ 1279 NONAME _ZN23QCoreApplicationPrivateD2Ev @ 1280 NONAME @@ -3711,4 +3711,42 @@ EXPORTS _ZN16QIODevicePrivate4peekEx @ 3710 NONAME _ZN8QProcess18setNativeArgumentsERK7QString @ 3711 NONAME _ZNK8QProcess15nativeArgumentsEv @ 3712 NONAME + _ZN11QThreadPool11waitForDoneEi @ 3713 NONAME + _ZN13QSharedMemory12setNativeKeyERK7QString @ 3714 NONAME + _ZN16QCoreApplicationC1ERiPPci @ 3715 NONAME + _ZN16QCoreApplicationC2ERiPPci @ 3716 NONAME + _ZN23QCoreApplicationPrivate19app_compile_versionE @ 3717 NONAME DATA 4 + _ZN23QCoreApplicationPrivateC1ERiPPcj @ 3718 NONAME + _ZN23QCoreApplicationPrivateC2ERiPPcj @ 3719 NONAME + _ZN6QMutex12lockInternalEv @ 3720 NONAME + _ZN6QMutex14unlockInternalEv @ 3721 NONAME + _ZN7QObject10disconnectEPKS_RK11QMetaMethodS1_S4_ @ 3722 NONAME + _ZN7QObject7connectEPKS_RK11QMetaMethodS1_S4_N2Qt14ConnectionTypeE @ 3723 NONAME + _ZNK10QStringRef10startsWithE13QLatin1StringN2Qt15CaseSensitivityE @ 3724 NONAME + _ZNK10QStringRef10startsWithE5QCharN2Qt15CaseSensitivityE @ 3725 NONAME + _ZNK10QStringRef10startsWithERK7QStringN2Qt15CaseSensitivityE @ 3726 NONAME + _ZNK10QStringRef10startsWithERKS_N2Qt15CaseSensitivityE @ 3727 NONAME + _ZNK10QStringRef11lastIndexOfE13QLatin1StringiN2Qt15CaseSensitivityE @ 3728 NONAME + _ZNK10QStringRef11lastIndexOfE5QChariN2Qt15CaseSensitivityE @ 3729 NONAME + _ZNK10QStringRef11lastIndexOfERK7QStringiN2Qt15CaseSensitivityE @ 3730 NONAME + _ZNK10QStringRef11lastIndexOfERKS_iN2Qt15CaseSensitivityE @ 3731 NONAME + _ZNK10QStringRef5countE5QCharN2Qt15CaseSensitivityE @ 3732 NONAME + _ZNK10QStringRef5countERK7QStringN2Qt15CaseSensitivityE @ 3733 NONAME + _ZNK10QStringRef5countERKS_N2Qt15CaseSensitivityE @ 3734 NONAME + _ZNK10QStringRef7indexOfE13QLatin1StringiN2Qt15CaseSensitivityE @ 3735 NONAME + _ZNK10QStringRef7indexOfE5QChariN2Qt15CaseSensitivityE @ 3736 NONAME + _ZNK10QStringRef7indexOfERK7QStringiN2Qt15CaseSensitivityE @ 3737 NONAME + _ZNK10QStringRef7indexOfERKS_iN2Qt15CaseSensitivityE @ 3738 NONAME + _ZNK10QStringRef8endsWithE13QLatin1StringN2Qt15CaseSensitivityE @ 3739 NONAME + _ZNK10QStringRef8endsWithE5QCharN2Qt15CaseSensitivityE @ 3740 NONAME + _ZNK10QStringRef8endsWithERK7QStringN2Qt15CaseSensitivityE @ 3741 NONAME + _ZNK10QStringRef8endsWithERKS_N2Qt15CaseSensitivityE @ 3742 NONAME + _ZNK13QSharedMemory9nativeKeyEv @ 3743 NONAME + _ZNK4QUrl11isLocalFileEv @ 3744 NONAME + _ZNK7QObject17senderSignalIndexEv @ 3745 NONAME + _ZNK7QString10startsWithERK10QStringRefN2Qt15CaseSensitivityE @ 3746 NONAME + _ZNK7QString11lastIndexOfERK10QStringRefiN2Qt15CaseSensitivityE @ 3747 NONAME + _ZNK7QString5countERK10QStringRefN2Qt15CaseSensitivityE @ 3748 NONAME + _ZNK7QString7indexOfERK10QStringRefiN2Qt15CaseSensitivityE @ 3749 NONAME + _ZNK7QString8endsWithERK10QStringRefN2Qt15CaseSensitivityE @ 3750 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index d8e86bf..6f26918 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -4324,7 +4324,7 @@ EXPORTS _ZN19QApplicationPrivate18dispatchEnterLeaveEP7QWidgetS1_ @ 4323 NONAME _ZN19QApplicationPrivate18resolveS60ScanCodeEij @ 4324 NONAME _ZN19QApplicationPrivate18wheel_scroll_linesE @ 4325 NONAME DATA 4 - _ZN19QApplicationPrivate19app_compile_versionE @ 4326 NONAME DATA 4 + _ZN19QApplicationPrivate19app_compile_versionE @ 4326 NONAME DATA 4 ABSENT _ZN19QApplicationPrivate19hidden_focus_widgetE @ 4327 NONAME DATA 4 _ZN19QApplicationPrivate19keyboard_input_timeE @ 4328 NONAME DATA 4 _ZN19QApplicationPrivate20emitLastWindowClosedEv @ 4329 NONAME @@ -4356,8 +4356,8 @@ EXPORTS _ZN19QApplicationPrivate9constructEv @ 4355 NONAME _ZN19QApplicationPrivate9fade_menuE @ 4356 NONAME DATA 1 _ZN19QApplicationPrivate9openPopupEP7QWidget @ 4357 NONAME - _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeE @ 4358 NONAME - _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeE @ 4359 NONAME + _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeE @ 4358 NONAME ABSENT + _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeE @ 4359 NONAME ABSENT _ZN19QApplicationPrivateD0Ev @ 4360 NONAME _ZN19QApplicationPrivateD1Ev @ 4361 NONAME _ZN19QApplicationPrivateD2Ev @ 4362 NONAME @@ -12091,4 +12091,54 @@ EXPORTS _ZN14QGraphicsScale13xScaleChangedEv @ 12090 NONAME _ZN14QGraphicsScale13yScaleChangedEv @ 12091 NONAME _ZN14QGraphicsScale13zScaleChangedEv @ 12092 NONAME + _ZN18QTextureGlyphCache19fillInPendingGlyphsEv @ 12093 NONAME + _ZN19QAbstractProxyModel11setItemDataERK11QModelIndexRK4QMapIi8QVariantE @ 12094 NONAME + _ZN19QAbstractProxyModel4sortEiN2Qt9SortOrderE @ 12095 NONAME + _ZN19QAbstractProxyModel9fetchMoreERK11QModelIndex @ 12096 NONAME + _ZN19QApplicationPrivate14_q_aboutToQuitEv @ 12097 NONAME + _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeEi @ 12098 NONAME + _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeEi @ 12099 NONAME + _ZN19QGraphicsGridLayout10removeItemEP19QGraphicsLayoutItem @ 12100 NONAME + _ZN6QImage4fillEN2Qt11GlobalColorE @ 12101 NONAME + _ZN6QImage4fillERK6QColor @ 12102 NONAME + _ZN7QGlyphs12setPositionsERK7QVectorI7QPointFE @ 12103 NONAME + _ZN7QGlyphs15setGlyphIndexesERK7QVectorIjE @ 12104 NONAME + _ZN7QGlyphs5clearEv @ 12105 NONAME + _ZN7QGlyphs6detachEv @ 12106 NONAME + _ZN7QGlyphs7setFontERK5QFont @ 12107 NONAME + _ZN7QGlyphsC1ERKS_ @ 12108 NONAME + _ZN7QGlyphsC1Ev @ 12109 NONAME + _ZN7QGlyphsC2ERKS_ @ 12110 NONAME + _ZN7QGlyphsC2Ev @ 12111 NONAME + _ZN7QGlyphsD1Ev @ 12112 NONAME + _ZN7QGlyphsD2Ev @ 12113 NONAME + _ZN7QGlyphsaSERKS_ @ 12114 NONAME + _ZN7QGlyphspLERKS_ @ 12115 NONAME + _ZN8QPainter10drawGlyphsERK7QPointFRK7QGlyphs @ 12116 NONAME + _ZNK10QTabWidget14heightForWidthEi @ 12117 NONAME + _ZNK11QFontEngine18createExplicitFontEv @ 12118 NONAME + _ZNK11QFontEngine26createExplicitFontWithNameERK7QString @ 12119 NONAME + _ZNK11QTextLayout6glyphsEv @ 12120 NONAME + _ZNK12QFontMetrics10inFontUcs4Ej @ 12121 NONAME + _ZNK12QRadioButton15minimumSizeHintEv @ 12122 NONAME + _ZNK13QFontMetricsF10inFontUcs4Ej @ 12123 NONAME + _ZNK13QTextFragment6glyphsEv @ 12124 NONAME + _ZNK14QWidgetPrivate17hasHeightForWidthEv @ 12125 NONAME + _ZNK16QFileSystemModel5rmdirERK11QModelIndex @ 12126 NONAME + _ZNK19QAbstractProxyModel11hasChildrenERK11QModelIndex @ 12127 NONAME + _ZNK19QAbstractProxyModel12canFetchMoreERK11QModelIndex @ 12128 NONAME + _ZNK19QAbstractProxyModel20supportedDropActionsEv @ 12129 NONAME + _ZNK19QAbstractProxyModel4spanERK11QModelIndex @ 12130 NONAME + _ZNK19QAbstractProxyModel5buddyERK11QModelIndex @ 12131 NONAME + _ZNK19QAbstractProxyModel8mimeDataERK5QListI11QModelIndexE @ 12132 NONAME + _ZNK19QAbstractProxyModel9mimeTypesEv @ 12133 NONAME + _ZNK7QGlyphs12glyphIndexesEv @ 12134 NONAME + _ZNK7QGlyphs4fontEv @ 12135 NONAME + _ZNK7QGlyphs9positionsEv @ 12136 NONAME + _ZNK7QGlyphseqERKS_ @ 12137 NONAME + _ZNK7QGlyphsneERKS_ @ 12138 NONAME + _ZNK7QGlyphsplERKS_ @ 12139 NONAME + _ZNK8QPainter16clipBoundingRectEv @ 12140 NONAME + _ZNK9QCheckBox15minimumSizeHintEv @ 12141 NONAME + _ZNK9QTextLine6glyphsEii @ 12142 NONAME -- cgit v0.12 From 050fa9f6cc1145f5a835420b9974a6b0e261b062 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 7 Sep 2010 16:51:55 +0200 Subject: Add baseName and completeBaseName getters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the definition of the concepts from QFileInfo, allow us to use the already calculated indexes to fetch the baseName and the completeBaseName on a QFileSystemEntry. Reviewed-by: João Abecasis --- src/corelib/io/qfilesystementry.cpp | 26 +++++++++++--- src/corelib/io/qfilesystementry_p.h | 2 ++ .../auto/qfilesystementry/tst_qfilesystementry.cpp | 40 +++++++++++++++------- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index f5009b4..6f04c21 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -149,10 +149,8 @@ QString QFileSystemEntry::fileName() const { findLastSeparator(); #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - if (m_lastSeparator == -1) { - if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) - return m_filePath.mid(2); - } + if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + return m_filePath.mid(2); #endif return m_filePath.mid(m_lastSeparator + 1); } @@ -176,6 +174,26 @@ QString QFileSystemEntry::path() const return m_filePath.left(m_lastSeparator); } +QString QFileSystemEntry::baseName() const +{ + findFileNameSeparators(); +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + return m_filePath.mid(2); +#endif + return m_filePath.mid(m_lastSeparator + 1, m_firstDotInFileName == -1 ?-1 : m_firstDotInFileName - 1); +} + +QString QFileSystemEntry::completeBaseName() const +{ + findFileNameSeparators(); +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) + return m_filePath.mid(2); +#endif + return m_filePath.mid(m_lastSeparator + 1, m_firstDotInFileName == -1 ?-1 : m_firstDotInFileName + m_lastDotInFileName - 1); +} + QString QFileSystemEntry::suffix() const { findFileNameSeparators(); diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 6b2cedd..5a41782 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -83,6 +83,8 @@ public: QString fileName() const; QString path() const; NativePath nativeFilePath() const; + QString baseName() const; + QString completeBaseName() const; QString suffix() const; QString completeSuffix() const; bool isAbsolute() const; diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 5194c02..0fa63b5 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -65,6 +65,8 @@ void tst_QFileSystemEntry::getSetCheck_data() QTest::addColumn("internalnativeFilePath"); QTest::addColumn("filepath"); QTest::addColumn("filename"); + QTest::addColumn("baseName"); + QTest::addColumn("completeBasename"); QTest::addColumn("suffix"); QTest::addColumn("completeSuffix"); QTest::addColumn("absolute"); @@ -78,33 +80,33 @@ void tst_QFileSystemEntry::getSetCheck_data() << QString("A:\\home\\qt\\in\\a\\dir.tar.gz") << absPrefix + QString("A:\\home\\qt\\in\\a\\dir.tar.gz") << "A:/home/qt/in/a/dir.tar.gz" - << "dir.tar.gz" << "gz" << "tar.gz" << true; + << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << true; QTest::newRow("relative") << QString("in\\a\\dir.tar.gz") << relPrefix + QString("in\\a\\dir.tar.gz") << "in/a/dir.tar.gz" - << "dir.tar.gz" << "gz" << "tar.gz" << false; + << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << false; QTest::newRow("noSuffix") << QString("myDir\\myfile") << relPrefix + QString("myDir\\myfile") - << "myDir/myfile" << "myfile" << "" << "" << false; + << "myDir/myfile" << "myfile" << "myfile" << "myfile" << "" << "" << false; QTest::newRow("noLongSuffix") << QString("myDir\\myfile.txt") << relPrefix + QString("myDir\\myfile.txt") - << "myDir/myfile.txt" << "myfile.txt" << "txt" << "txt" << false; + << "myDir/myfile.txt" << "myfile.txt" << "myfile" << "myfile" << "txt" << "txt" << false; QTest::newRow("endingSlash") << QString("myDir\\myfile.bla\\") << relPrefix + QString("myDir\\myfile.bla\\") - << "myDir/myfile.bla/" << "" << "" << "" << false; + << "myDir/myfile.bla/" << "" << "" << "" << "" << "" << false; QTest::newRow("absolutePath") << QString("A:dir\\without\\leading\\backslash.bat") << absPrefix + QString("A:\\dir\\without\\leading\\backslash.bat") - << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << true; + << "A:dir/without/leading/backslash.bat" << "backslash.bat" << << "backslash" << "backslash" << "bat" << "bat" << true; } void tst_QFileSystemEntry::getSetCheck() @@ -113,6 +115,8 @@ void tst_QFileSystemEntry::getSetCheck() QFETCH(QString, internalnativeFilePath); QFETCH(QString, filepath); QFETCH(QString, filename); + QFETCH(QString, basename); + QFETCH(QString, completeBasename); QFETCH(QString, suffix); QFETCH(QString, completeSuffix); QFETCH(bool, absolute); @@ -125,6 +129,8 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry1.completeSuffix(), completeSuffix); QCOMPARE(entry1.isAbsolute(), absolute); QCOMPARE(entry1.isRelative(), !absolute); + QCOMPARE(entry1.baseName(), basename); + QCOMPARE(entry1.completeBaseName(), completeBasename); QFileSystemEntry entry2(nativeFilePath, QFileSystemEntry::FromNativePath()); QCOMPARE(entry2.suffix(), suffix); @@ -136,6 +142,8 @@ void tst_QFileSystemEntry::getSetCheck() // the object shouldnot change nativeFilePath. QCOMPARE(entry2.nativeFilePath(), nativeFilePath); QCOMPARE(entry2.fileName(), filename); + QCOMPARE(entry2.baseName(), basename); + QCOMPARE(entry2.completeBaseName(), completeBasename); } #else @@ -145,6 +153,8 @@ void tst_QFileSystemEntry::getSetCheck_data() QTest::addColumn("nativeFilePath"); QTest::addColumn("filepath"); QTest::addColumn("filename"); + QTest::addColumn("basename"); + QTest::addColumn("completeBasename"); QTest::addColumn("suffix"); QTest::addColumn("completeSuffix"); QTest::addColumn("absolute"); @@ -152,27 +162,27 @@ void tst_QFileSystemEntry::getSetCheck_data() QTest::newRow("simple") << QByteArray("/home/qt/in/a/dir.tar.gz") << "/home/qt/in/a/dir.tar.gz" - << "dir.tar.gz" << "gz" << "tar.gz" << true; + << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << true; QTest::newRow("relative") << QByteArray("in/a/dir.tar.gz") << "in/a/dir.tar.gz" - << "dir.tar.gz" << "gz" << "tar.gz" << false; + << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << false; QTest::newRow("noSuffix") << QByteArray("myDir/myfile") - << "myDir/myfile" << "myfile" << "" << "" << false; + << "myDir/myfile" << "myfile" << "myfile" << "myfile" << "" << "" << false; QTest::newRow("noLongSuffix") << QByteArray("myDir/myfile.txt") - << "myDir/myfile.txt" << "myfile.txt" << "txt" << "txt" << false; + << "myDir/myfile.txt" << "myfile.txt" << "myfile" << "myfile" << "txt" << "txt" << false; QTest::newRow("endingSlash") << QByteArray("myDir/myfile.bla/") - << "myDir/myfile.bla/" << "" << "" << "" << false; + << "myDir/myfile.bla/" << "" << "" << "" << "" << "" << false; QTest::newRow("relativePath") << QByteArray("A:dir/without/leading/backslash.bat") - << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "bat" << "bat" << false; + << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "backslash" << "backslash" << "bat" << "bat" << false; } void tst_QFileSystemEntry::getSetCheck() @@ -180,6 +190,8 @@ void tst_QFileSystemEntry::getSetCheck() QFETCH(QByteArray, nativeFilePath); QFETCH(QString, filepath); QFETCH(QString, filename); + QFETCH(QString, basename); + QFETCH(QString, completeBasename); QFETCH(QString, suffix); QFETCH(QString, completeSuffix); QFETCH(bool, absolute); @@ -192,6 +204,8 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry1.completeSuffix(), completeSuffix); QCOMPARE(entry1.isAbsolute(), absolute); QCOMPARE(entry1.isRelative(), !absolute); + QCOMPARE(entry1.baseName(), basename); + QCOMPARE(entry1.completeBaseName(), completeBasename); QFileSystemEntry entry2(nativeFilePath, QFileSystemEntry::FromNativePath()); QCOMPARE(entry2.suffix(), suffix); @@ -201,6 +215,8 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry2.filePath(), filepath); QCOMPARE(entry2.nativeFilePath(), nativeFilePath); QCOMPARE(entry2.fileName(), filename); + QCOMPARE(entry2.baseName(), basename); + QCOMPARE(entry2.completeBaseName(), completeBasename); } #endif -- cgit v0.12 From e34c6ac1146d7bb97da88805764d9fa90763b6b5 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 7 Sep 2010 17:36:04 +0200 Subject: Various fixes in suffix and other entry methods. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added lots of unit tests (inspired from qfileinfo) and found plenty of bugs that I fixed. Reviewed-by: João Abecasis --- src/corelib/io/qfilesystementry.cpp | 25 ++-- .../auto/qfilesystementry/tst_qfilesystementry.cpp | 132 +++++++++++++++++++++ 2 files changed, 150 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 6f04c21..733a226 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -181,7 +181,13 @@ QString QFileSystemEntry::baseName() const if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) return m_filePath.mid(2); #endif - return m_filePath.mid(m_lastSeparator + 1, m_firstDotInFileName == -1 ?-1 : m_firstDotInFileName - 1); + int length = -1; + if (m_firstDotInFileName >= 0) { + length = m_firstDotInFileName; + if (m_lastSeparator != -1) // avoid off by one + length--; + } + return m_filePath.mid(m_lastSeparator + 1, length); } QString QFileSystemEntry::completeBaseName() const @@ -191,7 +197,13 @@ QString QFileSystemEntry::completeBaseName() const if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':')) return m_filePath.mid(2); #endif - return m_filePath.mid(m_lastSeparator + 1, m_firstDotInFileName == -1 ?-1 : m_firstDotInFileName + m_lastDotInFileName - 1); + int length = -1; + if (m_firstDotInFileName >= 0) { + length = m_firstDotInFileName + m_lastDotInFileName; + if (m_lastSeparator != -1) // avoid off by one + length--; + } + return m_filePath.mid(m_lastSeparator + 1, length); } QString QFileSystemEntry::suffix() const @@ -201,7 +213,7 @@ QString QFileSystemEntry::suffix() const if (m_lastDotInFileName == -1) return QString(); - return m_filePath.mid(m_lastSeparator + m_firstDotInFileName + m_lastDotInFileName + 1); + return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + m_lastDotInFileName + 1); } QString QFileSystemEntry::completeSuffix() const @@ -210,7 +222,7 @@ QString QFileSystemEntry::completeSuffix() const if (m_firstDotInFileName == -1) return QString(); - return m_filePath.mid(m_lastSeparator + m_firstDotInFileName + 1); + return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + 1); } bool QFileSystemEntry::isAbsolute() const @@ -310,15 +322,14 @@ void QFileSystemEntry::findFileNameSeparators() const } } } - m_lastSeparator = lastSeparator; - m_firstDotInFileName = firstDotInFileName == -1 ? -1 : firstDotInFileName - lastSeparator; + m_firstDotInFileName = firstDotInFileName == -1 ? -1 : firstDotInFileName - qMax(0, lastSeparator); if (lastDotInFileName == -1) m_lastDotInFileName = -1; else if (firstDotInFileName == lastDotInFileName) m_lastDotInFileName = 0; else - m_lastDotInFileName = firstDotInFileName - lastSeparator; + m_lastDotInFileName = lastDotInFileName - firstDotInFileName; } } diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 0fa63b5..267fa8c 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -56,6 +56,14 @@ class tst_QFileSystemEntry : public QObject private slots: void getSetCheck_data(); void getSetCheck(); + void suffix_data(); + void suffix(); + void completeSuffix_data(); + void completeSuffix(); + void baseName_data(); + void baseName(); + void completeBaseName_data(); + void completeBaseName(); }; #if defined(WIN_STUFF) @@ -220,5 +228,129 @@ void tst_QFileSystemEntry::getSetCheck() } #endif +void tst_QFileSystemEntry::suffix_data() +{ + QTest::addColumn("file"); + QTest::addColumn("expected"); + + QTest::newRow("noextension0") << "file" << ""; + QTest::newRow("noextension1") << "/path/to/file" << ""; + QTest::newRow("data0") << "file.tar" << "tar"; + QTest::newRow("data1") << "file.tar.gz" << "gz"; + QTest::newRow("data2") << "/path/file/file.tar.gz" << "gz"; + QTest::newRow("data3") << "/path/file.tar" << "tar"; + QTest::newRow("hidden1") << ".ext1" << "ext1"; + QTest::newRow("hidden1") << ".ext" << "ext"; + QTest::newRow("hidden1") << ".ex" << "ex"; + QTest::newRow("hidden1") << ".e" << "e"; + QTest::newRow("hidden2") << ".ext1.ext2" << "ext2"; + QTest::newRow("hidden2") << ".ext.ext2" << "ext2"; + QTest::newRow("hidden2") << ".ex.ext2" << "ext2"; + QTest::newRow("hidden2") << ".e.ext2" << "ext2"; + QTest::newRow("hidden2") << "..ext2" << "ext2"; + QTest::newRow("dots") << "/path/file.with.dots/file..ext2" << "ext2"; + QTest::newRow("dots2") << "/path/file.with.dots/.file..ext2" << "ext2"; +} + +void tst_QFileSystemEntry::suffix() +{ + QFETCH(QString, file); + QFETCH(QString, expected); + + QFileSystemEntry fe(file); + QCOMPARE(fe.suffix(), expected); + + QFileSystemEntry fi2(file); + // first resolve the last slash + (void) fi2.path(); + QCOMPARE(fi2.suffix(), expected); +} + +void tst_QFileSystemEntry::completeSuffix_data() +{ + QTest::addColumn("file"); + QTest::addColumn("expected"); + + QTest::newRow("noextension0") << "file" << ""; + QTest::newRow("noextension1") << "/path/to/file" << ""; + QTest::newRow("data0") << "file.tar" << "tar"; + QTest::newRow("data1") << "file.tar.gz" << "tar.gz"; + QTest::newRow("data2") << "/path/file/file.tar.gz" << "tar.gz"; + QTest::newRow("data3") << "/path/file.tar" << "tar"; + QTest::newRow("dots") << "/path/file.with.dots/file..ext2" << ".ext2"; + QTest::newRow("dots2") << "/path/file.with.dots/.file..ext2" << "file..ext2"; +} + +void tst_QFileSystemEntry::completeSuffix() +{ + QFETCH(QString, file); + QFETCH(QString, expected); + + QFileSystemEntry fi(file); + QCOMPARE(fi.completeSuffix(), expected); + + QFileSystemEntry fi2(file); + // first resolve the last slash + (void) fi2.path(); + QCOMPARE(fi2.completeSuffix(), expected); +} + +void tst_QFileSystemEntry::baseName_data() +{ + QTest::addColumn("file"); + QTest::addColumn("expected"); + + QTest::newRow("data0") << "file.tar" << "file"; + QTest::newRow("data1") << "file.tar.gz" << "file"; + QTest::newRow("data2") << "/path/file/file.tar.gz" << "file"; + QTest::newRow("data3") << "/path/file.tar" << "file"; + QTest::newRow("data4") << "/path/file" << "file"; + QTest::newRow("dots") << "/path/file.with.dots/file..ext2" << "file"; + QTest::newRow("dots2") << "/path/file.with.dots/.file..ext2" << ""; +} + +void tst_QFileSystemEntry::baseName() +{ + QFETCH(QString, file); + QFETCH(QString, expected); + + QFileSystemEntry fi(file); + QCOMPARE(fi.baseName(), expected); + + QFileSystemEntry fi2(file); + // first resolve the last slash + (void) fi2.path(); + QCOMPARE(fi2.baseName(), expected); +} + +void tst_QFileSystemEntry::completeBaseName_data() +{ + QTest::addColumn("file"); + QTest::addColumn("expected"); + + QTest::newRow("data0") << "file.tar" << "file"; + QTest::newRow("data1") << "file.tar.gz" << "file.tar"; + QTest::newRow("data2") << "/path/file/file.tar.gz" << "file.tar"; + QTest::newRow("data3") << "/path/file.tar" << "file"; + QTest::newRow("data4") << "/path/file" << "file"; + QTest::newRow("dots") << "/path/file.with.dots/file..ext2" << "file."; + QTest::newRow("dots2") << "/path/file.with.dots/.file..ext2" << ".file."; +} + +void tst_QFileSystemEntry::completeBaseName() +{ + QFETCH(QString, file); + QFETCH(QString, expected); + + QFileSystemEntry fi(file); + QCOMPARE(fi.completeBaseName(), expected); + + QFileSystemEntry fi2(file); + // first resolve the last slash + (void) fi2.path(); + QCOMPARE(fi2.completeBaseName(), expected); +} + + QTEST_MAIN(tst_QFileSystemEntry) #include -- cgit v0.12 From 881b7547c2be0dc2b7e223175b8c43e4bda78991 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 8 Sep 2010 14:38:06 +0200 Subject: Make QFileInfo use the new filesystemengine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The creation of a QAbstractFileEngine derived class will now be avoided if the file we are watching is on the native file system and from then on all access will be through the direct API Notice that for QFileInfo::path, isRelative, filePath, fileName, baseName, completeBaseName, completeSuffix and suffix we now use the QFileSystemEntry instead of asking the engine. This means that some buggy or just weird user provided engines no longer get used and as such we might not be bug compatible. Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 213 ++++++++++++++++++++++++++------- src/corelib/io/qfileinfo_p.h | 19 ++- src/corelib/io/qfilesystemmetadata_p.h | 6 + tests/auto/qfileinfo/tst_qfileinfo.cpp | 7 +- 4 files changed, 195 insertions(+), 50 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 7eca212..232a32e 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -51,7 +51,47 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const { if (cache_enabled && !fileNames[(int)name].isNull()) return fileNames[(int)name]; - QString ret = fileEngine->fileName(name); + + QString ret; + if (fileEngine == 0) { // local file; use the QFileSystemEngine directly + switch (name) { + case QAbstractFileEngine::CanonicalName: + case QAbstractFileEngine::CanonicalPathName: { + QFileSystemEntry entry = QFileSystemEngine::canonicalName(fileEntry); + if (cache_enabled) { // be smart and store both + fileNames[QAbstractFileEngine::CanonicalName] = entry.filePath(); + fileNames[QAbstractFileEngine::CanonicalPathName] = entry.path(); + } + if (name == QAbstractFileEngine::CanonicalName) + ret = entry.filePath(); + else + ret = entry.path(); + break; + } + case QAbstractFileEngine::LinkName: + ret = QFileSystemEngine::getLinkTarget(fileEntry, metaData).filePath(); + break; + case QAbstractFileEngine::BundleName: + ret = QFileSystemEngine::bundleName(fileEntry); + break; + case QAbstractFileEngine::AbsoluteName: + case QAbstractFileEngine::AbsolutePathName: { + QFileSystemEntry entry = QFileSystemEngine::absoluteName(fileEntry); + if (cache_enabled) { // be smart and store both + fileNames[QAbstractFileEngine::AbsoluteName] = entry.filePath(); + fileNames[QAbstractFileEngine::AbsolutePathName] = entry.path(); + } + if (name == QAbstractFileEngine::AbsoluteName) + ret = entry.filePath(); + else + ret = entry.path(); + break; + } + default: break; + } + } else { + ret = fileEngine->fileName(name); + } if (ret.isNull()) ret = QLatin1String(""); if (cache_enabled) @@ -61,6 +101,7 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const { + Q_ASSERT(fileEngine); // should never be called when using the native FS if (cache_enabled && !fileOwners[(int)own].isNull()) return fileOwners[(int)own]; QString ret = fileEngine->owner(own); @@ -73,6 +114,7 @@ QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) const { + Q_ASSERT(fileEngine); // should never be called when using the native FS // We split the testing into tests for for LinkType, BundleType, PermsMask // and the rest. // Tests for file permissions on Windows can be slow, expecially on network @@ -133,6 +175,7 @@ uint QFileInfoPrivate::getFileFlags(QAbstractFileEngine::FileFlags request) cons QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) const { + Q_ASSERT(fileEngine); // should never be called when using the native FS if (!cache_enabled) clearFlags(); uint cf; @@ -330,23 +373,23 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const return true; if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed) return false; - if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive()) - return false; - if (fileinfo.size() == size()) { //if the size isn't the same... - QString file1 = canonicalFilePath(), - file2 = fileinfo.canonicalFilePath(); - if (file1.length() == file2.length()) { - if (!fileinfo.d_ptr->fileEngine->caseSensitive()) { - for (int i = 0; i < file1.length(); i++) { - if (file1.at(i).toLower() != file2.at(i).toLower()) - return false; - } - return true; - } - return (file1 == file2); - } + Qt::CaseSensitivity sensitive; + if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) { + if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine + return false; + + sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive; + // if both are native just compare the canonicalFilePath of both. + } else { + if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive()) + return false; + sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive; } - return false; + + if (fileinfo.size() != size()) //if the size isn't the same... + return false; + + return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0; } /*! @@ -502,7 +545,7 @@ QString QFileInfo::absolutePath() const if (d->isDefaultConstructed) { return QLatin1String(""); - } else if (d->fileName.isEmpty()) { + } else if (d->fileEntry.isEmpty()) { qWarning("QFileInfo::absolutePath: Constructed with empty filename"); return QLatin1String(""); } @@ -539,7 +582,7 @@ QString QFileInfo::path() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::PathName); + return d->fileEntry.path(); } /*! @@ -563,7 +606,7 @@ bool QFileInfo::isRelative() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return true; - return d->fileEngine->isRelativePath(); + return d->fileEntry.isRelative(); } /*! @@ -576,12 +619,10 @@ bool QFileInfo::isRelative() const bool QFileInfo::makeAbsolute() { if (d_ptr.constData()->isDefaultConstructed - || !d_ptr.constData()->fileEngine->isRelativePath()) + || !d_ptr.constData()->fileEntry.isRelative()) return false; - QString absFileName = d_ptr.constData()->getFileName(QAbstractFileEngine::AbsoluteName); - // QSharedDataPointer::operator->() will detach. - setFile(absFileName); + setFile(absoluteFilePath()); return true; } @@ -596,6 +637,11 @@ bool QFileInfo::exists() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::ExistsAttribute); + return d->metaData.exists(); + } return d->getFileFlags(QAbstractFileEngine::ExistsFlag); } @@ -623,7 +669,7 @@ QString QFileInfo::filePath() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::DefaultName); + return d->fileEntry.filePath(); } /*! @@ -642,7 +688,7 @@ QString QFileInfo::fileName() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::BaseName); + return d->fileEntry.fileName(); } /*! @@ -686,7 +732,7 @@ QString QFileInfo::baseName() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - return d->getFileName(QAbstractFileEngine::BaseName).section(QLatin1Char('.'), 0, 0); + return d->fileEntry.baseName(); } /*! @@ -705,9 +751,7 @@ QString QFileInfo::completeBaseName() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - QString name = d->getFileName(QAbstractFileEngine::BaseName); - int index = name.lastIndexOf(QLatin1Char('.')); - return (index == -1) ? name : name.left(index); + return d->fileEntry.completeBaseName(); } /*! @@ -726,11 +770,7 @@ QString QFileInfo::completeSuffix() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - QString fileName = d->getFileName(QAbstractFileEngine::BaseName); - int firstDot = fileName.indexOf(QLatin1Char('.')); - if (firstDot == -1) - return QLatin1String(""); - return fileName.mid(firstDot + 1); + return d->fileEntry.completeSuffix(); } /*! @@ -753,11 +793,7 @@ QString QFileInfo::suffix() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - QString fileName = d->getFileName(QAbstractFileEngine::BaseName); - int lastDot = fileName.lastIndexOf(QLatin1Char('.')); - if (lastDot == -1) - return QLatin1String(""); - return fileName.mid(lastDot + 1); + return d->fileEntry.suffix(); } @@ -781,8 +817,9 @@ QString QFileInfo::suffix() const */ QDir QFileInfo::dir() const { + Q_D(const QFileInfo); // ### Qt5: Maybe rename this to parentDirectory(), considering what it actually do? - return QDir(path()); + return QDir(d->fileEntry.path()); } /*! @@ -818,6 +855,11 @@ bool QFileInfo::isReadable() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserReadPermission); + return (d->metaData.permissions() & QFile::ReadUser) != 0; + } return d->getFileFlags(QAbstractFileEngine::ReadUserPerm); } @@ -831,6 +873,11 @@ bool QFileInfo::isWritable() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserWritePermission)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserWritePermission); + return (d->metaData.permissions() & QFile::WriteUser) != 0; + } return d->getFileFlags(QAbstractFileEngine::WriteUserPerm); } @@ -844,6 +891,11 @@ bool QFileInfo::isExecutable() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserExecutePermission)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserExecutePermission); + return (d->metaData.permissions() & QFile::ExeUser) != 0; + } return d->getFileFlags(QAbstractFileEngine::ExeUserPerm); } @@ -858,6 +910,11 @@ bool QFileInfo::isHidden() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::HiddenAttribute)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::HiddenAttribute); + return d->metaData.isHidden(); + } return d->getFileFlags(QAbstractFileEngine::HiddenFlag); } @@ -873,6 +930,11 @@ bool QFileInfo::isFile() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::FileType)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::FileType); + return d->metaData.isFile(); + } return d->getFileFlags(QAbstractFileEngine::FileType); } @@ -887,6 +949,11 @@ bool QFileInfo::isDir() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::DirectoryType)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::DirectoryType); + return d->metaData.isDirectory(); + } return d->getFileFlags(QAbstractFileEngine::DirectoryType); } @@ -903,6 +970,11 @@ bool QFileInfo::isBundle() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::BundleType)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::BundleType); + return d->metaData.isBundle(); + } return d->getFileFlags(QAbstractFileEngine::BundleType); } @@ -928,6 +1000,11 @@ bool QFileInfo::isSymLink() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::LinkType)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::LinkType); + return d->metaData.isLink(); + } return d->getFileFlags(QAbstractFileEngine::LinkType); } @@ -941,6 +1018,8 @@ bool QFileInfo::isRoot() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return true; + if (d->fileEngine == 0) + return d->fileEntry.isRoot(); return d->getFileFlags(QAbstractFileEngine::RootFlag); } @@ -987,6 +1066,11 @@ QString QFileInfo::owner() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserName)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserName); + return d->metaData.user(); + } return d->getFileOwner(QAbstractFileEngine::OwnerUser); } @@ -1003,6 +1087,11 @@ uint QFileInfo::ownerId() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return 0; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserId)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserId); + return d->metaData.userId(); + } return d->fileEngine->ownerId(QAbstractFileEngine::OwnerUser); } @@ -1021,6 +1110,11 @@ QString QFileInfo::group() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::GroupName)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::GroupName); + return d->metaData.group(); + } return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } @@ -1037,6 +1131,11 @@ uint QFileInfo::groupId() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return 0; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::GroupId)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::GroupId); + return d->metaData.groupId(); + } return d->fileEngine->ownerId(QAbstractFileEngine::OwnerGroup); } @@ -1058,6 +1157,13 @@ bool QFileInfo::permission(QFile::Permissions permissions) const Q_D(const QFileInfo); if (d->isDefaultConstructed) return false; + if (d->fileEngine == 0) { + // the QFileSystemMetaData::MetaDataFlag and QFile::Permissions overlap, so just static cast. + QFileSystemMetaData::MetaDataFlag permissionFlags = static_cast((int)permissions); + if (!d->cache_enabled || !d->metaData.hasFlags(permissionFlags)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, permissionFlags); + return (d->metaData.permissions() & permissions) == permissions; + } return d->getFileFlags(QAbstractFileEngine::FileFlags((int)permissions)) == (uint)permissions; } @@ -1070,6 +1176,11 @@ QFile::Permissions QFileInfo::permissions() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return 0; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::Permissions)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::Permissions); + return d->metaData.permissions(); + } return QFile::Permissions(d->getFileFlags(QAbstractFileEngine::PermsMask) & QAbstractFileEngine::PermsMask); } @@ -1085,6 +1196,11 @@ qint64 QFileInfo::size() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return 0; + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::SizeAttribute)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::SizeAttribute); + return d->metaData.size(); + } if (!d->getCachedFlag(QFileInfoPrivate::CachedSize)) { d->setCachedFlag(QFileInfoPrivate::CachedSize); d->fileSize = d->fileEngine->size(); @@ -1110,6 +1226,11 @@ QDateTime QFileInfo::created() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QDateTime(); + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::CreationTime)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::CreationTime); + return d->metaData.creationTime(); + } return d->getFileTime(QAbstractFileEngine::CreationTime); } @@ -1123,6 +1244,11 @@ QDateTime QFileInfo::lastModified() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QDateTime(); + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ModificationTime)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::ModificationTime); + return d->metaData.modificationTime(); + } return d->getFileTime(QAbstractFileEngine::ModificationTime); } @@ -1139,6 +1265,11 @@ QDateTime QFileInfo::lastRead() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QDateTime(); + if (d->fileEngine == 0) { + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::AccessTime)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::AccessTime); + return d->metaData.accessTime(); + } return d->getFileTime(QAbstractFileEngine::AccessTime); } diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index b9b1092..a97d4d3 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -58,13 +58,14 @@ #include "qdatetime.h" #include "qatomic.h" #include "qshareddata.h" +#include "qfilesystementry_p.h" +#include "qfilesystemengine_p.h" QT_BEGIN_NAMESPACE class QFileInfoPrivate : public QSharedData { public: - enum { CachedFileFlags=0x01, CachedLinkTypeFlag=0x02, CachedBundleTypeFlag=0x04, CachedMTime=0x10, CachedCTime=0x20, CachedATime=0x40, CachedSize =0x08, CachedPerms=0x80 }; @@ -76,8 +77,10 @@ public: cache_enabled(true), fileFlags(0), fileSize(0) {} inline QFileInfoPrivate(const QFileInfoPrivate ©) - : QSharedData(copy), fileEngine(QAbstractFileEngine::create(copy.fileName)), - fileName(copy.fileName), + : QSharedData(copy), + fileEntry(copy.fileEntry), + metaData(copy.metaData), + fileEngine(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)), cachedFlags(0), #ifndef QT_NO_FSFILEENGINE isDefaultConstructed(false), @@ -87,8 +90,8 @@ public: cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) {} inline QFileInfoPrivate(const QString &file) - : QSharedData(), fileEngine(QAbstractFileEngine::create(file)), - fileName(file), + : fileEntry(file), + fileEngine(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)), cachedFlags(0), #ifndef QT_NO_FSFILEENGINE isDefaultConstructed(false), @@ -106,6 +109,7 @@ public: (void)fileEngine->fileFlags(QAbstractFileEngine::Refresh); } inline void clear() { + metaData.clear(); clearFlags(); for (int i = QAbstractFileEngine::NFileNames - 1 ; i >= 0 ; --i) fileNames[i].clear(); @@ -118,9 +122,11 @@ public: QString getFileName(QAbstractFileEngine::FileName) const; QString getFileOwner(QAbstractFileEngine::FileOwner own) const; + QFileSystemEntry fileEntry; + mutable QFileSystemMetaData metaData; + QScopedPointer const fileEngine; - mutable QString fileName; mutable QString fileNames[QAbstractFileEngine::NFileNames]; mutable QString fileOwners[2]; @@ -134,6 +140,7 @@ public: { return cache_enabled ? (cachedFlags & c) : 0; } inline void setCachedFlag(uint c) const { if (cache_enabled) cachedFlags |= c; } + }; QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index f140319..a506fa4 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -134,6 +134,9 @@ struct QFileSystemMetaData OwnerIds = UserId | GroupId, + UserName = 0x40000000, + GroupName = 0x80000000, + PosixStatFlags = QFileSystemMetaData::OtherPermissions | QFileSystemMetaData::GroupPermissions | QFileSystemMetaData::OwnerPermissions @@ -224,6 +227,9 @@ struct QFileSystemMetaData uint userId() const { return userId_; } uint groupId() const { return groupId_; } + QString user() const { return QString(); /* TODO */ } + QString group() const { return QString(); /* TODO */ } + uint ownerId(QAbstractFileEngine::FileOwner owner) const { if (owner == QAbstractFileEngine::OwnerUser) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 08cb68d..cced207 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1255,9 +1255,10 @@ void tst_QFileInfo::isLocalFs() QFileInfo info(path); QFileInfoPrivate *privateInfo = getPrivate(info); - QVERIFY(privateInfo->fileEngine); - QCOMPARE(bool(privateInfo->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag) - & QAbstractFileEngine::LocalDiskFlag), isLocalFs); + QCOMPARE((privateInfo->fileEngine == 0), isLocalFs); + if (privateInfo->fileEngine) + QCOMPARE(bool(privateInfo->fileEngine->fileFlags(QAbstractFileEngine::LocalDiskFlag) + & QAbstractFileEngine::LocalDiskFlag), isLocalFs); } void tst_QFileInfo::refresh() -- cgit v0.12 From 2e0ccea933efa503607f455450ce5d7374ecc395 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Thu, 9 Sep 2010 12:18:36 +0200 Subject: Fix warning of unused variable on non-symbian --- src/corelib/io/qfsfileengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index e4c6f09..c6e7300 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -491,8 +491,8 @@ qint64 QFSFileEnginePrivate::nativeReadLine(char *data, qint64 maxlen) */ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) { - Q_Q(QFSFileEngine); #ifdef Q_OS_SYMBIAN + Q_Q(QFSFileEngine); if (symbianFile.SubSessionHandle()) { if(len > KMaxTInt) { //this check is more likely to catch a corrupt length, since it isn't possible to allocate 2GB buffers (yet..) -- cgit v0.12 From 99cc67240494e06297df3876163b40f79b861c36 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Thu, 9 Sep 2010 13:25:06 +0200 Subject: Make compile on symbian / armcc --- src/corelib/io/qfilesystemengine_symbian.cpp | 2 +- src/corelib/io/qfilesystemiterator_symbian.cpp | 2 +- src/corelib/io/qfilesystemmetadata_p.h | 4 +++- tests/auto/qfilesystementry/tst_qfilesystementry.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 1205274..759aafd 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -41,7 +41,7 @@ #include "qfilesystemengine_p.h" #include "qfsfileengine.h" -#include "qcore_symbian_p.h" +#include #include diff --git a/src/corelib/io/qfilesystemiterator_symbian.cpp b/src/corelib/io/qfilesystemiterator_symbian.cpp index 9093599..106eda9 100644 --- a/src/corelib/io/qfilesystemiterator_symbian.cpp +++ b/src/corelib/io/qfilesystemiterator_symbian.cpp @@ -41,7 +41,7 @@ #include "qfilesystemiterator_p.h" #include "qfilesystemengine_p.h" -#include "qcore_symbian_p.h" +#include QT_BEGIN_NAMESPACE diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index a506fa4..1164d42 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -62,7 +62,7 @@ #if defined(Q_OS_WIN) #elif defined(Q_OS_SYMBIAN) #include -#include "qdatetime_p.h" +#include #else #endif @@ -253,6 +253,8 @@ struct QFileSystemMetaData } uint userId() const { return (uint) -2; } uint groupId() const { return (uint) -2; } + QString user() const { return QString(); } + QString group() const { return QString(); } uint ownerId(QAbstractFileEngine::FileOwner owner) const { Q_UNUSED(owner); diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 267fa8c..e00a214 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -114,7 +114,7 @@ void tst_QFileSystemEntry::getSetCheck_data() QTest::newRow("absolutePath") << QString("A:dir\\without\\leading\\backslash.bat") << absPrefix + QString("A:\\dir\\without\\leading\\backslash.bat") - << "A:dir/without/leading/backslash.bat" << "backslash.bat" << << "backslash" << "backslash" << "bat" << "bat" << true; + << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "backslash" << "backslash" << "bat" << "bat" << true; } void tst_QFileSystemEntry::getSetCheck() -- cgit v0.12 From 5baa2d0da807ec5b4635c891ec27125769bade2d Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 9 Sep 2010 11:28:11 +0100 Subject: Fix tst_qdiriterator for symbian Since 21e0423a, the directory structure for iteration is created by the test on initialisation. Furthermore the directory structure no longer exists in git, causing a build error at the deployment stage. Also, defined Q_NO_SYMLINKS to disable test cases related to symlinks Reviewed-By: joao --- tests/auto/qdiriterator/qdiriterator.pro | 5 ----- tests/auto/qdiriterator/tst_qdiriterator.cpp | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/auto/qdiriterator/qdiriterator.pro b/tests/auto/qdiriterator/qdiriterator.pro index d60b52d..0a154d6 100644 --- a/tests/auto/qdiriterator/qdiriterator.pro +++ b/tests/auto/qdiriterator/qdiriterator.pro @@ -3,10 +3,5 @@ SOURCES += tst_qdiriterator.cpp RESOURCES += qdiriterator.qrc QT = core -wince*|symbian: { - addFiles.sources = entrylist recursiveDirs foo - addFiles.path = . - DEPLOYMENT += addFiles wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1 -} diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index 1a873b8..f78ce34 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -53,7 +53,7 @@ #endif #if defined(Q_OS_SYMBIAN) -// Open C in Symbian doesn't support symbolic links to directories +#define Q_NO_SYMLINKS #define Q_NO_SYMLINKS_TO_DIRS #endif -- cgit v0.12 From 113a56eb0c88cdee3209dcf16af8bc51ccef080d Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 9 Sep 2010 14:54:47 +0100 Subject: backward compatibility fix for QFileInfo::isRoot() In the old system, QFileInfo("p:/").isRoot() would return false because the file engine first checks exists(). Assuming P: is not mounted that would return false. This change makes QFileInfo::isRoot() check the drive exists. Reviewed-By: joao --- src/corelib/io/qfileinfo.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 232a32e..5d632d3 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1018,8 +1018,20 @@ bool QFileInfo::isRoot() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return true; - if (d->fileEngine == 0) - return d->fileEntry.isRoot(); + if (d->fileEngine == 0) { + if (d->fileEntry.isRoot()) { +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + //the path is a drive root, but the drive may not exist + //for backward compatibility, return true only if the drive exists + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::ExistsAttribute); + return d->metaData.exists(); +#else + return true; +#endif + } + return false; + } return d->getFileFlags(QAbstractFileEngine::RootFlag); } -- cgit v0.12 From 87c150517b36ac89f17f2455494dc63fccdb5727 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 9 Sep 2010 16:13:21 +0100 Subject: Create QFileSystemEntry objects with / as directory separator It simplifies the code for users of QFileSystemEntry to assume that filePath() returns / seperated paths, and nativeFilePath returns paths using the native dir separator (e.g. \) Reviewed-By: joao --- src/corelib/io/qfileinfo_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index a97d4d3..6db84c4 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -90,7 +90,7 @@ public: cache_enabled(copy.cache_enabled), fileFlags(0), fileSize(0) {} inline QFileInfoPrivate(const QString &file) - : fileEntry(file), + : fileEntry(QDir::fromNativeSeparators(file)), fileEngine(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)), cachedFlags(0), #ifndef QT_NO_FSFILEENGINE -- cgit v0.12 From e2f34f6b77c8ddb39a6983648818a25236ddeebb Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 9 Sep 2010 16:15:57 +0100 Subject: Set size and modification time to 0 if file does not exist Since we report the size and modification time as known in the knownFlags() for non existant files, they need to be set to something. In particular, size is used in QFileInfo comparisons. Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 759aafd..e725147 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -194,6 +194,10 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (!err) data.fillFromTEntry(ent); } + if (err) { + data.size_ = 0; + data.modificationTime_ = TTime(0); + } data.knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags; } return data.hasFlags(what); -- cgit v0.12 From 30dcb614f31d64f052312b65bdd7720974b809d4 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 9 Sep 2010 17:05:33 +0100 Subject: Set file metadata variables to known values when stat fails For unix port, set file times and size to 0, and owner/group id to -2 (nobody) for files that don't exist. Also implemented saving owner and group ids in fillFromStatBuf, which was missing. Reviewed-by: joao --- src/corelib/io/qfilesystemengine.cpp | 2 ++ src/corelib/io/qfilesystemengine_unix.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 0563a15..56072d4 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -280,6 +280,8 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) creationTime_ = statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime; modificationTime_ = statBuffer.st_mtime; accessTime_ = statBuffer.st_atime; + userId_ = statBuffer.st_uid; + groupId_ = statBuffer.st_gid; #endif } diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 8d77963..65cb42f 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -343,8 +343,15 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (statBufferValid) data.fillFromStatBuf(statBuffer); - else + else { entryExists = false; + data.creationTime_ = 0; + data.modificationTime_ = 0; + data.accessTime_ = 0; + data.size_ = 0; + data.userId_ = (uint) -2; + data.groupId_ = (uint) -2; + } // reset the mask data.knownFlagsMask |= QFileSystemMetaData::PosixStatFlags -- cgit v0.12 From 1a3d4eaf52669eff4e48d2f8a2d62c41347bf8d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 10 Sep 2010 09:15:27 +0200 Subject: Fixing QDir/tree traverseDirectory benchmark Was missing counter initialization at the start of QBENCHMARK loop. --- tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp index ad5ae98..cbe931d 100644 --- a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp +++ b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp @@ -154,6 +154,7 @@ private slots: QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks); + count = 0; while (iterator.hasNext()) { iterator.next(); ++count; -- cgit v0.12 From 5f0e9b7666c689a8b7ea23eefa5a7a68b0a0ed78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 10 Sep 2010 09:46:56 +0200 Subject: Minor clean up on QDirIterator Removing unnecessary garbage, inlining a destructor. --- src/corelib/io/qdiriterator.cpp | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index fd4b9c1..3544d87 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -102,21 +102,17 @@ QT_BEGIN_NAMESPACE class QDirIteratorPrivateIteratorStack : public QStack { public: - ~QDirIteratorPrivateIteratorStack(); + ~QDirIteratorPrivateIteratorStack() + { + qDeleteAll(*this); + } }; -QDirIteratorPrivateIteratorStack::~QDirIteratorPrivateIteratorStack() -{ - qDeleteAll(*this); -} - - class QDirIteratorPrivate { public: QDirIteratorPrivate(const QString &path, const QStringList &nameFilters, QDir::Filters filters, QDirIterator::IteratorFlags flags); - ~QDirIteratorPrivate(); void advance(); @@ -141,8 +137,6 @@ public: // Loop protection QSet visitedLinks; - - QDirIterator *q; }; /*! @@ -173,13 +167,6 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList /*! \internal */ -QDirIteratorPrivate::~QDirIteratorPrivate() -{ -} - -/*! - \internal -*/ void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo) { QString path = fileInfo.filePath(); @@ -375,7 +362,6 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags) : d(new QDirIteratorPrivate(dir.path(), dir.nameFilters(), dir.filter(), flags)) { - d->q = this; } /*! @@ -397,7 +383,6 @@ QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags) QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags) : d(new QDirIteratorPrivate(path, QStringList(), filters, flags)) { - d->q = this; } /*! @@ -415,7 +400,6 @@ QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorF QDirIterator::QDirIterator(const QString &path, IteratorFlags flags) : d(new QDirIteratorPrivate(path, QStringList(), QDir::NoFilter, flags)) { - d->q = this; } /*! @@ -438,7 +422,6 @@ QDirIterator::QDirIterator(const QString &path, const QStringList &nameFilters, QDir::Filters filters, IteratorFlags flags) : d(new QDirIteratorPrivate(path, nameFilters, filters, flags)) { - d->q = this; } /*! -- cgit v0.12 From 4506d57fc0320234efcd4ab39e2fe9c2810b4d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 10 Sep 2010 10:21:18 +0200 Subject: QFileinfo: fix isSymLink on Mac On Mac OS X, we also flag Alias Records as symbolic links. Since we now make the distinction in the engine, we need to query for it explicitly. Added a new type LegacyLinkType to QFileSystemMetaData to document this old behavior. --- src/corelib/io/qfileinfo.cpp | 6 +++--- src/corelib/io/qfilesystemmetadata_p.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 5d632d3..68f1f55 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1001,9 +1001,9 @@ bool QFileInfo::isSymLink() const if (d->isDefaultConstructed) return false; if (d->fileEngine == 0) { - if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::LinkType)) - QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::LinkType); - return d->metaData.isLink(); + if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::LegacyLinkType)) + QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::LegacyLinkType); + return d->metaData.isLegacyLink(); } return d->getFileFlags(QAbstractFileEngine::LinkType); } diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 1164d42..9df762c 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -112,6 +112,8 @@ struct QFileSystemMetaData #endif SequentialType = 0x00800000, // Note: overlaps with QAbstractFileEngine::RootFlag + LegacyLinkType = LinkType | AliasType, + Type = LinkType | FileType | DirectoryType | BundleType | SequentialType | AliasType, // Attributes @@ -195,6 +197,7 @@ struct QFileSystemMetaData bool isBundle() const { return false; } bool isAlias() const { return false; } #endif + bool isLegacyLink() const { return (entryFlags & LegacyLinkType); } bool isSequential() const { return (entryFlags & SequentialType); } bool isHidden() const { return (entryFlags & HiddenAttribute); } -- cgit v0.12 From 529aa7d39f8eab70a954f02ac1ac5a6bac9889bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 10 Sep 2010 14:17:12 +0200 Subject: Fix QFileInfo::isHidden on Mac Having HiddenAttribute as part of PosixStatFlags, meant that we would assume we knew about it whenever we stat'ed, which wasn't the intent. As that is just one of the queries we do on Mac OS to determine if a file is considered hidden. Instead, we explicitly ask for a stat anytime the attribute is queried for. The proper fix will be to perform the cheap operations (e.g., file name begins with '.') first and only stat if we still haven't got an answer. --- src/corelib/io/qfilesystemengine_unix.cpp | 7 +++++++ src/corelib/io/qfilesystemmetadata_p.h | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 65cb42f..eb6b9f1 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -300,6 +300,13 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } #endif +#if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if (what & QFileSystemMetaData::HiddenAttribute) { + // Mac OS >= 10.5: st_flags & UF_HIDDEN + what |= QFileSystemMetaData::PosixStatFlags; + } +#endif + if (what & QFileSystemMetaData::PosixStatFlags) what |= QFileSystemMetaData::PosixStatFlags; diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 9df762c..c34cc1e 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -145,10 +145,6 @@ struct QFileSystemMetaData | QFileSystemMetaData::FileType | QFileSystemMetaData::DirectoryType | QFileSystemMetaData::SequentialType -#if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - // Mac OS >= 10.5: st_flags & UF_HIDDEN - | QFileSystemMetaData::HiddenAttribute -#endif | QFileSystemMetaData::SizeAttribute | QFileSystemMetaData::Times | QFileSystemMetaData::OwnerIds, -- cgit v0.12 From 69b8cf630e9cc83cd678814bf88495c7fbb438f4 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 10 Sep 2010 13:42:53 +0100 Subject: Move OS specific inlines outside of class declaration This makes it easier to read, as common functions with different implementations depending on the OS are only declared once in the class. Reviewed-By: joao --- src/corelib/io/qfilesystemmetadata_p.h | 140 +++++++++++++++++++-------------- 1 file changed, 79 insertions(+), 61 deletions(-) diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index c34cc1e..f7bc863 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -70,8 +70,9 @@ QT_BEGIN_NAMESPACE class QFileSystemEngine; -struct QFileSystemMetaData +class QFileSystemMetaData { +public: QFileSystemMetaData() : knownFlagsMask(0) { @@ -186,13 +187,8 @@ struct QFileSystemMetaData bool isLink() const { return (entryFlags & LinkType); } bool isFile() const { return (entryFlags & FileType); } bool isDirectory() const { return (entryFlags & DirectoryType); } -#if !defined(QWS) && defined(Q_OS_MAC) - bool isBundle() const { return (entryFlags & BundleType); } - bool isAlias() const { return (entryFlags & AliasType); } -#else - bool isBundle() const { return false; } - bool isAlias() const { return false; } -#endif + bool isBundle() const; + bool isAlias() const; bool isLegacyLink() const { return (entryFlags & LegacyLinkType); } bool isSequential() const { return (entryFlags & SequentialType); } bool isHidden() const { return (entryFlags & HiddenAttribute); } @@ -201,65 +197,21 @@ struct QFileSystemMetaData QFile::Permissions permissions() const { return QFile::Permissions(Permissions & entryFlags); } -#if defined(Q_OS_UNIX) && !defined (Q_OS_SYMBIAN) - QDateTime creationTime() const { return QDateTime::fromTime_t(creationTime_); } - QDateTime modificationTime() const { return QDateTime::fromTime_t(modificationTime_); } - QDateTime accessTime() const { return QDateTime::fromTime_t(accessTime_); } - - QDateTime fileTime(QAbstractFileEngine::FileTime time) const - { - switch (time) - { - case QAbstractFileEngine::ModificationTime: - return modificationTime(); - - case QAbstractFileEngine::AccessTime: - return accessTime(); - - case QAbstractFileEngine::CreationTime: - return creationTime(); - } - - return QDateTime(); - } - - uint userId() const { return userId_; } - uint groupId() const { return groupId_; } + QDateTime creationTime() const; + QDateTime modificationTime() const; + QDateTime accessTime() const; - QString user() const { return QString(); /* TODO */ } - QString group() const { return QString(); /* TODO */ } + QDateTime fileTime(QAbstractFileEngine::FileTime time) const; + uint userId() const; + uint groupId() const; + QString user() const; + QString group() const; + uint ownerId(QAbstractFileEngine::FileOwner owner) const; - uint ownerId(QAbstractFileEngine::FileOwner owner) const - { - if (owner == QAbstractFileEngine::OwnerUser) - return userId(); - else - return groupId(); - } -#endif #ifdef Q_OS_UNIX void fillFromStatBuf(const QT_STATBUF &statBuffer); #endif #ifdef Q_OS_SYMBIAN - QDateTime creationTime() const { return modificationTime(); } - QDateTime modificationTime() const { return qt_symbian_TTime_To_QDateTime(modificationTime_); } - QDateTime accessTime() const { return modificationTime(); } - - QDateTime fileTime(QAbstractFileEngine::FileTime time) const - { - Q_UNUSED(time); - return modificationTime(); - } - uint userId() const { return (uint) -2; } - uint groupId() const { return (uint) -2; } - QString user() const { return QString(); } - QString group() const { return QString(); } - uint ownerId(QAbstractFileEngine::FileOwner owner) const - { - Q_UNUSED(owner); - return (uint) -2; - } - void fillFromTEntry(const TEntry& entry); void fillFromVolumeInfo(const TVolumeInfo& info); #endif @@ -289,6 +241,72 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags) +#if !defined(QWS) && defined(Q_OS_MAC) +inline bool QFileSystemMetaData::isBundle() const { return (entryFlags & BundleType); } +inline bool QFileSystemMetaData::isAlias() const { return (entryFlags & AliasType); } +#else +inline bool QFileSystemMetaData::isBundle() const { return false; } +inline bool QFileSystemMetaData::isAlias() const { return false; } +#endif + +#if defined(Q_OS_UNIX) && !defined (Q_OS_SYMBIAN) +inline QDateTime QFileSystemMetaData::creationTime() const { return QDateTime::fromTime_t(creationTime_); } +inline QDateTime QFileSystemMetaData::modificationTime() const { return QDateTime::fromTime_t(modificationTime_); } +inline QDateTime QFileSystemMetaData::accessTime() const { return QDateTime::fromTime_t(accessTime_); } + +inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime time) const +{ + switch (time) + { + case QAbstractFileEngine::ModificationTime: + return modificationTime(); + + case QAbstractFileEngine::AccessTime: + return accessTime(); + + case QAbstractFileEngine::CreationTime: + return creationTime(); + } + + return QDateTime(); +} + +inline uint QFileSystemMetaData::userId() const { return userId_; } +inline uint QFileSystemMetaData::groupId() const { return groupId_; } + +inline QString QFileSystemMetaData::user() const { return QString(); /* TODO */ } +inline QString QFileSystemMetaData::group() const { return QString(); /* TODO */ } + +inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const +{ + if (owner == QAbstractFileEngine::OwnerUser) + return userId(); + else + return groupId(); +} +#endif + +#ifdef Q_OS_SYMBIAN +inline QDateTime QFileSystemMetaData::creationTime() const { return modificationTime(); } +inline QDateTime QFileSystemMetaData::modificationTime() const { return qt_symbian_TTime_To_QDateTime(modificationTime_); } +inline QDateTime QFileSystemMetaData::accessTime() const { return modificationTime(); } + +inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime time) const +{ + Q_UNUSED(time); + return modificationTime(); +} +inline uint QFileSystemMetaData::userId() const { return (uint) -2; } +inline uint QFileSystemMetaData::groupId() const { return (uint) -2; } +inline QString QFileSystemMetaData::user() const { return QString(); } +inline QString QFileSystemMetaData::group() const { return QString(); } +inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const +{ + Q_UNUSED(owner); + return (uint) -2; +} +#endif + QT_END_NAMESPACE #endif // include guard -- cgit v0.12 From cc23ac99d68af5c9bf537e5451b7ee7c7698e954 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 10 Sep 2010 15:15:43 +0200 Subject: Move resolving of user/group name to the engine. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Abecasis --- src/corelib/io/qfileinfo.cpp | 25 +++++++++++++------------ src/corelib/io/qfilesystemengine.cpp | 16 ++++++++++++++++ src/corelib/io/qfilesystemengine_p.h | 4 ++++ src/corelib/io/qfilesystemengine_symbian.cpp | 12 ++++++++++++ src/corelib/io/qfilesystemengine_unix.cpp | 12 ++++++++++++ src/corelib/io/qfilesystemengine_win.cpp | 12 ++++++++++++ src/corelib/io/qfilesystemmetadata_p.h | 13 +------------ 7 files changed, 70 insertions(+), 24 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 68f1f55..d49ee74 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -101,10 +101,21 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const { - Q_ASSERT(fileEngine); // should never be called when using the native FS if (cache_enabled && !fileOwners[(int)own].isNull()) return fileOwners[(int)own]; - QString ret = fileEngine->owner(own); + QString ret; + if (fileEngine == 0) { + switch (own) { + case QAbstractFileEngine::OwnerUser: + ret = QFileSystemEngine::resolveUserName(fileEntry, metaData); + break; + case QAbstractFileEngine::OwnerGroup: + ret = QFileSystemEngine::resolveGroupName(fileEntry, metaData); + break; + } + } else { + ret = fileEngine->owner(own); + } if (ret.isNull()) ret = QLatin1String(""); if (cache_enabled) @@ -1078,11 +1089,6 @@ QString QFileInfo::owner() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - if (d->fileEngine == 0) { - if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::UserName)) - QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::UserName); - return d->metaData.user(); - } return d->getFileOwner(QAbstractFileEngine::OwnerUser); } @@ -1122,11 +1128,6 @@ QString QFileInfo::group() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return QLatin1String(""); - if (d->fileEngine == 0) { - if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::GroupName)) - QFileSystemEngine::fillMetaData(d->fileEntry, d->metaData, QFileSystemMetaData::GroupName); - return d->metaData.group(); - } return d->getFileOwner(QAbstractFileEngine::OwnerGroup); } diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 56072d4..cbc4c42 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -287,4 +287,20 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) #endif +//static +QString QFileSystemEngine::resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData) +{ + if (!metaData.hasFlags(QFileSystemMetaData::UserId)) + QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId); + return resolveGroupName(metaData.userId()); +} + +//static +QString QFileSystemEngine::resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData) +{ + if (!metaData.hasFlags(QFileSystemMetaData::GroupId)) + QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::GroupId); + return resolveGroupName(metaData.groupId()); +} + QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 94fb4e5..94a8175 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -67,6 +67,10 @@ public: static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data); static QFileSystemEntry canonicalName(const QFileSystemEntry &entry); static QFileSystemEntry absoluteName(const QFileSystemEntry &entry); + static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data); + static QString resolveUserName(uint userId); + static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data); + static QString resolveGroupName(uint groupId); static QString bundleName(const QFileSystemEntry &entry); diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index e725147..1ed4ee8 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -124,6 +124,18 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) } //static +QString QFileSystemEngine::resolveUserName(uint userId) +{ + return QString(); // TODO +} + +//static +QString QFileSystemEngine::resolveGroupName(uint groupId) +{ + return QString(); // TODO +} + +//static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry); diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index eb6b9f1..fdb881f 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -267,6 +267,18 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) } //static +QString QFileSystemEngine::resolveUserName(uint userId) +{ + return QString(); // TODO +} + +//static +QString QFileSystemEngine::resolveGroupName(uint groupId) +{ + return QString(); // TODO +} + +//static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { #if !defined(QWS) && defined(Q_OS_MAC) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 8572506..28d5db4 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -67,6 +67,18 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) } //static +QString QFileSystemEngine::resolveUserName(uint userId) +{ + return QString(); // TODO +} + +//static +QString QFileSystemEngine::resolveGroupName(uint groupId) +{ + return QString(); // TODO +} + +//static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { return QString(); diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index f7bc863..ec25a0b 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -137,9 +137,6 @@ public: OwnerIds = UserId | GroupId, - UserName = 0x40000000, - GroupName = 0x80000000, - PosixStatFlags = QFileSystemMetaData::OtherPermissions | QFileSystemMetaData::GroupPermissions | QFileSystemMetaData::OwnerPermissions @@ -204,8 +201,6 @@ public: QDateTime fileTime(QAbstractFileEngine::FileTime time) const; uint userId() const; uint groupId() const; - QString user() const; - QString group() const; uint ownerId(QAbstractFileEngine::FileOwner owner) const; #ifdef Q_OS_UNIX @@ -256,8 +251,7 @@ inline QDateTime QFileSystemMetaData::accessTime() const { return QDa inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime time) const { - switch (time) - { + switch (time) { case QAbstractFileEngine::ModificationTime: return modificationTime(); @@ -274,9 +268,6 @@ inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime tim inline uint QFileSystemMetaData::userId() const { return userId_; } inline uint QFileSystemMetaData::groupId() const { return groupId_; } -inline QString QFileSystemMetaData::user() const { return QString(); /* TODO */ } -inline QString QFileSystemMetaData::group() const { return QString(); /* TODO */ } - inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const { if (owner == QAbstractFileEngine::OwnerUser) @@ -298,8 +289,6 @@ inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime tim } inline uint QFileSystemMetaData::userId() const { return (uint) -2; } inline uint QFileSystemMetaData::groupId() const { return (uint) -2; } -inline QString QFileSystemMetaData::user() const { return QString(); } -inline QString QFileSystemMetaData::group() const { return QString(); } inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const { Q_UNUSED(owner); -- cgit v0.12 From 8f40161a7932e901a9f6fe59b5b3d2666c5482c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 10 Sep 2010 17:25:14 +0200 Subject: QDirIterator: Use new native iterators when possible Native iterators interface allows propagation of meta data gathered during directory traversal. Reviewed-by: Shane Kearns --- src/corelib/io/qdiriterator.cpp | 99 +++++++++++++++++++++++++++++++---------- src/corelib/io/qfileinfo.cpp | 7 +++ src/corelib/io/qfileinfo.h | 4 ++ src/corelib/io/qfileinfo_p.h | 14 +++++- 4 files changed, 100 insertions(+), 24 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 3544d87..2e67bfd 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -97,9 +97,17 @@ #include #include +#include +#include +#include +#include +#include +#include + QT_BEGIN_NAMESPACE -class QDirIteratorPrivateIteratorStack : public QStack +template +class QDirIteratorPrivateIteratorStack : public QStack { public: ~QDirIteratorPrivateIteratorStack() @@ -116,6 +124,7 @@ public: void advance(); + bool entryMatches(const QString & fileName, const QFileInfo &fileInfo); void pushDirectory(const QFileInfo &fileInfo); void checkAndPushDirectory(const QFileInfo &); bool matchesFilters(const QString &fileName, const QFileInfo &fi) const; @@ -131,7 +140,9 @@ public: QVector nameRegExps; #endif - QDirIteratorPrivateIteratorStack fileEngineIterators; + QDirIteratorPrivateIteratorStack fileEngineIterators; + QDirIteratorPrivateIteratorStack nativeIterators; + QFileInfo currentFileInfo; QFileInfo nextFileInfo; @@ -144,8 +155,7 @@ public: */ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList &nameFilters, QDir::Filters filters, QDirIterator::IteratorFlags flags) - : engine(QAbstractFileEngine::create(path)) - , path(path) + : path(path) , nameFilters(nameFilters.contains(QLatin1String("*")) ? QStringList() : nameFilters) , filters(QDir::NoFilter == filters ? QDir::AllEntries : filters) , iteratorFlags(flags) @@ -159,8 +169,19 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList QRegExp::Wildcard)); #endif +#ifdef Q_OS_UNIX + QFileSystemEntry fileEntry(path); + QFileSystemMetaData metaData; + + engine.reset(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)); + QFileInfo fileInfo(new QFileInfoPrivate(fileEntry, metaData)); +#else + engine.reset(QAbstractFileEngine::create(path)); + QFileInfo fileInfo(path); +#endif + // Populate fields for hasNext() and next() - pushDirectory(QFileInfo(path)); + pushDirectory(fileInfo); advance(); } @@ -188,34 +209,63 @@ void QDirIteratorPrivate::pushDirectory(const QFileInfo &fileInfo) } else { // No iterator; no entry list. } + } else { + QFileSystemIterator *it = new QFileSystemIterator(fileInfo.d_ptr->fileEntry, + filters, nameFilters, iteratorFlags); + nativeIterators << it; } } -/*! - \internal -*/ -void QDirIteratorPrivate::advance() +inline bool QDirIteratorPrivate::entryMatches(const QString & fileName, const QFileInfo &fileInfo) { - while (!fileEngineIterators.isEmpty()) { + checkAndPushDirectory(fileInfo); - // Find the next valid iterator that matches the filters. - while (fileEngineIterators.top()->hasNext()) { - QAbstractFileEngineIterator *it = fileEngineIterators.top(); - it->next(); + if (matchesFilters(fileName, fileInfo)) { + currentFileInfo = nextFileInfo; + nextFileInfo = fileInfo; - const QFileInfo info = it->currentFileInfo(); - checkAndPushDirectory(it->currentFileInfo()); + //We found a matching entry. + return true; + } - if (matchesFilters(it->currentFileName(), info)) { - currentFileInfo = nextFileInfo; - nextFileInfo = info; + return false; +} - //We found a matching entry. - return; +/*! + \internal +*/ +void QDirIteratorPrivate::advance() +{ + if (engine) { + while (!fileEngineIterators.isEmpty()) { + // Find the next valid iterator that matches the filters. + QAbstractFileEngineIterator *it; + while (it = fileEngineIterators.top(), it->hasNext()) { + it->next(); + if (entryMatches(it->currentFileName(), it->currentFileInfo())) + return; } + + fileEngineIterators.pop(); + delete it; } + } else { + QFileSystemEntry nextEntry; + QFileSystemMetaData nextMetaData; + + while (!nativeIterators.isEmpty()) { + // Find the next valid iterator that matches the filters. + QFileSystemIterator *it; + while (it = nativeIterators.top(), it->advance(nextEntry, nextMetaData)) { + QFileInfo info(new QFileInfoPrivate(nextEntry, nextMetaData)); + + if (entryMatches(nextEntry.fileName(), info)) + return; + } - delete fileEngineIterators.pop(); + nativeIterators.pop(); + delete it; + } } currentFileInfo = nextFileInfo; @@ -455,7 +505,10 @@ QString QDirIterator::next() */ bool QDirIterator::hasNext() const { - return !d->fileEngineIterators.isEmpty(); + if (d->engine) + return !d->fileEngineIterators.isEmpty(); + else + return !d->nativeIterators.isEmpty(); } /*! diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index d49ee74..83df26d 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -291,6 +291,13 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request) */ /*! + \internal +*/ +QFileInfo::QFileInfo(QFileInfoPrivate *p) : d_ptr(p) +{ +} + +/*! Constructs an empty QFileInfo object. Note that an empty QFileInfo object contain no file reference. diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index f0128b1..273a5f7 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -53,11 +53,15 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) class QDir; +class QDirIteratorPrivate; class QDateTime; class QFileInfoPrivate; class Q_CORE_EXPORT QFileInfo { + friend class QDirIteratorPrivate; + explicit QFileInfo(QFileInfoPrivate *d); + public: QFileInfo(); QFileInfo(const QString &file); diff --git a/src/corelib/io/qfileinfo_p.h b/src/corelib/io/qfileinfo_p.h index 6db84c4..869a7a6 100644 --- a/src/corelib/io/qfileinfo_p.h +++ b/src/corelib/io/qfileinfo_p.h @@ -58,9 +58,11 @@ #include "qdatetime.h" #include "qatomic.h" #include "qshareddata.h" -#include "qfilesystementry_p.h" #include "qfilesystemengine_p.h" +#include +#include + QT_BEGIN_NAMESPACE class QFileInfoPrivate : public QSharedData @@ -102,6 +104,16 @@ public: { } + inline QFileInfoPrivate(const QFileSystemEntry &file, const QFileSystemMetaData &data) + : QSharedData(), + fileEntry(file), + metaData(data), + cachedFlags(0), + isDefaultConstructed(false), + cache_enabled(true), fileFlags(0), fileSize(0) + { + } + inline void clearFlags() const { fileFlags = 0; cachedFlags = 0; -- cgit v0.12 From ce74c076062c84f183f72947730db7b0e2d5ab54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 10 Sep 2010 17:43:23 +0200 Subject: Refactored QFSFileEngineIterator/Unix into new internal native iterators. QFSFileEngineIterator will use that internally, currently only on non-windows platforms. This implementation can be reused on Windows once the native iterators are in place there as well. Reviewed-by: Shane Kearns --- qmake/Makefile.unix | 7 +- qmake/qmake.pri | 2 +- src/corelib/io/io.pri | 1 - src/corelib/io/qfileinfo.h | 2 +- src/corelib/io/qfilesystemengine.cpp | 59 +++++++++++ src/corelib/io/qfilesystemiterator_p.h | 13 ++- src/corelib/io/qfilesystemiterator_unix.cpp | 53 +++++++++- src/corelib/io/qfilesystemmetadata_p.h | 1 + src/corelib/io/qfsfileengine_iterator.cpp | 45 ++++++++ src/corelib/io/qfsfileengine_iterator_p.h | 9 ++ src/corelib/io/qfsfileengine_iterator_unix.cpp | 140 ------------------------- src/tools/bootstrap/bootstrap.pro | 3 +- 12 files changed, 181 insertions(+), 154 deletions(-) delete mode 100644 src/corelib/io/qfsfileengine_iterator_unix.cpp diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index d248831..5ea023f 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -17,7 +17,7 @@ OBJS=project.o property.o main.o makefile.o unixmake2.o unixmake.o \ QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qglobal.o \ qbytearray.o qbytearraymatcher.o qdatastream.o qbuffer.o qlist.o qfile.o \ qfilesystementry.o qfilesystemengine_unix.o qfilesystemengine.o qfilesystemiterator_unix.o \ - qfsfileengine_unix.o qfsfileengine_iterator_unix.o qfsfileengine.o \ + qfsfileengine_unix.o qfsfileengine.o \ qfsfileengine_iterator.o qregexp.o qvector.o qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o \ qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o \ qmap.o qmetatype.o qsettings.o qlibraryinfo.o qvariant.o qvsnprintf.o \ @@ -49,7 +49,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_mac.cpp \ $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_unix.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp \ - $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_unix.cpp $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator.cpp \ + $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator.cpp \ $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(SOURCE_PATH)/src/corelib/tools/qlist.cpp \ $(SOURCE_PATH)/src/corelib/tools/qvector.cpp $(SOURCE_PATH)/src/corelib/tools/qbitarray.cpp \ $(SOURCE_PATH)/src/corelib/io/qdiriterator.cpp \ @@ -188,9 +188,6 @@ qfsfileengine_iterator.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator.c qfsfileengine_unix.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_unix.cpp -qfsfileengine_iterator_unix.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_unix.cpp - $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_unix.cpp - qabstractfileengine.o: $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp diff --git a/qmake/qmake.pri b/qmake/qmake.pri index ae31eca..cd81c82 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -127,7 +127,7 @@ bootstrap { #Qt code qxmlutils.h unix { - SOURCES += qfilesystemengine_unix.cpp qfilesystemiterator_unix.cpp qfsfileengine_unix.cpp qfsfileengine_iterator_unix.cpp + SOURCES += qfilesystemengine_unix.cpp qfilesystemiterator_unix.cpp qfsfileengine_unix.cpp mac { SOURCES += qfilesystemengine_mac.cpp SOURCES += qcore_mac.cpp qsettings_mac.cpp diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 4a20dfa..4a2f042 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -73,7 +73,6 @@ win32 { SOURCES += io/qfilesystemengine_win.cpp SOURCES += io/qfilesystemiterator_win.cpp } else:unix { - SOURCES += io/qfsfileengine_iterator_unix.cpp SOURCES += io/qfsfileengine_unix.cpp symbian { SOURCES += io/qfilesystemengine_symbian.cpp diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h index 273a5f7..92bea5e 100644 --- a/src/corelib/io/qfileinfo.h +++ b/src/corelib/io/qfileinfo.h @@ -60,9 +60,9 @@ class QFileInfoPrivate; class Q_CORE_EXPORT QFileInfo { friend class QDirIteratorPrivate; +public: explicit QFileInfo(QFileInfoPrivate *d); -public: QFileInfo(); QFileInfo(const QString &file); QFileInfo(const QFile &file); diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index cbc4c42..4791dfc 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -285,6 +285,65 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) #endif } +void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry) +{ + // ### This will clear all entry flags and knownFlagsMask + switch (entry.d_type) + { + case DT_DIR: + knownFlagsMask = QFileSystemMetaData::LinkType + | QFileSystemMetaData::FileType + | QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::SequentialType + | QFileSystemMetaData::ExistsAttribute; + + entryFlags = QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::ExistsAttribute; + + break; + + case DT_BLK: + case DT_CHR: + case DT_FIFO: + case DT_SOCK: + // ### System attribute + knownFlagsMask = QFileSystemMetaData::LinkType + | QFileSystemMetaData::FileType + | QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::BundleType + | QFileSystemMetaData::AliasType + | QFileSystemMetaData::SequentialType + | QFileSystemMetaData::ExistsAttribute; + + entryFlags = QFileSystemMetaData::SequentialType + | QFileSystemMetaData::ExistsAttribute; + + break; + + case DT_LNK: + knownFlagsMask = QFileSystemMetaData::LinkType; + entryFlags = QFileSystemMetaData::LinkType; + break; + + case DT_REG: + knownFlagsMask = QFileSystemMetaData::LinkType + | QFileSystemMetaData::FileType + | QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::BundleType + | QFileSystemMetaData::SequentialType + | QFileSystemMetaData::ExistsAttribute; + + entryFlags = QFileSystemMetaData::FileType + | QFileSystemMetaData::ExistsAttribute; + + break; + + case DT_UNKNOWN: + default: + clear(); + } +} + #endif //static diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h index ed1ef5e..d3b195d 100644 --- a/src/corelib/io/qfilesystemiterator_p.h +++ b/src/corelib/io/qfilesystemiterator_p.h @@ -66,6 +66,7 @@ #elif defined (Q_OS_SYMBIAN) #include #else +#include #endif QT_BEGIN_NAMESPACE @@ -73,12 +74,15 @@ QT_BEGIN_NAMESPACE class QFileSystemIterator { public: - QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters, QDirIterator::IteratorFlags flags); + QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, + const QStringList &nameFilters, QDirIterator::IteratorFlags flags + = QDirIterator::FollowSymlinks | QDirIterator::Subdirectories); ~QFileSystemIterator(); bool advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData); private: + QFileSystemEntry::NativePath nativePath; // Platform-specific data #if defined(Q_OS_WIN) @@ -88,6 +92,13 @@ private: TInt lastError; TInt entryIndex; #else + QT_DIR *dir; + QT_DIRENT *dirEntry; +#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) + // for readdir_r + QScopedPointer mt_file; +#endif + int lastError; #endif Q_DISABLE_COPY(QFileSystemIterator) diff --git a/src/corelib/io/qfilesystemiterator_unix.cpp b/src/corelib/io/qfilesystemiterator_unix.cpp index 3c73496..00ccd41 100644 --- a/src/corelib/io/qfilesystemiterator_unix.cpp +++ b/src/corelib/io/qfilesystemiterator_unix.cpp @@ -39,27 +39,74 @@ ** ****************************************************************************/ +#include "qplatformdefs.h" #include "qfilesystemiterator_p.h" +#include +#include + QT_BEGIN_NAMESPACE QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters, QDirIterator::IteratorFlags flags) + : nativePath(entry.nativeFilePath()) + , dir(0) + , dirEntry(0) + , lastError(0) { - Q_UNUSED(entry) Q_UNUSED(filters) Q_UNUSED(nameFilters) Q_UNUSED(flags) + + if ((dir = QT_OPENDIR(nativePath.constData())) == 0) { + lastError = errno; + } else { + + if (!nativePath.endsWith('/')) + nativePath.append('/'); + +#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) + // ### Race condition; we should use fpathconf and dirfd(). + size_t maxPathName = ::pathconf(nativePath.constData(), _PC_NAME_MAX); + if (maxPathName == size_t(-1)) + maxPathName = FILENAME_MAX; + maxPathName += sizeof(QT_DIRENT) + 1; + + QT_DIRENT *p = reinterpret_cast(::malloc(maxPathName)); + Q_CHECK_PTR(p); + + mt_file.reset(p); +#endif + } } QFileSystemIterator::~QFileSystemIterator() { + if (dir) + QT_CLOSEDIR(dir); } bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) { - Q_UNUSED(fileEntry) - Q_UNUSED(metaData) + if (!dir) + return false; + +#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) + lastError = QT_READDIR_R(dir, mt_file.data(), &dirEntry); + if (lastError) + return false; +#else + // ### add local lock to prevent breaking reentrancy + dirEntry = QT_READDIR(dir); +#endif // _POSIX_THREAD_SAFE_FUNCTIONS + + if (dirEntry) { + fileEntry = QFileSystemEntry(nativePath + QByteArray(dirEntry->d_name), QFileSystemEntry::FromNativePath()); + metaData.fillFromDirEnt(*dirEntry); + return true; + } + + lastError = errno; return false; } diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index ec25a0b..e45c5dc 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -205,6 +205,7 @@ public: #ifdef Q_OS_UNIX void fillFromStatBuf(const QT_STATBUF &statBuffer); + void fillFromDirEnt(const QT_DIRENT &statBuffer); #endif #ifdef Q_OS_SYMBIAN void fillFromTEntry(const TEntry& entry); diff --git a/src/corelib/io/qfsfileengine_iterator.cpp b/src/corelib/io/qfsfileengine_iterator.cpp index 7e7d70a..4617f49 100644 --- a/src/corelib/io/qfsfileengine_iterator.cpp +++ b/src/corelib/io/qfsfileengine_iterator.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qfsfileengine_iterator_p.h" +#include "qfileinfo_p.h" #include "qvariant.h" #ifndef QT_NO_FSFILEENGINE @@ -48,15 +49,35 @@ QT_BEGIN_NAMESPACE QFSFileEngineIterator::QFSFileEngineIterator(QDir::Filters filters, const QStringList &filterNames) : QAbstractFileEngineIterator(filters, filterNames) +#ifdef Q_OS_UNIX + , done(false) +#endif { +#ifndef Q_OS_UNIX newPlatformSpecifics(); +#endif } QFSFileEngineIterator::~QFSFileEngineIterator() { +#ifndef Q_OS_UNIX deletePlatformSpecifics(); +#endif } +#ifdef Q_OS_UNIX +bool QFSFileEngineIterator::hasNext() const +{ + if (!done && !nativeIterator) { + nativeIterator.reset(new QFileSystemIterator(QFileSystemEntry(path()), + filters(), nameFilters())); + advance(); + } + + return !done; +} +#endif + QString QFSFileEngineIterator::next() { if (!hasNext()) @@ -66,14 +87,38 @@ QString QFSFileEngineIterator::next() return currentFilePath(); } +#ifdef Q_OS_UNIX +void QFSFileEngineIterator::advance() const +{ + currentInfo = nextInfo; + + QFileSystemEntry entry; + QFileSystemMetaData data; + if (nativeIterator->advance(entry, data)) { + nextInfo = QFileInfo(new QFileInfoPrivate(entry, data)); + } else { + done = true; + nativeIterator.reset(); + } +} +#endif + QString QFSFileEngineIterator::currentFileName() const { +#ifdef Q_OS_UNIX + return currentInfo.fileName(); +#else return currentEntry; +#endif } QFileInfo QFSFileEngineIterator::currentFileInfo() const { +#ifdef Q_OS_UNIX + return currentInfo; +#else return QAbstractFileEngineIterator::currentFileInfo(); +#endif } QT_END_NAMESPACE diff --git a/src/corelib/io/qfsfileengine_iterator_p.h b/src/corelib/io/qfsfileengine_iterator_p.h index be670e0..7940fbd 100644 --- a/src/corelib/io/qfsfileengine_iterator_p.h +++ b/src/corelib/io/qfsfileengine_iterator_p.h @@ -54,6 +54,7 @@ // #include "qabstractfileengine.h" +#include "qfilesystemiterator_p.h" #include "qdir.h" #ifndef QT_NO_FSFILEENGINE @@ -76,6 +77,13 @@ public: QFileInfo currentFileInfo() const; private: +#ifdef Q_OS_UNIX + void advance() const; + mutable QScopedPointer nativeIterator; + mutable QFileInfo currentInfo; + mutable QFileInfo nextInfo; + mutable bool done; +#else QFSFileEngineIteratorPlatformSpecificData *platform; friend class QFSFileEngineIteratorPlatformSpecificData; void newPlatformSpecifics(); @@ -83,6 +91,7 @@ private: void advance(); QString currentEntry; +#endif }; QT_END_NAMESPACE diff --git a/src/corelib/io/qfsfileengine_iterator_unix.cpp b/src/corelib/io/qfsfileengine_iterator_unix.cpp deleted file mode 100644 index bfdb03e..0000000 --- a/src/corelib/io/qfsfileengine_iterator_unix.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qplatformdefs.h" -#include "qfsfileengine_iterator_p.h" - -#include - -#ifndef QT_NO_FSFILEENGINE - -QT_BEGIN_NAMESPACE - -class QFSFileEngineIteratorPlatformSpecificData -{ -public: - inline QFSFileEngineIteratorPlatformSpecificData() - : dir(0), dirEntry(0), done(false) -#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) - , mt_file(0) -#endif - {} - - QT_DIR *dir; - QT_DIRENT *dirEntry; - bool done; - -#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) - // for readdir_r - QT_DIRENT *mt_file; -#endif -}; - -void QFSFileEngineIterator::advance() -{ - currentEntry = platform->dirEntry ? QFile::decodeName(QByteArray(platform->dirEntry->d_name)) : QString(); - - if (!platform->dir) - return; - -#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) - if (QT_READDIR_R(platform->dir, platform->mt_file, &platform->dirEntry) != 0) - platform->done = true; -#else - // ### add local lock to prevent breaking reentrancy - platform->dirEntry = QT_READDIR(platform->dir); -#endif // _POSIX_THREAD_SAFE_FUNCTIONS - if (!platform->dirEntry) { - QT_CLOSEDIR(platform->dir); - platform->dir = 0; - platform->done = true; -#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) - delete [] platform->mt_file; - platform->mt_file = 0; -#endif - } -} - -void QFSFileEngineIterator::newPlatformSpecifics() -{ - platform = new QFSFileEngineIteratorPlatformSpecificData; -} - -void QFSFileEngineIterator::deletePlatformSpecifics() -{ - if (platform->dir) { - QT_CLOSEDIR(platform->dir); -#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) - delete [] platform->mt_file; - platform->mt_file = 0; -#endif - } - delete platform; - platform = 0; -} - -bool QFSFileEngineIterator::hasNext() const -{ - if (!platform->done && !platform->dir) { - QFSFileEngineIterator *that = const_cast(this); - if ((that->platform->dir = QT_OPENDIR(QFile::encodeName(path()).data())) == 0) { - that->platform->done = true; - } else { - // ### Race condition; we should use fpathconf and dirfd(). - long maxPathName = ::pathconf(QFile::encodeName(path()).data(), _PC_NAME_MAX); - if ((int) maxPathName == -1) - maxPathName = FILENAME_MAX; - maxPathName += sizeof(QT_DIRENT) + 1; -#if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_CYGWIN) && !defined(Q_OS_SYMBIAN) - if (that->platform->mt_file) - delete [] that->platform->mt_file; - that->platform->mt_file = (QT_DIRENT *)new char[maxPathName]; -#endif - - that->advance(); - } - } - return !platform->done; -} - -QT_END_NAMESPACE - -#endif // QT_NO_FSFILEENGINE diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 016fdc0..81b785a 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -87,8 +87,7 @@ SOURCES += \ unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \ ../../corelib/io/qfilesystemiterator_unix.cpp \ - ../../corelib/io/qfsfileengine_unix.cpp \ - ../../corelib/io/qfsfileengine_iterator_unix.cpp + ../../corelib/io/qfsfileengine_unix.cpp win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ ../../corelib/io/qfilesystemiterator_win.cpp \ -- cgit v0.12 From a12e4996b8316badd7784b204ea8f22b7986f032 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 13 Sep 2010 12:04:57 +0100 Subject: Fix Symbian's root path Change the root path to return the root of the system drive, e.g. "c:/" instead of the PhoneMemoryRootPath() "c:/data/". The PhoneMemoryRootPath() matched Qt's concept of the home path, and will continue to be returned for that function. Reviewed-By: Thomas Zander --- src/corelib/io/qfsfileengine_unix.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index c6e7300..a6cf7fc 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -744,7 +744,7 @@ QString QFSFileEngine::currentPath(const QString &) QString QFSFileEngine::homePath() { #if defined(Q_OS_SYMBIAN) - QString home = rootPath(); + QString home = QDir::cleanPath(QDir::fromNativeSeparators(qt_TDesC2QString(PathInfo::PhoneMemoryRootPath()))); #else QString home = QFile::decodeName(qgetenv("HOME")); if (home.isNull()) @@ -756,8 +756,10 @@ QString QFSFileEngine::homePath() QString QFSFileEngine::rootPath() { #if defined(Q_OS_SYMBIAN) - TFileName symbianPath = PathInfo::PhoneMemoryRootPath(); - return QDir::cleanPath(QDir::fromNativeSeparators(qt_TDesC2QString(symbianPath))); + TChar drive; + TInt err = RFs::DriveToChar(RFs::GetSystemDrive(), drive); //RFs::GetSystemDriveChar not supported on S60 3.1 + Q_ASSERT(err == KErrNone); //RFs::GetSystemDrive() shall always return a convertible drive number on a valid OS configuration + return QString(QChar(drive)).append(QLatin1String(":/")); #else return QLatin1String("/"); #endif -- cgit v0.12 From 7f5417353bd71a63e962851ba598f1e2631f4a25 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 13 Sep 2010 14:57:08 +0100 Subject: Fix setPermissions in symbian In error, it was checking the read permissions to set the read-only file attribute, when it should have been checking the write permissions. read-only = !writable. Reviewed-By: Thomas Zander --- src/corelib/io/qfilesystemengine_symbian.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 1ed4ee8..6bad860 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -290,7 +290,7 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) QString targetpath = absoluteName(entry).nativeFilePath(); RFs& fs(qt_s60GetRFs()); TInt err = fs.Delete(qt_QString2TPtrC(targetpath)); - return false; // TODO error reporting; + return err == KErrNone; // TODO error reporting; } //static @@ -300,8 +300,8 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per TUint setmask = 0; TUint clearmask = 0; RFs& fs(qt_s60GetRFs()); - if (permissions & (QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther)) - clearmask = KEntryAttReadOnly; + if (permissions & (QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther)) + clearmask = KEntryAttReadOnly; //if anyone can write, it's not read-only else setmask = KEntryAttReadOnly; TInt err = fs.SetAtt(qt_QString2TPtrC(targetpath), setmask, clearmask); @@ -310,7 +310,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions)); data->knownFlagsMask |= QFileSystemMetaData::Permissions; } - return err != KErrNone; // TODO error reporting + return err == KErrNone; // TODO error reporting } QT_END_NAMESPACE -- cgit v0.12 From 9bdc685da9d1e1aac165711197e3b7b887e19da3 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 13 Sep 2010 15:34:27 +0100 Subject: Integrate symbian file system iterator Store the relative path in nativeFilePath and prepend it to results, this behaviour was previously provided by the base class. Some refactoring to avoid needing to allocate a TFileName on the stack, and to set the known metadata flags inside the fillFromXXX functions. Reviewed-By: Thomas Zander Reviewed-By: mread --- src/corelib/io/qfilesystemengine_symbian.cpp | 6 +++-- src/corelib/io/qfilesystemiterator_symbian.cpp | 33 +++++++++++--------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 6bad860..c339dc4 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -144,6 +144,8 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) void QFileSystemMetaData::fillFromTEntry(const TEntry& entry) { + entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); + knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags; //Symbian doesn't have unix type file permissions entryFlags |= QFileSystemMetaData::Permissions; if(entry.IsReadOnly()) { @@ -171,6 +173,8 @@ void QFileSystemMetaData::fillFromTEntry(const TEntry& entry) void QFileSystemMetaData::fillFromVolumeInfo(const TVolumeInfo& info) { + entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); + knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags; entryFlags |= QFileSystemMetaData::ExistsAttribute; entryFlags |= QFileSystemMetaData::Permissions; if(info.iDrive.iDriveAtt & KDriveAttRom) { @@ -187,7 +191,6 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (what & QFileSystemMetaData::SymbianTEntryFlags) { RFs& fs(qt_s60GetRFs()); TInt err; - data.entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); QFileSystemEntry absentry(absoluteName(entry)); if (absentry.isRoot()) { //Root directories don't have an entry, and Entry() returns KErrBadName. @@ -210,7 +213,6 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM data.size_ = 0; data.modificationTime_ = TTime(0); } - data.knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags; } return data.hasFlags(what); } diff --git a/src/corelib/io/qfilesystemiterator_symbian.cpp b/src/corelib/io/qfilesystemiterator_symbian.cpp index 106eda9..e316526 100644 --- a/src/corelib/io/qfilesystemiterator_symbian.cpp +++ b/src/corelib/io/qfilesystemiterator_symbian.cpp @@ -51,26 +51,28 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &path, QDir::Fil { RFs& fs = qt_s60GetRFs(); - TFileName symbianPath; - QString abspath = QFileSystemEngine::absoluteName(path).nativeFilePath(); + nativePath = path.nativeFilePath(); + if (!nativePath.endsWith(QLatin1Char('\\'))) + nativePath.append(QLatin1Char('\\')); - if (!abspath.endsWith(QLatin1Char('\\'))) - abspath.append(QLatin1Char('\\')); + QString absPath = QFileSystemEngine::absoluteName(path).nativeFilePath(); - int pathLen = abspath.length(); - if (pathLen > symbianPath.MaxLength()) { + if (!absPath.endsWith(QLatin1Char('\\'))) + absPath.append(QLatin1Char('\\')); + + int pathLen = absPath.length(); + if (pathLen > KMaxFileName) { lastError = KErrBadName; return; } - symbianPath.Copy(qt_QString2TPtrC(abspath)); //set up server side filtering to reduce IPCs //RDir won't accept all valid name filters e.g. "*. bar" if (nameFilters.count() == 1 && !(filters & QDir::AllDirs) && iteratorFlags == QDirIterator::NoIteratorFlags && pathLen + nameFilters[0].length() - <= symbianPath.MaxLength()) { + <= KMaxFileName) { //server side supports one mask - skip this for recursive mode or if only files should be filtered - symbianPath.Append(qt_QString2TPtrC(nameFilters[0])); + absPath.append(nameFilters[0]); } TUint symbianMask = 0; @@ -90,7 +92,7 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &path, QDir::Fil symbianMask = KEntryAttMatchExclusive | KEntryAttReadOnly; } - lastError = dirHandle.Open(fs, symbianPath, symbianMask); + lastError = dirHandle.Open(fs, qt_QString2TPtrC(absPath), symbianMask); } QFileSystemIterator::~QFileSystemIterator() @@ -98,13 +100,6 @@ QFileSystemIterator::~QFileSystemIterator() dirHandle.Close(); } -static void createFileSystemMetaDataHelper(const TEntry &entry, QFileSystemMetaData &metaData) -{ - //placeholder - //TODO: adapt from QFileInfoPrivate::fromTEntry(entries[entryIndex], path()); - //or add this functionality to QFileSystemMetaData -} - bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) { //1st time, lastError is result of dirHandle.Open(), entries.Count() is 0 and entryIndex is -1 so initial read is triggered @@ -121,8 +116,8 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa if ((lastError == KErrNone || lastError == KErrEof) && entryIndex < entries.Count()) { Q_ASSERT(entryIndex >= 0); const TEntry &entry(entries[entryIndex]); - fileEntry = QFileSystemEntry(qt_TDesC2QString(entry.iName), QFileSystemEntry::FromNativePath()); - createFileSystemMetaDataHelper(entry, metaData); + fileEntry = QFileSystemEntry(nativePath + qt_TDesC2QString(entry.iName), QFileSystemEntry::FromNativePath()); + metaData.fillFromTEntry(entry); return true; } -- cgit v0.12 From 71d1d710d5e25be4b74af10a8dfcc3c53bd42ef1 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 13 Sep 2010 16:27:32 +0100 Subject: Fixes for canonicalPath and exists on symbian QDir::cleanPath does not do what we need for some types of path, for example c:/../. However, changing the cleanPath() function isn't easy because so many places rely on the current behaviour. RFs::Att() doesn't work for root directories, so instead to check whether a file exists, we now use the normal fillMetaData() function. Also fixed some compiler warnings in the file. Reviewed-By: mread --- src/corelib/io/qfilesystemengine_symbian.cpp | 61 +++++++++++++++++++--------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index c339dc4..dc7fcbf 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -52,6 +52,36 @@ bool QFileSystemEngine::isCaseSensitive() return false; } +//TODO: resolve this with QDir::cleanPath, without breaking the behaviour of that +//function which is documented only by autotest +//input: a dirty absolute path, e.g. c:/../../foo/./ +//output: a clean absolute path, e.g. c:/foo/ +static QString symbianCleanAbsolutePath(const QString& path) +{ + bool isDir = path.endsWith(QLatin1Char('/')); + //using SkipEmptyParts flag to eliminate duplicated slashes + QStringList components = path.split(QLatin1Char('/'), QString::SkipEmptyParts); + int cdups = 0; + for(int i=components.count() - 1; i>=0; --i) { + if(components.at(i) == QLatin1String("..")) { + components.removeAt(i); + cdups++; + } + else if(components.at(i) == QLatin1String(".")) { + components.removeAt(i); + } + else if(cdups && i > 0) { + --cdups; + components.removeAt(i); + } + } + QString result = components.join(QLatin1String("/")); + if ((isDir&& !result.endsWith(QLatin1Char('/'))) + || (result.length() == 2 && result.at(1).unicode() == ':')) + result.append(QLatin1Char('/')); + return result; +} + //static QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data) { @@ -65,15 +95,12 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) return entry; QFileSystemEntry result = absoluteName(entry); - RFs& fs(qt_s60GetRFs()); - TUint e; - //Att is faster than Entry for determining if a file exists, due to smaller IPC - TInt r = fs.Att(qt_QString2TPtrC(result.nativeFilePath()), e); - - if (r == KErrNone) { - return result; - } else { // file doesn't exist + QFileSystemMetaData meta; + if (!fillMetaData(result, meta, QFileSystemMetaData::ExistsAttribute) || !meta.exists()) { + // file doesn't exist return QFileSystemEntry(); + } else { + return result; } } @@ -109,30 +136,26 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) } } if (!orig.isEmpty() && !(orig.length() == 1 && orig.at(0).unicode() == '.')) { - if (!result.isEmpty() && !result.endsWith('/')) - result.append('/'); + if (!result.isEmpty() && !result.endsWith(QLatin1Char('/'))) + result.append(QLatin1Char('/')); result.append(orig); } - const bool isDir = result.endsWith('/'); - const bool isRoot = entry.isRoot(); - - result = QDir::cleanPath(result); - if (isDir && !isRoot) - result.append(QLatin1Char('/')); - return QFileSystemEntry(result); + return symbianCleanAbsolutePath(result); } //static QString QFileSystemEngine::resolveUserName(uint userId) { - return QString(); // TODO + Q_UNUSED(userId) + return QString(); // no users or groups on symbian } //static QString QFileSystemEngine::resolveGroupName(uint groupId) { - return QString(); // TODO + Q_UNUSED(groupId) + return QString(); // no users or groups on symbian } //static -- cgit v0.12 From c76b30f79c08499c2d9d4329c72639f80ff872b2 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 9 Sep 2010 15:49:26 +0200 Subject: QFileSystemEngine: Fix stupid bug-o in engine creation Reviewed-by: Joao --- src/corelib/io/qfilesystemengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 4791dfc..9bfd382 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -133,7 +133,7 @@ static inline bool _q_checkEntry(QFileSystemEntry &entry, QFileSystemMetaData &d static inline bool _q_checkEntry(QAbstractFileEngine *&engine, bool resolvingEntry) { if (resolvingEntry) { - if (!engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag) { + if (!(engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) { delete engine; engine = 0; return false; -- cgit v0.12 From 59ad6b33ac73b5981c9b3a9ba87374d33fb17228 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Sat, 11 Sep 2010 00:13:12 +0200 Subject: Make QFSFileEngine & QFileInfo use the new filesystemengine on Windows QFSFileEngine now uses the QFileSystemEngine static functions to implement most of the file system related quries. All the Win32 specific code is now moved from the QFSFileEngine to QFileSystemEngine. This implements all the fillMetaData and filename query functions. These new functions behave exactly like their previous implementations in QFSFileEngine. Following optimizations are done with this. * GetFileAttributesEx() instead of GetFileAttibutes(). * GetFileInformationByHandle() instead of POSIX functions. Reviewed-by: Joao --- src/corelib/io/qfilesystemengine_p.h | 23 +- src/corelib/io/qfilesystemengine_win.cpp | 1074 ++++++++++++++++++++++++- src/corelib/io/qfilesystemmetadata_p.h | 55 +- src/corelib/io/qfsfileengine_iterator_win.cpp | 3 +- src/corelib/io/qfsfileengine_p.h | 10 +- src/corelib/io/qfsfileengine_win.cpp | 1048 ++---------------------- 6 files changed, 1211 insertions(+), 1002 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 94a8175..1068e76 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -75,10 +75,24 @@ public: static QString bundleName(const QFileSystemEntry &entry); static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, - QFileSystemMetaData::MetaDataFlags what); + QFileSystemMetaData::MetaDataFlags what); #if defined(Q_OS_UNIX) static bool fillMetaData(int fd, QFileSystemMetaData &data); // what = PosixStatFlags #endif +#if defined(Q_OS_WIN) + + static bool uncListSharesOnServer(const QString &server, QStringList *list); //Used also by QFSFileEngineIterator::hasNext() + static bool fillMetaData(int fd, QFileSystemMetaData &data, + QFileSystemMetaData::MetaDataFlags what); + static bool fillMetaData(HANDLE fHandle, QFileSystemMetaData &data, + QFileSystemMetaData::MetaDataFlags what); + static bool fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data, + QFileSystemMetaData::MetaDataFlags what); + static QString homePath(); + static QString rootPath(); + static QString owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own); + static QString nativeAbsoluteFilePath(const QString &path); +#endif static bool createDirectory(const QFileSystemEntry &entry, bool createParents); static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents); @@ -90,12 +104,15 @@ public: static bool removeFile(const QFileSystemEntry &entry); static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, - QFileSystemMetaData *data = 0); + QFileSystemMetaData *data = 0); static QAbstractFileEngine *resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry, - QFileSystemMetaData &data); + QFileSystemMetaData &data); private: static QString slowCanonicalized(const QString &path); +#if defined(Q_OS_WIN) + static void clearWinStatData(QFileSystemMetaData &data); +#endif }; QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 28d5db4..550b522 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -41,29 +41,531 @@ #include "qfilesystemengine_p.h" +#define _POSIX_ +#include "qplatformdefs.h" +#include "qabstractfileengine.h" +#include "private/qfsfileengine_p.h" +#include "qfilesystemengine_p.h" +#include + +#include "qfile.h" +#include "qdir.h" +#include "private/qmutexpool_p.h" +#include "qvarlengtharray.h" +#include "qdatetime.h" +#include "qt_windows.h" + +#if !defined(Q_OS_WINCE) +# include +# include +# include +#else +# include +#endif +#include +#include +#include +#include +#include +#include +#define SECURITY_WIN32 +#include + +#ifndef _INTPTR_T_DEFINED +#ifdef _WIN64 +typedef __int64 intptr_t; +#else +#ifdef _W64 +typedef _W64 int intptr_t; +#else +typedef INT_PTR intptr_t; +#endif +#endif +#define _INTPTR_T_DEFINED +#endif + +#ifndef INVALID_FILE_ATTRIBUTES +# define INVALID_FILE_ATTRIBUTES (DWORD (-1)) +#endif + +#if !defined(Q_OS_WINCE) +# if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE) +typedef struct _REPARSE_DATA_BUFFER { + ULONG ReparseTag; + USHORT ReparseDataLength; + USHORT Reserved; + union { + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + ULONG Flags; + WCHAR PathBuffer[1]; + } SymbolicLinkReparseBuffer; + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + WCHAR PathBuffer[1]; + } MountPointReparseBuffer; + struct { + UCHAR DataBuffer[1]; + } GenericReparseBuffer; + }; +} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; +# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer) +# endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE) + +# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE +# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384 +# endif +# ifndef IO_REPARSE_TAG_SYMLINK +# define IO_REPARSE_TAG_SYMLINK (0xA000000CL) +# endif +# ifndef FSCTL_GET_REPARSE_POINT +# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) +# endif +#endif // !defined(Q_OS_WINCE) + QT_BEGIN_NAMESPACE +Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0; + +#if defined(Q_OS_WINCE) +static QString qfsPrivateCurrentDir = QLatin1String(""); +// As none of the functions we try to resolve do exist on Windows CE +// we use QT_NO_LIBRARY to shorten everything up a little bit. +#define QT_NO_LIBRARY 1 +#endif + +#if !defined(QT_NO_LIBRARY) +QT_BEGIN_INCLUDE_NAMESPACE +typedef DWORD (WINAPI *PtrGetNamedSecurityInfoW)(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*); +static PtrGetNamedSecurityInfoW ptrGetNamedSecurityInfoW = 0; +typedef BOOL (WINAPI *PtrLookupAccountSidW)(LPCWSTR, PSID, LPWSTR, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE); +static PtrLookupAccountSidW ptrLookupAccountSidW = 0; +typedef VOID (WINAPI *PtrBuildTrusteeWithSidW)(PTRUSTEE_W, PSID); +static PtrBuildTrusteeWithSidW ptrBuildTrusteeWithSidW = 0; +typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACCESS_MASK); +static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0; +static TRUSTEE_W currentUserTrusteeW; +static TRUSTEE_W worldTrusteeW; + +typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD); +static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0; +typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD); +static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0; +QT_END_INCLUDE_NAMESPACE + + +static void resolveLibs() +{ + static bool triedResolve = false; + if (!triedResolve) { + // need to resolve the security info functions + + // protect initialization +#ifndef QT_NO_THREAD + QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); + // check triedResolve again, since another thread may have already + // done the initialization + if (triedResolve) { + // another thread did initialize the security function pointers, + // so we shouldn't do it again. + return; + } +#endif + + triedResolve = true; +#if !defined(Q_OS_WINCE) + HINSTANCE advapiHnd = LoadLibrary(L"advapi32"); + if (advapiHnd) { + ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW"); + ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); + ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW"); + ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW"); + } + if (ptrBuildTrusteeWithSidW) { + // Create TRUSTEE for current user + HANDLE hnd = ::GetCurrentProcess(); + HANDLE token = 0; + if (::OpenProcessToken(hnd, TOKEN_QUERY, &token)) { + TOKEN_USER tu; + DWORD retsize; + if (::GetTokenInformation(token, TokenUser, &tu, sizeof(tu), &retsize)) + ptrBuildTrusteeWithSidW(¤tUserTrusteeW, tu.User.Sid); + ::CloseHandle(token); + } + + typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*); + PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); + typedef PVOID (WINAPI *PtrFreeSid)(PSID); + PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); + if (ptrAllocateAndInitializeSid && ptrFreeSid) { + // Create TRUSTEE for Everyone (World) + SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY }; + PSID pWorld = 0; + if (ptrAllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pWorld)) + ptrBuildTrusteeWithSidW(&worldTrusteeW, pWorld); + ptrFreeSid(pWorld); + } + } + HINSTANCE userenvHnd = LoadLibrary(L"userenv"); + if (userenvHnd) + ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); + HINSTANCE kernel32 = LoadLibrary(L"kernel32"); + if(kernel32) + ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW"); +#endif + } +} +#endif // QT_NO_LIBRARY + +typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD); +static PtrNetShareEnum ptrNetShareEnum = 0; +typedef DWORD (WINAPI *PtrNetApiBufferFree)(LPVOID); +static PtrNetApiBufferFree ptrNetApiBufferFree = 0; +typedef struct _SHARE_INFO_1 { + LPWSTR shi1_netname; + DWORD shi1_type; + LPWSTR shi1_remark; +} SHARE_INFO_1; + + +static bool resolveUNCLibs() +{ + static bool triedResolve = false; + if (!triedResolve) { +#ifndef QT_NO_THREAD + QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); + if (triedResolve) { + return ptrNetShareEnum && ptrNetApiBufferFree; + } +#endif + triedResolve = true; +#if !defined(Q_OS_WINCE) + HINSTANCE hLib = LoadLibrary(L"netapi32"); + if (hLib) { + ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum"); + if (ptrNetShareEnum) + ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree"); + } +#endif + } + return ptrNetShareEnum && ptrNetApiBufferFree; +} + +static QString readSymLink(const QFileSystemEntry &link) +{ + QString result; +#if !defined(Q_OS_WINCE) + HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(), + FILE_READ_EA, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + 0, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, + 0); + if (handle != INVALID_HANDLE_VALUE) { + DWORD bufsize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE; + REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize); + DWORD retsize = 0; + if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) { + if (rdb->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { + int length = rdb->MountPointReparseBuffer.SubstituteNameLength / sizeof(wchar_t); + int offset = rdb->MountPointReparseBuffer.SubstituteNameOffset / sizeof(wchar_t); + const wchar_t* PathBuffer = &rdb->MountPointReparseBuffer.PathBuffer[offset]; + result = QString::fromWCharArray(PathBuffer, length); + } else if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) { + int length = rdb->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t); + int offset = rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t); + const wchar_t* PathBuffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[offset]; + result = QString::fromWCharArray(PathBuffer, length); + } + // cut-off "//?/" and "/??/" + if (result.size() > 4 && result.at(0) == QLatin1Char('\\') && result.at(2) == QLatin1Char('?') && result.at(3) == QLatin1Char('\\')) + result = result.mid(4); + } + qFree(rdb); + CloseHandle(handle); + +#if !defined(QT_NO_LIBRARY) + resolveLibs(); + if (ptrGetVolumePathNamesForVolumeNameW) { + QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive); + if(matchVolName.indexIn(result) == 0) { + DWORD len; + wchar_t buffer[MAX_PATH]; + QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\")); + if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0) + result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); + } + } +#endif + } +#else + Q_UNUSED(link); +#endif // Q_OS_WINCE + return result; +} + +static QString readLink(const QFileSystemEntry &link) +{ +#if !defined(Q_OS_WINCE) +#if !defined(QT_NO_LIBRARY) && !defined(Q_CC_MWERKS) + QString ret; + + bool neededCoInit = false; + IShellLink *psl; // pointer to IShellLink i/f + WIN32_FIND_DATA wfd; + wchar_t szGotPath[MAX_PATH]; + + // Get pointer to the IShellLink interface. + HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl); + + if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized + neededCoInit = true; + CoInitialize(NULL); + hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, + IID_IShellLink, (LPVOID *)&psl); + } + if (SUCCEEDED(hres)) { // Get pointer to the IPersistFile interface. + IPersistFile *ppf; + hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf); + if (SUCCEEDED(hres)) { + hres = ppf->Load((LPOLESTR)link.nativeFilePath().utf16(), STGM_READ); + //The original path of the link is retrieved. If the file/folder + //was moved, the return value still have the old path. + if (SUCCEEDED(hres)) { + if (psl->GetPath(szGotPath, MAX_PATH, &wfd, SLGP_UNCPRIORITY) == NOERROR) + ret = QString::fromWCharArray(szGotPath); + } + ppf->Release(); + } + psl->Release(); + } + if (neededCoInit) + CoUninitialize(); + + return ret; +#else + Q_UNUSED(link); + return QString(); +#endif // QT_NO_LIBRARY +#else + wchar_t target[MAX_PATH]; + QString result; + if (SHGetShortcutTarget((wchar_t*)QFileInfo(link.filePath()).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) { + result = QString::fromWCharArray(target); + if (result.startsWith(QLatin1Char('"'))) + result.remove(0,1); + if (result.endsWith(QLatin1Char('"'))) + result.remove(result.size()-1,1); + } + return result; +#endif // Q_OS_WINCE +} + +static bool uncShareExists(const QString &server) +{ + // This code asumes the UNC path is always like \\?\UNC\server... + QStringList parts = server.split(QLatin1Char('\\'), QString::SkipEmptyParts); + if (parts.count() >= 3) { + QStringList shares; + if (QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(2), &shares)) + return parts.count() >= 4 ? shares.contains(parts.at(3), Qt::CaseInsensitive) : true; + } + return false; +} + +static inline bool getFindData(QString path, WIN32_FIND_DATA &findData) +{ + // path should not end with a trailing slash + while (path.endsWith(QLatin1Char('\\'))) + path.chop(1); + + // can't handle drives + if (!path.endsWith(QLatin1Char(':'))) { + HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData); + if (hFind != INVALID_HANDLE_VALUE) { + ::FindClose(hFind); + return true; + } + } + + return false; +} + +bool QFileSystemEngine::uncListSharesOnServer(const QString &server, QStringList *list) +{ + if (resolveUNCLibs()) { + SHARE_INFO_1 *BufPtr, *p; + DWORD res; + DWORD er = 0, tr = 0, resume = 0, i; + do { + res = ptrNetShareEnum((wchar_t*)server.utf16(), 1, (LPBYTE *)&BufPtr, DWORD(-1), &er, &tr, &resume); + if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA) { + p = BufPtr; + for (i = 1; i <= er; ++i) { + if (list && p->shi1_type == 0) + list->append(QString::fromWCharArray(p->shi1_netname)); + p++; + } + } + ptrNetApiBufferFree(BufPtr); + } while (res == ERROR_MORE_DATA); + return res == ERROR_SUCCESS; + } + return false; +} + +void QFileSystemMetaData::fillFromFileAttribute(DWORD fileAttribute,bool isDriveRoot) +{ + fileAttribute_ = fileAttribute; + // Ignore the hidden attribute for drives. + if (!isDriveRoot && (fileAttribute_ & FILE_ATTRIBUTE_HIDDEN)) + entryFlags |= HiddenAttribute; + entryFlags |= ((fileAttribute & FILE_ATTRIBUTE_DIRECTORY) ? DirectoryType: FileType); + entryFlags |= ExistsAttribute; + knownFlagsMask |= FileType | DirectoryType | HiddenAttribute | ExistsAttribute; +} + +void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType, bool isDriveRoot) +{ + fillFromFileAttribute(findData.dwFileAttributes, isDriveRoot); + creationTime_ = findData.ftCreationTime; + lastAccessTime_ = findData.ftLastAccessTime; + lastWriteTime_ = findData.ftLastWriteTime; + size_ = findData.nFileSizeHigh; + size_ <<= 32; + size_ += findData.nFileSizeLow; + knownFlagsMask |= Times | SizeAttribute; + if (setLinkType) { + knownFlagsMask |= LinkType; + entryFlags &= ~LinkType; + if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) + && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK + || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { + entryFlags |= LinkType; + } + + } +} + +void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo) +{ + fillFromFileAttribute(fileInfo.dwFileAttributes); + creationTime_ = fileInfo.ftCreationTime; + lastAccessTime_ = fileInfo.ftLastAccessTime; + lastWriteTime_ = fileInfo.ftLastWriteTime; + size_ = fileInfo.nFileSizeHigh; + size_ <<= 32; + size_ += fileInfo.nFileSizeLow; + knownFlagsMask |= Times | SizeAttribute; +} + +void QFileSystemEngine::clearWinStatData(QFileSystemMetaData &data) +{ + data.size_ = -1; + data.fileAttribute_ = 0; +} + bool QFileSystemEngine::isCaseSensitive() { return false; } //static -QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data) +QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, + QFileSystemMetaData &data) { - return link; // TODO implement + if (data.missingFlags(QFileSystemMetaData::LinkType)) + QFileSystemEngine::fillMetaData(link, data, QFileSystemMetaData::LinkType); + + QString ret; + if (data.isLnkFile()) + ret = readLink(link); + else if (data.isLink()) + ret = readSymLink(link); + return QFileSystemEntry(QDir::fromNativeSeparators(ret)); } //static QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) { - return QFileSystemEntry(slowCanonicalized(entry.filePath())); + // The caller has to verify whether the file exists or not. + return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); +} + +//static +QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) +{ + // can be //server or //server/share + QString absPath; +#if !defined(Q_OS_WINCE) + QVarLengthArray buf(qMax(MAX_PATH, path.size() + 1)); + wchar_t *fileName = 0; + DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); + if (retLen > (DWORD)buf.size()) { + buf.resize(retLen); + retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); + } + if (retLen != 0) + absPath = QString::fromWCharArray(buf.data(), retLen); +#else + if (path.startsWith(QLatin1Char('/')) || path.startsWith(QLatin1Char('\\'))) + absPath = QDir::toNativeSeparators(path); + else + absPath = QDir::toNativeSeparators(QDir::cleanPath(qfsPrivateCurrentDir + QLatin1Char('/') + path)); +#endif + // This is really ugly, but GetFullPathName strips off whitespace at the end. + // If you for instance write ". " in the lineedit of QFileDialog, + // (which is an invalid filename) this function will strip the space off and viola, + // the file is later reported as existing. Therefore, we re-add the whitespace that + // was at the end of path in order to keep the filename invalid. + if (!path.isEmpty() && path.at(path.size() - 1) == QLatin1Char(' ')) + absPath.append(QLatin1Char(' ')); + return absPath; } //static QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) { - return entry; // TODO implement; + QString ret; + + if (!entry.isRelative()) { +#if !defined(Q_OS_WINCE) + if (entry.filePath().startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt + entry.filePath().size() == 2 || // It's a drive letter that needs to get a working dir appended + (entry.filePath().size() > 2 && entry.filePath().at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt + entry.filePath().contains(QLatin1String("/../")) || entry.filePath().contains(QLatin1String("/./")) || + entry.filePath().endsWith(QLatin1String("/..")) || entry.filePath().endsWith(QLatin1String("/."))) + { + ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath())); + } else +#endif + { + ret = entry.filePath(); + } + } else { + ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath()); + } + + // The path should be absolute at this point. + // From the docs : + // Absolute paths begin with the directory separator "/" + // (optionally preceded by a drive specification under Windows). + if (ret.at(0) != QLatin1Char('/')) { + Q_ASSERT(ret.length() >= 2); + Q_ASSERT(ret.at(0).isLetter()); + Q_ASSERT(ret.at(1) == QLatin1Char(':')); + + // Force uppercase drive letters. + ret[0] = ret.at(0).toUpper(); + } + return QFileSystemEntry(ret); } //static @@ -81,25 +583,506 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) //static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { + Q_UNUSED(entry); return QString(); } //static -bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) +QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own) { - return false; // TODO implement; + QString name; +#if !defined(QT_NO_LIBRARY) + extern int qt_ntfs_permission_lookup; + if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { + resolveLibs(); + if (ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) { + PSID pOwner = 0; + PSECURITY_DESCRIPTOR pSD; + if (ptrGetNamedSecurityInfoW((wchar_t*)entry.nativeFilePath().utf16(), SE_FILE_OBJECT, + own == QAbstractFileEngine::OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, + own == QAbstractFileEngine::OwnerUser ? &pOwner : 0, own == QAbstractFileEngine::OwnerGroup ? &pOwner : 0, + 0, 0, &pSD) == ERROR_SUCCESS) { + DWORD lowner = 64; + DWORD ldomain = 64; + QVarLengthArray owner(lowner); + QVarLengthArray domain(ldomain); + SID_NAME_USE use = SidTypeUnknown; + // First call, to determine size of the strings (with '\0'). + if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner, + (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + if (lowner > (DWORD)owner.size()) + owner.resize(lowner); + if (ldomain > (DWORD)domain.size()) + domain.resize(ldomain); + // Second call, try on resized buf-s + if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner, + (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) { + lowner = 0; + } + } else { + lowner = 0; + } + } + if (lowner != 0) + name = QString::fromWCharArray(owner.data()); + LocalFree(pSD); + } + } + } +#else + Q_UNUSED(own); +#endif + return name; +} + +//static +bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data, + QFileSystemMetaData::MetaDataFlags what) +{ + QAbstractFileEngine::FileFlags ret = 0; + +#if !defined(QT_NO_LIBRARY) + if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { + resolveLibs(); + if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) { + enum { ReadMask = 0x00000001, WriteMask = 0x00000002, ExecMask = 0x00000020 }; + + QString fname = entry.filePath(); + PSID pOwner = 0; + PSID pGroup = 0; + PACL pDacl; + PSECURITY_DESCRIPTOR pSD; + DWORD res = ptrGetNamedSecurityInfoW((wchar_t*)fname.utf16(), SE_FILE_OBJECT, + OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, + &pOwner, &pGroup, &pDacl, 0, &pSD); + if(res == ERROR_SUCCESS) { + ACCESS_MASK access_mask; + TRUSTEE_W trustee; + if (what & QFileSystemMetaData::UserPermissions) { // user + data.knownFlagsMask |= QFileSystemMetaData::UserPermissions; + if(ptrGetEffectiveRightsFromAclW(pDacl, ¤tUserTrusteeW, &access_mask) != ERROR_SUCCESS) + access_mask = (ACCESS_MASK)-1; + if(access_mask & ReadMask) + data.entryFlags |= QFileSystemMetaData::UserReadPermission; + if(access_mask & WriteMask) + data.entryFlags|= QFileSystemMetaData::UserWritePermission; + if(access_mask & ExecMask) + data.entryFlags|= QFileSystemMetaData::UserExecutePermission; + } + if (what & QFileSystemMetaData::OwnerPermissions) { // owner + data.knownFlagsMask |= QFileSystemMetaData::OwnerPermissions; + ptrBuildTrusteeWithSidW(&trustee, pOwner); + if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS) + access_mask = (ACCESS_MASK)-1; + if(access_mask & ReadMask) + data.entryFlags |= QFileSystemMetaData::OwnerReadPermission; + if(access_mask & WriteMask) + data.entryFlags |= QFileSystemMetaData::OwnerWritePermission; + if(access_mask & ExecMask) + data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission; + } + if (what & QFileSystemMetaData::GroupPermissions) { // group + data.knownFlagsMask |= QFileSystemMetaData::GroupPermissions; + ptrBuildTrusteeWithSidW(&trustee, pGroup); + if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS) + access_mask = (ACCESS_MASK)-1; + if(access_mask & ReadMask) + data.entryFlags |= QFileSystemMetaData::GroupReadPermission; + if(access_mask & WriteMask) + data.entryFlags |= QFileSystemMetaData::GroupWritePermission; + if(access_mask & ExecMask) + data.entryFlags |= QFileSystemMetaData::GroupExecutePermission; + } + if (what & QFileSystemMetaData::OtherPermissions) { // other (world) + data.knownFlagsMask |= QFileSystemMetaData::OtherPermissions; + if(ptrGetEffectiveRightsFromAclW(pDacl, &worldTrusteeW, &access_mask) != ERROR_SUCCESS) + access_mask = (ACCESS_MASK)-1; // ### + if(access_mask & ReadMask) + data.entryFlags |= QFileSystemMetaData::OtherReadPermission; + if(access_mask & WriteMask) + data.entryFlags |= QFileSystemMetaData::OtherWritePermission; + if(access_mask & ExecMask) + data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission; + } + LocalFree(pSD); + } + } + } else +#endif + { + //### what to do with permissions if we don't use NTFS + // for now just add all permissions and what about exe missions ?? + // also qt_ntfs_permission_lookup is now not set by default ... should it ? + data.entryFlags |= QFileSystemMetaData::OwnerReadPermission + | QFileSystemMetaData::GroupReadPermission + | QFileSystemMetaData::OtherReadPermission; + + if (!(data.fileAttribute_ & FILE_ATTRIBUTE_READONLY)) { + data.entryFlags |= QFileSystemMetaData::OwnerWritePermission + | QFileSystemMetaData::GroupWritePermission + | QFileSystemMetaData::OtherWritePermission; + } + + QString fname = entry.filePath(); + QString ext = fname.right(4).toLower(); + if (data.isDirectory() || + ext == QLatin1String(".exe") || ext == QLatin1String(".com") || ext == QLatin1String(".bat") || + ext == QLatin1String(".pif") || ext == QLatin1String(".cmd")) { + data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission | QFileSystemMetaData::GroupExecutePermission + | QFileSystemMetaData::OtherExecutePermission | QFileSystemMetaData::UserExecutePermission; + } + data.knownFlagsMask |= QFileSystemMetaData::OwnerPermissions | QFileSystemMetaData::GroupPermissions + | QFileSystemMetaData::OtherPermissions | QFileSystemMetaData::UserExecutePermission; + // calculate user permissions + if (what & QFileSystemMetaData::UserReadPermission) { + if (::_waccess((wchar_t*)entry.nativeFilePath().utf16(), R_OK) == 0) + data.entryFlags |= QFileSystemMetaData::UserReadPermission; + data.knownFlagsMask |= QFileSystemMetaData::UserReadPermission; + } + if (what & QFileSystemMetaData::UserWritePermission) { + if (::_waccess((wchar_t*)entry.nativeFilePath().utf16(), W_OK) == 0) + data.entryFlags |= QFileSystemMetaData::UserWritePermission; + data.knownFlagsMask |= QFileSystemMetaData::UserReadPermission; + } + } + + return data.hasFlags(what); +} + +static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaData &data) +{ + bool entryExists = false; + DWORD fileAttrib = 0; +#if !defined(Q_OS_WINCE) + if (fname.isDriveRoot()) { + // a valid drive ?? + DWORD drivesBitmask = ::GetLogicalDrives(); + int drivebit = 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode()); + if (drivesBitmask & drivebit) { + fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM; + entryExists = true; + } + } else { +#endif + const QString &path = fname.nativeFilePath(); + bool is_dir = false; + if (path.startsWith(QLatin1String("\\\\?\\UNC"))) { + // UNC - stat doesn't work for all cases (Windows bug) + int s = path.indexOf(path.at(0),7); + if (s > 0) { + // "\\?\UNC\server\..." + s = path.indexOf(path.at(0),s+1); + if (s > 0) { + // "\\?\UNC\server\share\..." + if (s == path.size() - 1) { + // "\\?\UNC\server\share\" + is_dir = true; + } else { + // "\\?\UNC\server\share\notfound" + } + } else { + // "\\?\UNC\server\share" + is_dir = true; + } + } else { + // "\\?\UNC\server" + is_dir = true; + } + } + if (is_dir && uncShareExists(path)) { + // looks like a UNC dir, is a dir. + fileAttrib = FILE_ATTRIBUTE_DIRECTORY; + entryExists = true; + } +#if !defined(Q_OS_WINCE) + } +#endif + if (entryExists) + data.fillFromFileAttribute(fileAttrib); + return entryExists; +} + +static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData &data) +{ + bool filledData = false; + // This assumes the last call to a Windows API failed. + int errorCode = GetLastError(); + if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { + WIN32_FIND_DATA findData; + if (getFindData(fname.nativeFilePath(), findData) + && findData.dwFileAttributes != INVALID_FILE_ATTRIBUTES) { + data.fillFromFindData(findData, true, fname.isDriveRoot()); + filledData = true; + } + } + return filledData; +} + +#if !defined(Q_OS_WINCE) +//static +bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data, + QFileSystemMetaData::MetaDataFlags what) +{ + HANDLE fHandle = (HANDLE)_get_osfhandle(fd); + if (fHandle != INVALID_HANDLE_VALUE) { + return fillMetaData(fHandle, data, what); + } + return false; +} +#endif + +//static +bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data, + QFileSystemMetaData::MetaDataFlags what) +{ + data.entryFlags &= ~what; + clearWinStatData(data); + BY_HANDLE_FILE_INFORMATION fileInfo; + UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); + if (GetFileInformationByHandle(fHandle , &fileInfo)) { + data.fillFromFindInfo(fileInfo); + } + SetErrorMode(oldmode); + return data.hasFlags(what); +} + +//static +bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, + QFileSystemMetaData::MetaDataFlags what) +{ + what |= QFileSystemMetaData::WinLnkType | QFileSystemMetaData::WinStatFlags; + data.entryFlags &= ~what; + + QFileSystemEntry fname; + data.knownFlagsMask |= QFileSystemMetaData::WinLnkType; + if(entry.filePath().endsWith(QLatin1String(".lnk"))) { + data.entryFlags |= QFileSystemMetaData::WinLnkType; + fname = QFileSystemEntry(readLink(entry)); + } else { + fname = entry; + } + + if (fname.isEmpty()) { + data.knownFlagsMask |= what; + clearWinStatData(data); + return false; + } + + if (what & QFileSystemMetaData::WinStatFlags) { + UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); + clearWinStatData(data); + WIN32_FIND_DATA findData; + // The memory structure for WIN32_FIND_DATA is same as WIN32_FILE_ATTRIBUTE_DATA + // for all members used by fillFindData(). + bool ok = ::GetFileAttributesEx((wchar_t*)fname.nativeFilePath().utf16(), GetFileExInfoStandard, + reinterpret_cast(&findData)); + if (ok) { + data.fillFromFindData(findData, false, fname.isDriveRoot()); + } else { + if (!tryFindFallback(fname, data)) + tryDriveUNCFallback(fname, data); + } + SetErrorMode(oldmode); + } + + if (what & QFileSystemMetaData::Permissions) + fillPermissions(fname, data, what); + if ((what & QFileSystemMetaData::LinkType) + && data.missingFlags(QFileSystemMetaData::LinkType)) { + data.knownFlagsMask |= QFileSystemMetaData::LinkType; + if (data.fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) { + WIN32_FIND_DATA findData; + if (getFindData(fname.nativeFilePath(), findData)) + data.fillFromFindData(findData, true); + } + } + data.knownFlagsMask |= what; + return data.hasFlags(what); +} + +static inline bool mkDir(const QString &path) +{ +#if defined(Q_OS_WINCE) + // Unfortunately CreateDirectory returns true for paths longer than + // 256, but does not create a directory. It starts to fail, when + // path length > MAX_PATH, which is 260 usually on CE. + // This only happens on a Windows Mobile device. Windows CE seems + // not to be affected by this. + static int platformId = 0; + if (platformId == 0) { + wchar_t platformString[64]; + if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformString)/sizeof(*platformString),platformString,0)) { + if (0 == wcscmp(platformString, L"PocketPC") || 0 == wcscmp(platformString, L"Smartphone")) + platformId = 1; + else + platformId = 2; + } + } + if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256) + return false; +#endif + return ::CreateDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), 0); +} + +static inline bool rmDir(const QString &path) +{ + return ::RemoveDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16()); +} + +static bool isDirPath(const QString &dirPath, bool *existed) +{ + QString path = dirPath; + if (path.length() == 2 && path.at(1) == QLatin1Char(':')) + path += QLatin1Char('\\'); + + DWORD fileAttrib = ::GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16()); + if (fileAttrib == INVALID_FILE_ATTRIBUTES) { + int errorCode = GetLastError(); + if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { + WIN32_FIND_DATA findData; + if (getFindData(QFSFileEnginePrivate::longFileName(path), findData)) + fileAttrib = findData.dwFileAttributes; + } + } + + if (existed) + *existed = fileAttrib != INVALID_FILE_ATTRIBUTES; + + if (fileAttrib == INVALID_FILE_ATTRIBUTES) + return false; + + return fileAttrib & FILE_ATTRIBUTE_DIRECTORY; } //static bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents) { - return false; // TODO implement; + QString dirName = entry.filePath(); + if (createParents) { + dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName)); + // We spefically search for / so \ would break it.. + int oldslash = -1; + if (dirName.startsWith(QLatin1String("\\\\"))) { + // Don't try to create the root path of a UNC path; + // CreateDirectory() will just return ERROR_INVALID_NAME. + for (int i = 0; i < dirName.size(); ++i) { + if (dirName.at(i) != QDir::separator()) { + oldslash = i; + break; + } + } + if (oldslash != -1) + oldslash = dirName.indexOf(QDir::separator(), oldslash); + } + for (int slash=0; slash != -1; oldslash = slash) { + slash = dirName.indexOf(QDir::separator(), oldslash+1); + if (slash == -1) { + if (oldslash == dirName.length()) + break; + slash = dirName.length(); + } + if (slash) { + QString chunk = dirName.left(slash); + bool existed = false; + if (!isDirPath(chunk, &existed)) { + if (!existed) { + if (!mkDir(chunk)) + return false; + } else { + return false; + } + } + } + } + return true; + } + return mkDir(entry.filePath()); } //static bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents) { - return false; // TODO implement; + QString dirName = entry.filePath(); + if (removeEmptyParents) { + dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName)); + for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { + QString chunk = dirName.left(slash); + if (chunk.length() == 2 && chunk.at(0).isLetter() && chunk.at(1) == QLatin1Char(':')) + break; + if (!isDirPath(chunk, 0)) + return false; + if (!rmDir(chunk)) + return oldslash != 0; + slash = dirName.lastIndexOf(QDir::separator(), oldslash-1); + } + return true; + } + return rmDir(entry.filePath()); +} + +//static +QString QFileSystemEngine::rootPath() +{ +#if defined(Q_OS_WINCE) + QString ret = QLatin1String("/"); +#elif defined(Q_FS_FAT) + QString ret = QString::fromLatin1(qgetenv("SystemDrive").constData()); + if (ret.isEmpty()) + ret = QLatin1String("c:"); + ret.append(QLatin1Char('/')); +#elif defined(Q_OS_OS2EMX) + char dir[4]; + _abspath(dir, QLatin1String("/"), _MAX_PATH); + QString ret(dir); +#endif + return ret; +} + +//static +QString QFileSystemEngine::homePath() +{ + QString ret; +#if !defined(QT_NO_LIBRARY) + resolveLibs(); + if (ptrGetUserProfileDirectoryW) { + HANDLE hnd = ::GetCurrentProcess(); + HANDLE token = 0; + BOOL ok = ::OpenProcessToken(hnd, TOKEN_QUERY, &token); + if (ok) { + DWORD dwBufferSize = 0; + // First call, to determine size of the strings (with '\0'). + ok = ptrGetUserProfileDirectoryW(token, NULL, &dwBufferSize); + if (!ok && dwBufferSize != 0) { // We got the required buffer size + wchar_t *userDirectory = new wchar_t[dwBufferSize]; + // Second call, now we can fill the allocated buffer. + ok = ptrGetUserProfileDirectoryW(token, userDirectory, &dwBufferSize); + if (ok) + ret = QString::fromWCharArray(userDirectory); + delete [] userDirectory; + } + ::CloseHandle(token); + } + } +#endif + if (ret.isEmpty() || !QFile::exists(ret)) { + ret = QString::fromLocal8Bit(qgetenv("USERPROFILE").constData()); + if (ret.isEmpty() || !QFile::exists(ret)) { + ret = QString::fromLocal8Bit(qgetenv("HOMEDRIVE").constData()) + + QString::fromLocal8Bit(qgetenv("HOMEPATH").constData()); + if (ret.isEmpty() || !QFile::exists(ret)) { + ret = QString::fromLocal8Bit(qgetenv("HOME").constData()); + if (ret.isEmpty() || !QFile::exists(ret)) { +#if defined(Q_OS_WINCE) + ret = QLatin1String("\\My Documents"); + if (!QFile::exists(ret)) +#endif + ret = rootPath(); + } + } + } + } + return QDir::fromNativeSeparators(ret); } //static @@ -111,25 +1094,90 @@ bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSy //static bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) { - return false; // TODO implement; + bool ret = ::CopyFile((wchar_t*)source.nativeFilePath().utf16(), + (wchar_t*)target.nativeFilePath().utf16(), true) != 0; + return ret; } //static bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) { - return false; // TODO implement; + bool ret = ::MoveFile((wchar_t*)source.nativeFilePath().utf16(), + (wchar_t*)target.nativeFilePath().utf16()) != 0; + return ret; } //static bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) { - return false; // TODO implement; + bool ret = ::DeleteFile((wchar_t*)entry.nativeFilePath().utf16()) != 0; + return ret; } //static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, + QFileSystemMetaData *data) { - return false; // TODO implement; + Q_UNUSED(data); + int mode = 0; + + if (permissions & QFile::ReadOwner || permissions & QFile::ReadUser + || permissions & QFile::ReadGroup || permissions & QFile::ReadOther) + mode |= _S_IREAD; + if (permissions & QFile::WriteOwner || permissions & QFile::WriteUser + || permissions & QFile::WriteGroup || permissions & QFile::WriteOther) + mode |= _S_IWRITE; + + if (mode == 0) // not supported + return false; + + return ::_wchmod((wchar_t*)entry.nativeFilePath().utf16(), mode) == 0; +} + +static inline QDateTime fileTimeToQDateTime(const FILETIME *time) +{ + QDateTime ret; + +#if defined(Q_OS_WINCE) + SYSTEMTIME systime; + FILETIME ftime; + systime.wYear = 1970; + systime.wMonth = 1; + systime.wDay = 1; + systime.wHour = 0; + systime.wMinute = 0; + systime.wSecond = 0; + systime.wMilliseconds = 0; + systime.wDayOfWeek = 4; + SystemTimeToFileTime(&systime, &ftime); + unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime; + FileTimeToSystemTime(time, &systime); + unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime; + unsigned __int64 difftime = acttime - time1970; + difftime /= 10000000; + ret.setTime_t((unsigned int)difftime); +#else + SYSTEMTIME sTime, lTime; + FileTimeToSystemTime(time, &sTime); + SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime); + ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay)); + ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds)); +#endif + + return ret; +} + +QDateTime QFileSystemMetaData::creationTime() const +{ + return fileTimeToQDateTime(&creationTime_); +} +QDateTime QFileSystemMetaData::modificationTime() const +{ + return fileTimeToQDateTime(&lastWriteTime_); +} +QDateTime QFileSystemMetaData::accessTime() const +{ + return fileTimeToQDateTime(&lastAccessTime_); } QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index e45c5dc..29ef987 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -111,9 +111,14 @@ public: BundleType = 0x0, AliasType = 0x0, #endif +#if defined(Q_OS_WIN) + WinLnkType = 0x08000000, // Note: Uses the same position for AliasType on Mac +#else + WinLnkType = 0x0, +#endif SequentialType = 0x00800000, // Note: overlaps with QAbstractFileEngine::RootFlag - LegacyLinkType = LinkType | AliasType, + LegacyLinkType = LinkType | AliasType | WinLnkType, Type = LinkType | FileType | DirectoryType | BundleType | SequentialType | AliasType, @@ -153,6 +158,14 @@ public: | QFileSystemMetaData::SequentialType | QFileSystemMetaData::Attributes | QFileSystemMetaData::Times, +#if defined(Q_OS_WIN) + WinStatFlags = QFileSystemMetaData::FileType + | QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::HiddenAttribute + | QFileSystemMetaData::ExistsAttribute + | QFileSystemMetaData::SizeAttribute + | QFileSystemMetaData::Times, +#endif AllMetaDataFlags = 0xFFFFFFFF @@ -181,7 +194,7 @@ public: bool exists() const { return (entryFlags & ExistsAttribute); } - bool isLink() const { return (entryFlags & LinkType); } + bool isLink() const { return (entryFlags & LinkType); } bool isFile() const { return (entryFlags & FileType); } bool isDirectory() const { return (entryFlags & DirectoryType); } bool isBundle() const; @@ -189,6 +202,11 @@ public: bool isLegacyLink() const { return (entryFlags & LegacyLinkType); } bool isSequential() const { return (entryFlags & SequentialType); } bool isHidden() const { return (entryFlags & HiddenAttribute); } +#if defined(Q_OS_WIN) + bool isLnkFile() const { return (entryFlags & WinLnkType); } +#else + bool isLnkFile() const { return false; } +#endif qint64 size() const { return size_; } @@ -212,6 +230,11 @@ public: void fillFromVolumeInfo(const TVolumeInfo& info); #endif +#if defined(Q_OS_WIN) + inline void fillFromFileAttribute(DWORD fileAttribute, bool isDriveRoot = false); + inline void fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType = false, bool isDriveRoot = false); + inline void fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo); +#endif private: friend class QFileSystemEngine; @@ -222,6 +245,10 @@ private: // Platform-specific data goes here: #if defined(Q_OS_WIN) + DWORD fileAttribute_; + FILETIME creationTime_; + FILETIME lastAccessTime_; + FILETIME lastWriteTime_; #elif defined(Q_OS_SYMBIAN) TTime modificationTime_; #else @@ -245,11 +272,7 @@ inline bool QFileSystemMetaData::isBundle() const { return fal inline bool QFileSystemMetaData::isAlias() const { return false; } #endif -#if defined(Q_OS_UNIX) && !defined (Q_OS_SYMBIAN) -inline QDateTime QFileSystemMetaData::creationTime() const { return QDateTime::fromTime_t(creationTime_); } -inline QDateTime QFileSystemMetaData::modificationTime() const { return QDateTime::fromTime_t(modificationTime_); } -inline QDateTime QFileSystemMetaData::accessTime() const { return QDateTime::fromTime_t(accessTime_); } - +#if (defined(Q_OS_UNIX) && !defined (Q_OS_SYMBIAN)) || defined (Q_OS_WIN) inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime time) const { switch (time) { @@ -265,6 +288,12 @@ inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime tim return QDateTime(); } +#endif + +#if defined(Q_OS_UNIX) && !defined (Q_OS_SYMBIAN) +inline QDateTime QFileSystemMetaData::creationTime() const { return QDateTime::fromTime_t(creationTime_); } +inline QDateTime QFileSystemMetaData::modificationTime() const { return QDateTime::fromTime_t(modificationTime_); } +inline QDateTime QFileSystemMetaData::accessTime() const { return QDateTime::fromTime_t(accessTime_); } inline uint QFileSystemMetaData::userId() const { return userId_; } inline uint QFileSystemMetaData::groupId() const { return groupId_; } @@ -297,6 +326,18 @@ inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) c } #endif +#if defined(Q_OS_WIN) +inline uint QFileSystemMetaData::userId() const { return (uint) -2; } +inline uint QFileSystemMetaData::groupId() const { return (uint) -2; } +inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) const +{ + if (owner == QAbstractFileEngine::OwnerUser) + return userId(); + else + return groupId(); +} +#endif + QT_END_NAMESPACE #endif // include guard diff --git a/src/corelib/io/qfsfileengine_iterator_win.cpp b/src/corelib/io/qfsfileengine_iterator_win.cpp index 7181025..d4e6f5a 100644 --- a/src/corelib/io/qfsfileengine_iterator_win.cpp +++ b/src/corelib/io/qfsfileengine_iterator_win.cpp @@ -41,6 +41,7 @@ #include "qfsfileengine_iterator_p.h" #include "qfsfileengine_p.h" +#include "qfilesystemengine_p.h" #include "qplatformdefs.h" #include @@ -135,7 +136,7 @@ bool QFSFileEngineIterator::hasNext() const // UNC QStringList parts = QDir::toNativeSeparators(path).split(QLatin1Char('\\'), QString::SkipEmptyParts); - if (parts.count() == 1 && QFSFileEnginePrivate::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(0), + if (parts.count() == 1 && QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(0), &platform->uncShares)) { if (platform->uncShares.isEmpty()) { platform->done = true; diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index a3733d8..14a8938 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -114,9 +114,7 @@ public: uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags); bool unmap(uchar *ptr); -#if defined(Q_OS_UNIX) mutable QFileSystemMetaData metaData; -#endif FILE *fh; #ifdef Q_OS_SYMBIAN @@ -177,7 +175,7 @@ public: #endif #if defined(Q_OS_WIN) - bool doStat() const; + bool doStat(QFileSystemMetaData::MetaDataFlags flags) const; #else bool doStat(QFileSystemMetaData::MetaDataFlags flags = QFileSystemMetaData::PosixStatFlags) const; #endif @@ -187,12 +185,6 @@ public: int sysOpen(const QString &, int flags); #endif -#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) - static void resolveLibs(); - static bool resolveUNCLibs(); - static bool uncListSharesOnServer(const QString &server, QStringList *list); -#endif - #ifdef Q_OS_SYMBIAN void setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString); #endif diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 7262129..976207a 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -69,69 +69,9 @@ #define SECURITY_WIN32 #include -#ifndef _INTPTR_T_DEFINED -#ifdef _WIN64 -typedef __int64 intptr_t; -#else -#ifdef _W64 -typedef _W64 int intptr_t; -#else -typedef INT_PTR intptr_t; -#endif -#endif -#define _INTPTR_T_DEFINED -#endif - -#ifndef INVALID_FILE_ATTRIBUTES -# define INVALID_FILE_ATTRIBUTES (DWORD (-1)) -#endif - -#if !defined(Q_OS_WINCE) -# if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE) -typedef struct _REPARSE_DATA_BUFFER { - ULONG ReparseTag; - USHORT ReparseDataLength; - USHORT Reserved; - union { - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - ULONG Flags; - WCHAR PathBuffer[1]; - } SymbolicLinkReparseBuffer; - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - WCHAR PathBuffer[1]; - } MountPointReparseBuffer; - struct { - UCHAR DataBuffer[1]; - } GenericReparseBuffer; - }; -} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER; -# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer) -# endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE) - -# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE -# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384 -# endif -# ifndef IO_REPARSE_TAG_SYMLINK -# define IO_REPARSE_TAG_SYMLINK (0xA000000CL) -# endif -# ifndef FSCTL_GET_REPARSE_POINT -# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS) -# endif -#endif // !defined(Q_OS_WINCE) - QT_BEGIN_NAMESPACE -static QString readLink(const QFileSystemEntry &link); -Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0; #if defined(Q_OS_WINCE) static QString qfsPrivateCurrentDir = QLatin1String(""); @@ -140,146 +80,6 @@ static QString qfsPrivateCurrentDir = QLatin1String(""); #define QT_NO_LIBRARY 1 #endif -#if !defined(QT_NO_LIBRARY) -QT_BEGIN_INCLUDE_NAMESPACE -typedef DWORD (WINAPI *PtrGetNamedSecurityInfoW)(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*); -static PtrGetNamedSecurityInfoW ptrGetNamedSecurityInfoW = 0; -typedef BOOL (WINAPI *PtrLookupAccountSidW)(LPCWSTR, PSID, LPWSTR, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE); -static PtrLookupAccountSidW ptrLookupAccountSidW = 0; -typedef VOID (WINAPI *PtrBuildTrusteeWithSidW)(PTRUSTEE_W, PSID); -static PtrBuildTrusteeWithSidW ptrBuildTrusteeWithSidW = 0; -typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACCESS_MASK); -static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0; -static TRUSTEE_W currentUserTrusteeW; -static TRUSTEE_W worldTrusteeW; - -typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD); -static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0; -typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD); -static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0; -QT_END_INCLUDE_NAMESPACE - - -void QFSFileEnginePrivate::resolveLibs() -{ - static bool triedResolve = false; - if (!triedResolve) { - // need to resolve the security info functions - - // protect initialization -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); - // check triedResolve again, since another thread may have already - // done the initialization - if (triedResolve) { - // another thread did initialize the security function pointers, - // so we shouldn't do it again. - return; - } -#endif - - triedResolve = true; -#if !defined(Q_OS_WINCE) - HINSTANCE advapiHnd = LoadLibrary(L"advapi32"); - if (advapiHnd) { - ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW"); - ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); - ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW"); - ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW"); - } - if (ptrBuildTrusteeWithSidW) { - // Create TRUSTEE for current user - HANDLE hnd = ::GetCurrentProcess(); - HANDLE token = 0; - if (::OpenProcessToken(hnd, TOKEN_QUERY, &token)) { - TOKEN_USER tu; - DWORD retsize; - if (::GetTokenInformation(token, TokenUser, &tu, sizeof(tu), &retsize)) - ptrBuildTrusteeWithSidW(¤tUserTrusteeW, tu.User.Sid); - ::CloseHandle(token); - } - - typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*); - PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); - typedef PVOID (WINAPI *PtrFreeSid)(PSID); - PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); - if (ptrAllocateAndInitializeSid && ptrFreeSid) { - // Create TRUSTEE for Everyone (World) - SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY }; - PSID pWorld = 0; - if (ptrAllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pWorld)) - ptrBuildTrusteeWithSidW(&worldTrusteeW, pWorld); - ptrFreeSid(pWorld); - } - } - HINSTANCE userenvHnd = LoadLibrary(L"userenv"); - if (userenvHnd) - ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); - HINSTANCE kernel32 = LoadLibrary(L"kernel32"); - if(kernel32) - ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW"); -#endif - } -} -#endif // QT_NO_LIBRARY - -typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD); -static PtrNetShareEnum ptrNetShareEnum = 0; -typedef DWORD (WINAPI *PtrNetApiBufferFree)(LPVOID); -static PtrNetApiBufferFree ptrNetApiBufferFree = 0; -typedef struct _SHARE_INFO_1 { - LPWSTR shi1_netname; - DWORD shi1_type; - LPWSTR shi1_remark; -} SHARE_INFO_1; - - -bool QFSFileEnginePrivate::resolveUNCLibs() -{ - static bool triedResolve = false; - if (!triedResolve) { -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); - if (triedResolve) { - return ptrNetShareEnum && ptrNetApiBufferFree; - } -#endif - triedResolve = true; -#if !defined(Q_OS_WINCE) - HINSTANCE hLib = LoadLibrary(L"netapi32"); - if (hLib) { - ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum"); - if (ptrNetShareEnum) - ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree"); - } -#endif - } - return ptrNetShareEnum && ptrNetApiBufferFree; -} - -bool QFSFileEnginePrivate::uncListSharesOnServer(const QString &server, QStringList *list) -{ - if (resolveUNCLibs()) { - SHARE_INFO_1 *BufPtr, *p; - DWORD res; - DWORD er = 0, tr = 0, resume = 0, i; - do { - res = ptrNetShareEnum((wchar_t*)server.utf16(), 1, (LPBYTE *)&BufPtr, DWORD(-1), &er, &tr, &resume); - if (res == ERROR_SUCCESS || res == ERROR_MORE_DATA) { - p = BufPtr; - for (i = 1; i <= er; ++i) { - if (list && p->shi1_type == 0) - list->append(QString::fromWCharArray(p->shi1_netname)); - p++; - } - } - ptrNetApiBufferFree(BufPtr); - } while (res == ERROR_MORE_DATA); - return res == ERROR_SUCCESS; - } - return false; -} - #if !defined(Q_OS_WINCE) static inline bool isUncPath(const QString &path) { @@ -289,47 +89,6 @@ static inline bool isUncPath(const QString &path) } #endif -// can be //server or //server/share -static bool uncShareExists(const QString &server) -{ - QStringList parts = server.split(QLatin1Char('\\'), QString::SkipEmptyParts); - if (parts.count()) { - QStringList shares; - if (QFSFileEnginePrivate::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(0), &shares)) - return parts.count() >= 2 ? shares.contains(parts.at(1), Qt::CaseInsensitive) : true; - } - return false; -} - -static QString nativeAbsoluteFilePath(const QString &path) -{ - QString absPath; -#if !defined(Q_OS_WINCE) - QVarLengthArray buf(qMax(MAX_PATH, path.size() + 1)); - wchar_t *fileName = 0; - DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); - if (retLen > (DWORD)buf.size()) { - buf.resize(retLen); - retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); - } - if (retLen != 0) - absPath = QString::fromWCharArray(buf.data(), retLen); -#else - if (path.startsWith(QLatin1Char('/')) || path.startsWith(QLatin1Char('\\'))) - absPath = QDir::toNativeSeparators(path); - else - absPath = QDir::toNativeSeparators(QDir::cleanPath(qfsPrivateCurrentDir + QLatin1Char('/') + path)); -#endif - // This is really ugly, but GetFullPathName strips off whitespace at the end. - // If you for instance write ". " in the lineedit of QFileDialog, - // (which is an invalid filename) this function will strip the space off and viola, - // the file is later reported as existing. Therefore, we re-add the whitespace that - // was at the end of path in order to keep the filename invalid. - if (!path.isEmpty() && path.at(path.size() - 1) == QLatin1Char(' ')) - absPath.append(QLatin1Char(' ')); - return absPath; -} - /*! \internal */ @@ -338,7 +97,7 @@ QString QFSFileEnginePrivate::longFileName(const QString &path) if (path.startsWith(QLatin1String("\\\\.\\"))) return path; - QString absPath = nativeAbsoluteFilePath(path); + QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path); #if !defined(Q_OS_WINCE) QString prefix = QLatin1String("\\\\?\\"); if (isUncPath(absPath)) { @@ -389,7 +148,6 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) // WriteOnly can create files, ReadOnly cannot. DWORD creationDisp = (openMode & QIODevice::WriteOnly) ? OPEN_ALWAYS : OPEN_EXISTING; - // Create the file handle. fileHandle = CreateFile((const wchar_t*)fileEntry.nativeFilePath().utf16(), accessRights, @@ -481,17 +239,9 @@ qint64 QFSFileEnginePrivate::nativeSize() const // ### Don't flush; for buffered files, we should get away with ftell. thatQ->flush(); -#if !defined(Q_OS_WINCE) - // stdlib/stdio mode. - if (fh || fd != -1) { - qint64 fileSize = _filelengthi64(fh ? QT_FILENO(fh) : fd); - if (fileSize == -1) { - fileSize = 0; - thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno)); - } - return fileSize; - } -#else // Q_OS_WINCE + // Always retrive the current information + metaData.clearFlags(QFileSystemMetaData::SizeAttribute); +#if defined(Q_OS_WINCE) // Buffered stdlib mode. if (fh) { QT_OFF_T oldPos = QT_FTELL(fh); @@ -504,57 +254,23 @@ qint64 QFSFileEnginePrivate::nativeSize() const } return fileSize; } -#endif - - // Not-open mode, where the file name is known: We'll check the - // file system directly. - if (openMode == QIODevice::NotOpen && !fileEntry.isEmpty()) { - WIN32_FILE_ATTRIBUTE_DATA attribData; - bool ok = ::GetFileAttributesEx((const wchar_t*)fileEntry.nativeFilePath().utf16(), - GetFileExInfoStandard, &attribData); - if (!ok) { - int errorCode = GetLastError(); - if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { - WIN32_FIND_DATA findData; - if (getFindData(fileEntry.nativeFilePath(), findData)) { - ok = true; - attribData.nFileSizeHigh = findData.nFileSizeHigh; - attribData.nFileSizeLow = findData.nFileSizeLow; - } - } - } - if (ok) { - qint64 size = attribData.nFileSizeHigh; - size <<= 32; - size += attribData.nFileSizeLow; - return size; - } - thatQ->setError(QFile::UnspecifiedError, qt_error_string()); - return 0; - } - -#if defined(Q_OS_WINCE) - // Unbuffed stdio mode if (fd != -1) { thatQ->setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); return 0; } #endif + bool filled = false; + if (fileHandle != INVALID_HANDLE_VALUE && openMode != QIODevice::NotOpen ) + filled = QFileSystemEngine::fillMetaData(fileHandle, metaData, + QFileSystemMetaData::SizeAttribute); + else + filled = doStat(QFileSystemMetaData::SizeAttribute); - // Windows native mode. - if (fileHandle == INVALID_HANDLE_VALUE) - return 0; - - BY_HANDLE_FILE_INFORMATION fileInfo; - if (!GetFileInformationByHandle(fileHandle, &fileInfo)) { - thatQ->setError(QFile::UnspecifiedError, qt_error_string()); + if (!filled || metaData.size() == -1) { + thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno)); return 0; } - - qint64 size = fileInfo.nFileSizeHigh; - size <<= 32; - size += fileInfo.nFileSizeLow; - return size; + return metaData.size(); } /* @@ -788,7 +504,7 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - bool ret = ::DeleteFile((wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0; + bool ret = QFileSystemEngine::removeFile(d->fileEntry); if (!ret) setError(QFile::RemoveError, qt_error_string()); return ret; @@ -797,10 +513,7 @@ bool QFSFileEngine::remove() bool QFSFileEngine::copy(const QString ©Name) { Q_D(QFSFileEngine); - - QFileSystemEntry target(copyName); - bool ret = ::CopyFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(), - (wchar_t*)target.nativeFilePath().utf16(), true) != 0; + bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(copyName)); if (!ret) setError(QFile::CopyError, qt_error_string()); return ret; @@ -809,130 +522,20 @@ bool QFSFileEngine::copy(const QString ©Name) bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - QFileSystemEntry target(newName); - bool ret = ::MoveFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(), - (wchar_t*)target.nativeFilePath().utf16()) != 0; + bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName)); if (!ret) setError(QFile::RenameError, qt_error_string()); return ret; } -static inline bool mkDir(const QString &path) -{ -#if defined(Q_OS_WINCE) - // Unfortunately CreateDirectory returns true for paths longer than - // 256, but does not create a directory. It starts to fail, when - // path length > MAX_PATH, which is 260 usually on CE. - // This only happens on a Windows Mobile device. Windows CE seems - // not to be affected by this. - static int platformId = 0; - if (platformId == 0) { - wchar_t platformString[64]; - if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformString)/sizeof(*platformString),platformString,0)) { - if (0 == wcscmp(platformString, L"PocketPC") || 0 == wcscmp(platformString, L"Smartphone")) - platformId = 1; - else - platformId = 2; - } - } - if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256) - return false; -#endif - return ::CreateDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), 0); -} - -static inline bool rmDir(const QString &path) -{ - return ::RemoveDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16()); -} - -static bool isDirPath(const QString &dirPath, bool *existed) -{ - QString path = dirPath; - if (path.length() == 2 && path.at(1) == QLatin1Char(':')) - path += QLatin1Char('\\'); - - DWORD fileAttrib = ::GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16()); - if (fileAttrib == INVALID_FILE_ATTRIBUTES) { - int errorCode = GetLastError(); - if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { - WIN32_FIND_DATA findData; - if (getFindData(QFSFileEnginePrivate::longFileName(path), findData)) - fileAttrib = findData.dwFileAttributes; - } - } - - if (existed) - *existed = fileAttrib != INVALID_FILE_ATTRIBUTES; - - if (fileAttrib == INVALID_FILE_ATTRIBUTES) - return false; - - return fileAttrib & FILE_ATTRIBUTE_DIRECTORY; -} - bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const { - QString dirName = name; - if (createParentDirectories) { - dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName)); - // We spefically search for / so \ would break it.. - int oldslash = -1; - if (dirName.startsWith(QLatin1String("\\\\"))) { - // Don't try to create the root path of a UNC path; - // CreateDirectory() will just return ERROR_INVALID_NAME. - for (int i = 0; i < dirName.size(); ++i) { - if (dirName.at(i) != QDir::separator()) { - oldslash = i; - break; - } - } - if (oldslash != -1) - oldslash = dirName.indexOf(QDir::separator(), oldslash); - } - for (int slash=0; slash != -1; oldslash = slash) { - slash = dirName.indexOf(QDir::separator(), oldslash+1); - if (slash == -1) { - if (oldslash == dirName.length()) - break; - slash = dirName.length(); - } - if (slash) { - QString chunk = dirName.left(slash); - bool existed = false; - if (!isDirPath(chunk, &existed)) { - if (!existed) { - if (!mkDir(chunk)) - return false; - } else { - return false; - } - } - } - } - return true; - } - return mkDir(name); + return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories); } bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const { - QString dirName = name; - if (recurseParentDirectories) { - dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName)); - for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { - QString chunk = dirName.left(slash); - if (chunk.length() == 2 && chunk.at(0).isLetter() && chunk.at(1) == QLatin1Char(':')) - break; - if (!isDirPath(chunk, 0)) - return false; - if (!rmDir(chunk)) - return oldslash != 0; - slash = dirName.lastIndexOf(QDir::separator(), oldslash-1); - } - return true; - } - return rmDir(name); + return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories); } bool QFSFileEngine::caseSensitive() const @@ -997,64 +600,12 @@ QString QFSFileEngine::currentPath(const QString &fileName) QString QFSFileEngine::homePath() { - QString ret; -#if !defined(QT_NO_LIBRARY) - QFSFileEnginePrivate::resolveLibs(); - if (ptrGetUserProfileDirectoryW) { - HANDLE hnd = ::GetCurrentProcess(); - HANDLE token = 0; - BOOL ok = ::OpenProcessToken(hnd, TOKEN_QUERY, &token); - if (ok) { - DWORD dwBufferSize = 0; - // First call, to determine size of the strings (with '\0'). - ok = ptrGetUserProfileDirectoryW(token, NULL, &dwBufferSize); - if (!ok && dwBufferSize != 0) { // We got the required buffer size - wchar_t *userDirectory = new wchar_t[dwBufferSize]; - // Second call, now we can fill the allocated buffer. - ok = ptrGetUserProfileDirectoryW(token, userDirectory, &dwBufferSize); - if (ok) - ret = QString::fromWCharArray(userDirectory); - - delete [] userDirectory; - } - ::CloseHandle(token); - } - } -#endif - if (ret.isEmpty() || !QFile::exists(ret)) { - ret = QString::fromLocal8Bit(qgetenv("USERPROFILE").constData()); - if (ret.isEmpty() || !QFile::exists(ret)) { - ret = QString::fromLocal8Bit(qgetenv("HOMEDRIVE").constData()) + QString::fromLocal8Bit(qgetenv("HOMEPATH").constData()); - if (ret.isEmpty() || !QFile::exists(ret)) { - ret = QString::fromLocal8Bit(qgetenv("HOME").constData()); - if (ret.isEmpty() || !QFile::exists(ret)) { -#if defined(Q_OS_WINCE) - ret = QLatin1String("\\My Documents"); - if (!QFile::exists(ret)) -#endif - ret = rootPath(); - } - } - } - } - return QDir::fromNativeSeparators(ret); + return QFileSystemEngine::homePath(); } QString QFSFileEngine::rootPath() { -#if defined(Q_OS_WINCE) - QString ret = QLatin1String("/"); -#elif defined(Q_FS_FAT) - QString ret = QString::fromLatin1(qgetenv("SystemDrive").constData()); - if (ret.isEmpty()) - ret = QLatin1String("c:"); - ret.append(QLatin1Char('/')); -#elif defined(Q_OS_OS2EMX) - char dir[4]; - _abspath(dir, QLatin1String("/"), _MAX_PATH); - QString ret(dir); -#endif - return ret; + return QFileSystemEngine::rootPath(); } QString QFSFileEngine::tempPath() @@ -1107,219 +658,25 @@ QFileInfoList QFSFileEngine::drives() #endif } -bool QFSFileEnginePrivate::doStat() const +bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const { - if (!tried_stat) { + if (!tried_stat || !metaData.hasFlags(flags)) { tried_stat = true; - could_stat = false; - - if (fileEntry.isEmpty()) - return could_stat; - - QFileSystemEntry fname; - if(fileEntry.filePath().endsWith(QLatin1String(".lnk"))) { - fname = QFileSystemEntry(readLink(fileEntry)); - if(fname.isEmpty()) - return could_stat; - } - else - fname = fileEntry; - - UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); - if (fd != -1) { #if !defined(Q_OS_WINCE) - HANDLE fh = (HANDLE)_get_osfhandle(fd); - if (fh != INVALID_HANDLE_VALUE) { - BY_HANDLE_FILE_INFORMATION fileInfo; - if (GetFileInformationByHandle(fh, &fileInfo)) { - could_stat = true; - fileAttrib = fileInfo.dwFileAttributes; - } - } -#else - DWORD tmpAttributes = GetFileAttributes((wchar_t*)fname.nativeFilePath().utf16()); - if (tmpAttributes != -1) { - fileAttrib = tmpAttributes; - could_stat = true; - } -#endif - } else { - fileAttrib = GetFileAttributes((wchar_t*)fname.nativeFilePath().utf16()); - if (fileAttrib == INVALID_FILE_ATTRIBUTES) { - int errorCode = GetLastError(); - if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { - WIN32_FIND_DATA findData; - if (getFindData(fname.nativeFilePath(), findData)) { - fileAttrib = findData.dwFileAttributes; - } - } - } - could_stat = fileAttrib != INVALID_FILE_ATTRIBUTES; - if (!could_stat) { -#if !defined(Q_OS_WINCE) - if (fname.isDriveRoot()) { - // a valid drive ?? - DWORD drivesBitmask = ::GetLogicalDrives(); - int drivebit = 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode()); - if (drivesBitmask & drivebit) { - fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM; - could_stat = true; - } - } else { -#endif - const QString &path = fname.nativeFilePath(); - bool is_dir = false; - if (path.startsWith(QLatin1String("\\\\"))) { - // UNC - stat doesn't work for all cases (Windows bug) - int s = path.indexOf(path.at(0),2); - if (s > 0) { - // "\\server\..." - s = path.indexOf(path.at(0),s+1); - if (s > 0) { - // "\\server\share\..." - if (s == path.size() - 1) { - // "\\server\share\" - is_dir = true; - } else { - // "\\server\share\notfound" - } - } else { - // "\\server\share" - is_dir = true; - } - } else { - // "\\server" - is_dir = true; - } - } - if (is_dir && uncShareExists(path)) { - // looks like a UNC dir, is a dir. - fileAttrib = FILE_ATTRIBUTE_DIRECTORY; - could_stat = true; - } -#if !defined(Q_OS_WINCE) - } + int localFd = fd; + if (fh && fileEntry.isEmpty()) + localFd = QT_FILENO(fh); + if (localFd != -1) + QFileSystemEngine::fillMetaData(localFd, metaData, flags); #endif - } - } - - SetErrorMode(oldmode); + if (metaData.missingFlags(flags) && !fileEntry.isEmpty()) + QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags)); } - return could_stat; -} - -static QString readSymLink(const QFileSystemEntry &link) -{ - QString result; -#if !defined(Q_OS_WINCE) - HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(), - FILE_READ_EA, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - 0, - OPEN_EXISTING, - FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, - 0); - if (handle != INVALID_HANDLE_VALUE) { - DWORD bufsize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE; - REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize); - DWORD retsize = 0; - if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) { - if (rdb->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { - int length = rdb->MountPointReparseBuffer.SubstituteNameLength / sizeof(wchar_t); - int offset = rdb->MountPointReparseBuffer.SubstituteNameOffset / sizeof(wchar_t); - const wchar_t* PathBuffer = &rdb->MountPointReparseBuffer.PathBuffer[offset]; - result = QString::fromWCharArray(PathBuffer, length); - } else if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) { - int length = rdb->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t); - int offset = rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t); - const wchar_t* PathBuffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[offset]; - result = QString::fromWCharArray(PathBuffer, length); - } - // cut-off "//?/" and "/??/" - if (result.size() > 4 && result.at(0) == QLatin1Char('\\') && result.at(2) == QLatin1Char('?') && result.at(3) == QLatin1Char('\\')) - result = result.mid(4); - } - qFree(rdb); - CloseHandle(handle); - -#if !defined(QT_NO_LIBRARY) - QFSFileEnginePrivate::resolveLibs(); - if (ptrGetVolumePathNamesForVolumeNameW) { - QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive); - if(matchVolName.indexIn(result) == 0) { - DWORD len; - wchar_t buffer[MAX_PATH]; - QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\")); - if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0) - result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); - } - } -#endif - } -#else - Q_UNUSED(link); -#endif // Q_OS_WINCE - return result; + return metaData.exists(); } -static QString readLink(const QFileSystemEntry &link) -{ -#if !defined(Q_OS_WINCE) -#if !defined(QT_NO_LIBRARY) && !defined(Q_CC_MWERKS) - QString ret; - - bool neededCoInit = false; - IShellLink *psl; // pointer to IShellLink i/f - WIN32_FIND_DATA wfd; - wchar_t szGotPath[MAX_PATH]; - - // Get pointer to the IShellLink interface. - HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl); - - if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized - neededCoInit = true; - CoInitialize(NULL); - hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, - IID_IShellLink, (LPVOID *)&psl); - } - if (SUCCEEDED(hres)) { // Get pointer to the IPersistFile interface. - IPersistFile *ppf; - hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf); - if (SUCCEEDED(hres)) { - hres = ppf->Load((LPOLESTR)link.nativeFilePath().utf16(), STGM_READ); - //The original path of the link is retrieved. If the file/folder - //was moved, the return value still have the old path. - if (SUCCEEDED(hres)) { - if (psl->GetPath(szGotPath, MAX_PATH, &wfd, SLGP_UNCPRIORITY) == NOERROR) - ret = QString::fromWCharArray(szGotPath); - } - ppf->Release(); - } - psl->Release(); - } - if (neededCoInit) - CoUninitialize(); - - return ret; -#else - Q_UNUSED(link); - return QString(); -#endif // QT_NO_LIBRARY -#else - wchar_t target[MAX_PATH]; - QString result; - if (SHGetShortcutTarget((wchar_t*)QFileInfo(link.filePath()).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) { - result = QString::fromWCharArray(target); - if (result.startsWith(QLatin1Char('"'))) - result.remove(0,1); - if (result.endsWith(QLatin1Char('"'))) - result.remove(result.size()-1,1); - } - return result; -#endif // Q_OS_WINCE -} bool QFSFileEngine::link(const QString &newName) { @@ -1384,183 +741,63 @@ bool QFSFileEngine::link(const QString &newName) #endif // Q_OS_WINCE } -QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions(QAbstractFileEngine::FileFlags type) const +/*! + \reimp +*/ +QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::FileFlags type) const { + Q_D(const QFSFileEngine); + + if (type & Refresh) + d->metaData.clear(); + QAbstractFileEngine::FileFlags ret = 0; -#if !defined(QT_NO_LIBRARY) - if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { - resolveLibs(); - if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) { - enum { ReadMask = 0x00000001, WriteMask = 0x00000002, ExecMask = 0x00000020 }; - - QString fname = fileEntry.filePath().endsWith(QLatin1String(".lnk")) ? readLink(fileEntry) : fileEntry.filePath(); - PSID pOwner = 0; - PSID pGroup = 0; - PACL pDacl; - PSECURITY_DESCRIPTOR pSD; - DWORD res = ptrGetNamedSecurityInfoW((wchar_t*)fname.utf16(), SE_FILE_OBJECT, - OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, - &pOwner, &pGroup, &pDacl, 0, &pSD); - if(res == ERROR_SUCCESS) { - ACCESS_MASK access_mask; - TRUSTEE_W trustee; - if (type & 0x0700) { // user - if(ptrGetEffectiveRightsFromAclW(pDacl, ¤tUserTrusteeW, &access_mask) != ERROR_SUCCESS) - access_mask = (ACCESS_MASK)-1; - if(access_mask & ReadMask) - ret |= QAbstractFileEngine::ReadUserPerm; - if(access_mask & WriteMask) - ret |= QAbstractFileEngine::WriteUserPerm; - if(access_mask & ExecMask) - ret |= QAbstractFileEngine::ExeUserPerm; - } - if (type & 0x7000) { // owner - ptrBuildTrusteeWithSidW(&trustee, pOwner); - if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS) - access_mask = (ACCESS_MASK)-1; - if(access_mask & ReadMask) - ret |= QAbstractFileEngine::ReadOwnerPerm; - if(access_mask & WriteMask) - ret |= QAbstractFileEngine::WriteOwnerPerm; - if(access_mask & ExecMask) - ret |= QAbstractFileEngine::ExeOwnerPerm; - } - if (type & 0x0070) { // group - ptrBuildTrusteeWithSidW(&trustee, pGroup); - if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS) - access_mask = (ACCESS_MASK)-1; - if(access_mask & ReadMask) - ret |= QAbstractFileEngine::ReadGroupPerm; - if(access_mask & WriteMask) - ret |= QAbstractFileEngine::WriteGroupPerm; - if(access_mask & ExecMask) - ret |= QAbstractFileEngine::ExeGroupPerm; - } - if (type & 0x0007) { // other (world) - if(ptrGetEffectiveRightsFromAclW(pDacl, &worldTrusteeW, &access_mask) != ERROR_SUCCESS) - access_mask = (ACCESS_MASK)-1; // ### - if(access_mask & ReadMask) - ret |= QAbstractFileEngine::ReadOtherPerm; - if(access_mask & WriteMask) - ret |= QAbstractFileEngine::WriteOtherPerm; - if(access_mask & ExecMask) - ret |= QAbstractFileEngine::ExeOtherPerm; - } - LocalFree(pSD); - } - } - } else -#endif + if (type & FlagsMask) + ret |= LocalDiskFlag; + + bool exists; { - //### what to do with permissions if we don't use NTFS - // for now just add all permissions and what about exe missions ?? - // also qt_ntfs_permission_lookup is now not set by default ... should it ? - ret |= QAbstractFileEngine::ReadOwnerPerm | QAbstractFileEngine::ReadGroupPerm - | QAbstractFileEngine::ReadOtherPerm; - - if (!(fileAttrib & FILE_ATTRIBUTE_READONLY)) { - ret |= QAbstractFileEngine::WriteOwnerPerm | QAbstractFileEngine::WriteGroupPerm - | QAbstractFileEngine::WriteOtherPerm; - } + QFileSystemMetaData::MetaDataFlags queryFlags = 0; - QString fname = fileEntry.filePath().endsWith(QLatin1String(".lnk")) ? readLink(fileEntry) : fileEntry.filePath(); - QString ext = fname.right(4).toLower(); - if ((fileAttrib & FILE_ATTRIBUTE_DIRECTORY) || - ext == QLatin1String(".exe") || ext == QLatin1String(".com") || ext == QLatin1String(".bat") || - ext == QLatin1String(".pif") || ext == QLatin1String(".cmd")) { - ret |= QAbstractFileEngine::ExeOwnerPerm | QAbstractFileEngine::ExeGroupPerm - | QAbstractFileEngine::ExeOtherPerm | QAbstractFileEngine::ExeUserPerm; - } + queryFlags |= QFileSystemMetaData::MetaDataFlags(uint(type)) + & QFileSystemMetaData::Permissions; - // calculate user permissions - if (type & QAbstractFileEngine::ReadUserPerm) { - if (::_waccess((wchar_t*)longFileName(fname).utf16(), R_OK) == 0) - ret |= QAbstractFileEngine::ReadUserPerm; - } - if (type & QAbstractFileEngine::WriteUserPerm) { - if (::_waccess((wchar_t*)longFileName(fname).utf16(), W_OK) == 0) - ret |= QAbstractFileEngine::WriteUserPerm; - } - } - return ret; -} + // AliasType and BundleType are 0x0 + if (type & TypesMask) + queryFlags |= QFileSystemMetaData::AliasType + | QFileSystemMetaData::LinkType + | QFileSystemMetaData::FileType + | QFileSystemMetaData::DirectoryType + | QFileSystemMetaData::BundleType; -/*! - \internal -*/ -bool QFSFileEnginePrivate::isSymlink() const -{ -#if !defined(Q_OS_WINCE) - if (need_lstat) { - need_lstat = false; - is_link = false; - - if (fileAttrib & FILE_ATTRIBUTE_REPARSE_POINT) { - WIN32_FIND_DATA findData; - if (getFindData(fileEntry.nativeFilePath(), findData)) { - if ((findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) - && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { - is_link = true; - } - } - } - } - return is_link; -#else - return false; -#endif // Q_OS_WINCE -} + if (type & FlagsMask) + queryFlags |= QFileSystemMetaData::HiddenAttribute + | QFileSystemMetaData::ExistsAttribute; -/*! - \reimp -*/ -QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(QAbstractFileEngine::FileFlags type) const -{ - Q_D(const QFSFileEngine); - QAbstractFileEngine::FileFlags ret = 0; - // Force a stat, so that we're guaranteed to get up-to-date results - if (type & Refresh) { - d->tried_stat = 0; -#if !defined(Q_OS_WINCE) - d->need_lstat = 1; -#endif - } + queryFlags |= QFileSystemMetaData::LinkType; - if (type & PermsMask) { - if (d->doStat()) { - ret |= ExistsFlag; - ret |= d->getPermissions(type); - } + exists = d->doStat(queryFlags); } + + if (exists && (type & PermsMask)) + ret |= FileFlags(uint(d->metaData.permissions())); + if (type & TypesMask) { - if (d->fileEntry.filePath().endsWith(QLatin1String(".lnk"))) { + if ((type & LinkType) && d->metaData.isLegacyLink()) ret |= LinkType; - QString l = readLink(d->fileEntry); - if (!l.isEmpty()) { - bool existed = false; - if (isDirPath(l, &existed) && existed) - ret |= DirectoryType; - else if (existed) - ret |= FileType; - } - } else if (d->doStat()) { - if ((type & LinkType) && d->isSymlink()) - ret |= LinkType; - if (d->fileAttrib & FILE_ATTRIBUTE_DIRECTORY) { - ret |= DirectoryType; - } else { - ret |= FileType; - } + if (d->metaData.isDirectory()) { + ret |= DirectoryType; + } else { + ret |= FileType; } } if (type & FlagsMask) { - ret |= LocalDiskFlag; - if (d->doStat()) { + if (d->metaData.exists()) { ret |= ExistsFlag; if (d->fileEntry.isRoot()) ret |= RootFlag; - else if (d->fileAttrib & FILE_ATTRIBUTE_HIDDEN) + else if (d->metaData.isHidden()) ret |= HiddenFlag; } } @@ -1585,7 +822,7 @@ QString QFSFileEngine::fileName(FileName file) const d->fileEntry.filePath().contains(QLatin1String("/../")) || d->fileEntry.filePath().contains(QLatin1String("/./")) || d->fileEntry.filePath().endsWith(QLatin1String("/..")) || d->fileEntry.filePath().endsWith(QLatin1String("/."))) { - ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(d->fileEntry.filePath())); + ret = QDir::fromNativeSeparators(QFileSystemEngine::nativeAbsoluteFilePath(d->fileEntry.filePath())); } else #endif { @@ -1621,18 +858,13 @@ QString QFSFileEngine::fileName(FileName file) const } else if (file == CanonicalName || file == CanonicalPathName) { if (!(fileFlags(ExistsFlag) & ExistsFlag)) return QString(); - QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry)); + QFileSystemEntry entry(QFileSystemEngine::canonicalName(QFileSystemEntry(fileName(AbsoluteName)))); if (file == CanonicalPathName) return entry.path(); return entry.filePath(); } else if (file == LinkName) { - QString ret; - if (d->fileEntry.filePath().endsWith(QLatin1String(".lnk"))) - ret = readLink(d->fileEntry); - else if (d->doStat() && d->isSymlink()) - ret = readSymLink(d->fileEntry); - return QDir::fromNativeSeparators(ret); + QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData).filePath(); } else if (file == BundleName) { return QString(); } @@ -1654,67 +886,14 @@ uint QFSFileEngine::ownerId(FileOwner /*own*/) const QString QFSFileEngine::owner(FileOwner own) const { - QString name; -#if !defined(QT_NO_LIBRARY) Q_D(const QFSFileEngine); - if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) { - QFSFileEnginePrivate::resolveLibs(); - if (ptrGetNamedSecurityInfoW && ptrLookupAccountSidW) { - PSID pOwner = 0; - PSECURITY_DESCRIPTOR pSD; - if (ptrGetNamedSecurityInfoW((wchar_t*)d->fileEntry.nativeFilePath().utf16(), SE_FILE_OBJECT, - own == OwnerGroup ? GROUP_SECURITY_INFORMATION : OWNER_SECURITY_INFORMATION, - own == OwnerUser ? &pOwner : 0, own == OwnerGroup ? &pOwner : 0, - 0, 0, &pSD) == ERROR_SUCCESS) { - DWORD lowner = 64; - DWORD ldomain = 64; - QVarLengthArray owner(lowner); - QVarLengthArray domain(ldomain); - SID_NAME_USE use = SidTypeUnknown; - // First call, to determine size of the strings (with '\0'). - if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner, - (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) { - if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { - if (lowner > (DWORD)owner.size()) - owner.resize(lowner); - if (ldomain > (DWORD)domain.size()) - domain.resize(ldomain); - // Second call, try on resized buf-s - if (!ptrLookupAccountSidW(NULL, pOwner, (LPWSTR)owner.data(), &lowner, - (LPWSTR)domain.data(), &ldomain, (SID_NAME_USE*)&use)) { - lowner = 0; - } - } else { - lowner = 0; - } - } - if (lowner != 0) - name = QString::fromWCharArray(owner.data()); - LocalFree(pSD); - } - } - } -#else - Q_UNUSED(own); -#endif - return name; + return QFileSystemEngine::owner(d->fileEntry, own); } bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); - bool ret = false; - int mode = 0; - - if (perms & QFile::ReadOwner || perms & QFile::ReadUser || perms & QFile::ReadGroup || perms & QFile::ReadOther) - mode |= _S_IREAD; - if (perms & QFile::WriteOwner || perms & QFile::WriteUser || perms & QFile::WriteGroup || perms & QFile::WriteOther) - mode |= _S_IWRITE; - - if (mode == 0) // not supported - return false; - - ret = ::_wchmod((wchar_t*)d->fileEntry.nativeFilePath().utf16(), mode) == 0; + bool ret = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms)); if (!ret) setError(QFile::PermissionsError, qt_error_string(errno)); return ret; @@ -1758,83 +937,14 @@ bool QFSFileEngine::setSize(qint64 size) } -static inline QDateTime fileTimeToQDateTime(const FILETIME *time) -{ - QDateTime ret; - -#if defined(Q_OS_WINCE) - SYSTEMTIME systime; - FILETIME ftime; - systime.wYear = 1970; - systime.wMonth = 1; - systime.wDay = 1; - systime.wHour = 0; - systime.wMinute = 0; - systime.wSecond = 0; - systime.wMilliseconds = 0; - systime.wDayOfWeek = 4; - SystemTimeToFileTime(&systime, &ftime); - unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime; - FileTimeToSystemTime(time, &systime); - unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime; - unsigned __int64 difftime = acttime - time1970; - difftime /= 10000000; - ret.setTime_t((unsigned int)difftime); -#else - SYSTEMTIME sTime, lTime; - FileTimeToSystemTime(time, &sTime); - SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime); - ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay)); - ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds)); -#endif - - return ret; -} - QDateTime QFSFileEngine::fileTime(FileTime time) const { Q_D(const QFSFileEngine); - QDateTime ret; - if (d->fd != -1) { -#if !defined(Q_OS_WINCE) - HANDLE fh = (HANDLE)_get_osfhandle(d->fd); - if (fh != INVALID_HANDLE_VALUE) { - FILETIME creationTime, lastAccessTime, lastWriteTime; - if (GetFileTime(fh, &creationTime, &lastAccessTime, &lastWriteTime)) { - if(time == CreationTime) - ret = fileTimeToQDateTime(&creationTime); - else if(time == ModificationTime) - ret = fileTimeToQDateTime(&lastWriteTime); - else if(time == AccessTime) - ret = fileTimeToQDateTime(&lastAccessTime); - } - } -#endif - } else { - WIN32_FILE_ATTRIBUTE_DATA attribData; - bool ok = ::GetFileAttributesEx((wchar_t*)QFSFileEnginePrivate::longFileName(d->fileEntry.filePath()).utf16(), GetFileExInfoStandard, &attribData); - if (!ok) { - int errorCode = GetLastError(); - if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) { - WIN32_FIND_DATA findData; - if (getFindData(d->fileEntry.nativeFilePath(), findData)) { - ok = true; - attribData.ftCreationTime = findData.ftCreationTime; - attribData.ftLastWriteTime = findData.ftLastWriteTime; - attribData.ftLastAccessTime = findData.ftLastAccessTime; - } - } - } - if (ok) { - if(time == CreationTime) - ret = fileTimeToQDateTime(&attribData.ftCreationTime); - else if(time == ModificationTime) - ret = fileTimeToQDateTime(&attribData.ftLastWriteTime); - else if(time == AccessTime) - ret = fileTimeToQDateTime(&attribData.ftLastAccessTime); - } - } - return ret; + + if (d->doStat(QFileSystemMetaData::Times)) + return d->metaData.fileTime(time); + + return QDateTime(); } uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, -- cgit v0.12 From 15dbe69d9a174a85aed297b2e93d0d9fb79d12e8 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 14 Sep 2010 11:22:22 +0200 Subject: Fix the tst_QFileInfo::canonicalFilePath() on windows. This was trying to load a wrong Win32 function to test the symbolic links on windows. Some Win32 APIs have to be resolved against either a Wider Character version('W') or an ANSI version('A'), the function names without these character appended are usually '#define's in the header files. Reviewed-by: Zeno Albisser --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index cced207..e4aa0d3 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -608,7 +608,7 @@ void tst_QFileInfo::canonicalFilePath() #ifdef Q_OS_WIN typedef BOOL (WINAPI *PtrCreateSymbolicLink)(LPTSTR, LPTSTR, DWORD); PtrCreateSymbolicLink ptrCreateSymbolicLink = - (PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLink"); + (PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLinkW"); if (!ptrCreateSymbolicLink || ptrCreateSymbolicLink((wchar_t*)QString("res").utf16(), (wchar_t*)QString("resources").utf16(), 1) == 0) { @@ -621,7 +621,7 @@ void tst_QFileInfo::canonicalFilePath() QCOMPARE(QFileInfo("file1").canonicalFilePath(), currentPath + "/resources/file1"); QCOMPARE(QDir::setCurrent(currentPath), true); - QFile::remove("res"); + QDir::current().rmdir("res"); #endif } -- cgit v0.12 From f2dbebdab183dfe5d18ab7a8fbd85983401dfa3c Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 14 Sep 2010 16:23:27 +0200 Subject: Make compile for symbian Reviewed-by: Shane Kearns --- src/corelib/io/qfilesystemengine_symbian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index dc7fcbf..ca559da 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -141,7 +141,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) result.append(orig); } - return symbianCleanAbsolutePath(result); + return QFileSystemEntry(symbianCleanAbsolutePath(result)); } //static -- cgit v0.12 From 0299d30d5aa35d532df6bc018afc52df263651a0 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 14 Sep 2010 13:01:29 +0200 Subject: Test QDirIterator using UNC paths on Windows. Adding the test tst_QDirIterator::uncPaths(). Currently this traverses the shares & folders in test-server for all entries except '.' & '..' Reviewed-by: Denis --- tests/auto/qdiriterator/tst_qdiriterator.cpp | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index f78ce34..d93e91e 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -57,6 +57,10 @@ #define Q_NO_SYMLINKS_TO_DIRS #endif +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#include "../network-settings.h" +#endif + Q_DECLARE_METATYPE(QDirIterator::IteratorFlags) Q_DECLARE_METATYPE(QDir::Filters) @@ -118,6 +122,10 @@ private slots: void longPath(); void task185502_dirorder(); void relativePaths(); +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + void uncPaths_data(); + void uncPaths(); +#endif }; tst_QDirIterator::tst_QDirIterator() @@ -532,6 +540,28 @@ void tst_QDirIterator::relativePaths() } } +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +void tst_QDirIterator::uncPaths_data() +{ + QTest::addColumn("dirName"); + QTest::newRow("uncserver") + < Date: Mon, 13 Sep 2010 16:50:27 +0100 Subject: Pass QFileSystemMetaData reference into QFileSystemEngine::canonicalName On symbian, this allows us to use the cached ExistsAttribute On symbian and unix, this allows us to update the caller's knowledge of ExistsAttribute (potentially saving a stat later) Reviewed-By: joao --- src/corelib/io/qfileinfo.cpp | 2 +- src/corelib/io/qfilesystemengine_p.h | 2 +- src/corelib/io/qfilesystemengine_symbian.cpp | 7 ++++--- src/corelib/io/qfilesystemengine_unix.cpp | 6 +++++- src/corelib/io/qfilesystemengine_win.cpp | 2 +- src/corelib/io/qfsfileengine_unix.cpp | 2 +- src/corelib/io/qfsfileengine_win.cpp | 2 +- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 83df26d..4f5a4ab 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -57,7 +57,7 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const switch (name) { case QAbstractFileEngine::CanonicalName: case QAbstractFileEngine::CanonicalPathName: { - QFileSystemEntry entry = QFileSystemEngine::canonicalName(fileEntry); + QFileSystemEntry entry = QFileSystemEngine::canonicalName(fileEntry, metaData); if (cache_enabled) { // be smart and store both fileNames[QAbstractFileEngine::CanonicalName] = entry.filePath(); fileNames[QAbstractFileEngine::CanonicalPathName] = entry.path(); diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 1068e76..b3bbd65 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -65,7 +65,7 @@ public: static bool isCaseSensitive(); static QFileSystemEntry getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data); - static QFileSystemEntry canonicalName(const QFileSystemEntry &entry); + static QFileSystemEntry canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data); static QFileSystemEntry absoluteName(const QFileSystemEntry &entry); static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data); static QString resolveUserName(uint userId); diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index ca559da..9b81571 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -89,14 +89,15 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, } //static -QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) +QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data) { if (entry.isEmpty() || entry.isRoot()) return entry; QFileSystemEntry result = absoluteName(entry); - QFileSystemMetaData meta; - if (!fillMetaData(result, meta, QFileSystemMetaData::ExistsAttribute) || !meta.exists()) { + if (!data.hasFlags(QFileSystemMetaData::ExistsAttribute)) + fillMetaData(result, data, QFileSystemMetaData::ExistsAttribute); + if (!data.exists()) { // file doesn't exist return QFileSystemEntry(); } else { diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index fdb881f..6d8b3ff 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -193,7 +193,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, } //static -QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) +QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, , QFileSystemMetaData &data) { if (entry.isEmpty() || entry.isRoot()) return entry; @@ -223,10 +223,14 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) ret = realpath(entry.nativeFilePath().constData(), (char*)0); # endif if (ret) { + data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute; + data.entryFlags |= QFileSystemMetaData::ExistsAttribute; QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret)); free(ret); return QFileSystemEntry(canonicalPath); } else if (errno == ENOENT) { // file doesn't exist + data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute; + data.entryFlags &= ~(QFileSystemMetaData::ExistsAttribute); return QFileSystemEntry(); } return entry; diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 550b522..2e9f94b 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -493,7 +493,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, } //static -QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry) +QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data) { // The caller has to verify whether the file exists or not. return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index a6cf7fc..418506c 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -923,7 +923,7 @@ QString QFSFileEngine::fileName(FileName file) const } return entry.filePath(); } else if (file == CanonicalName || file == CanonicalPathName) { - QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry)); + QFileSystemEntry entry(QFileSystemEngine::canonicalName(d->fileEntry, d->metaData)); if (file == CanonicalPathName) return entry.path(); return entry.filePath(); diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 976207a..2bf377a 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -858,7 +858,7 @@ QString QFSFileEngine::fileName(FileName file) const } else if (file == CanonicalName || file == CanonicalPathName) { if (!(fileFlags(ExistsFlag) & ExistsFlag)) return QString(); - QFileSystemEntry entry(QFileSystemEngine::canonicalName(QFileSystemEntry(fileName(AbsoluteName)))); + QFileSystemEntry entry(QFileSystemEngine::canonicalName(QFileSystemEntry(fileName(AbsoluteName)), d->metaData)); if (file == CanonicalPathName) return entry.path(); -- cgit v0.12 From 3f5d522e7abe15abc97ef1aa27a33311d74f8312 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 13 Sep 2010 19:35:46 +0100 Subject: Fix for QFile::remove autotest After removing a file, invalidate the cached metadata to force any calls that require metadata to fetch it from the file system. Reviewed-By: joao --- src/corelib/io/qfsfileengine_unix.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 418506c..1d1baf9 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -589,6 +589,7 @@ bool QFSFileEngine::remove() { Q_D(QFSFileEngine); bool ret = QFileSystemEngine::removeFile(d->fileEntry); + d->metaData.clear(); if (!ret) { #ifdef Q_OS_SYMBIAN //TODO: error reporting -- cgit v0.12 From 108eb5b7d21e24e48f214ea8f171fa97c0087167 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 13 Sep 2010 19:39:20 +0100 Subject: Fixed QFile::setSize on symbian Reviewed-By: joao --- src/corelib/io/qfsfileengine_unix.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 1d1baf9..2e9d10c 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -520,9 +520,9 @@ qint64 QFSFileEnginePrivate::nativePos() const #ifdef Q_OS_SYMBIAN if (symbianFile.SubSessionHandle()) { #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API - qint64 pos; + qint64 pos = 0; #else - TInt pos; + TInt pos = 0; #endif TInt err = symbianFile.Seek(ESeekCurrent, pos); if(err != KErrNone) { @@ -1028,7 +1028,7 @@ bool QFSFileEngine::setSize(qint64 size) TInt err = d->symbianFile.SetSize(size); ret = (err == KErrNone); } - if (d->fd != -1) + else if (d->fd != -1) ret = QT_FTRUNCATE(d->fd, size) == 0; else if (d->fh) ret = QT_FTRUNCATE(QT_FILENO(d->fh), size) == 0; -- cgit v0.12 From 3289a268d58181b22f7fe90669a7215bc2edc75a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 14 Sep 2010 18:01:50 +0100 Subject: Don't compute canonical paths when not needed This optimisation saves 20% on symbian recursive iteration, and should help on other OS when the FollowSymlinks flag is not specified for directory iteration. Reviewed-By: joao --- src/corelib/io/qdiriterator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 2e67bfd..582fb85 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -299,7 +299,8 @@ void QDirIteratorPrivate::checkAndPushDirectory(const QFileInfo &fileInfo) return; // Stop link loops - if (visitedLinks.contains(fileInfo.canonicalFilePath())) + if (!visitedLinks.isEmpty() && + visitedLinks.contains(fileInfo.canonicalFilePath())) return; pushDirectory(fileInfo); -- cgit v0.12 From ff5946f056c52d7851106ef9ba93e40129349d8d Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 15 Sep 2010 11:42:51 +0100 Subject: Disable symlink and memory mapped files tests on symbian Reviewed-By: joao --- tests/auto/qdir/tst_qdir.cpp | 4 +++- tests/auto/qfile/tst_qfile.cpp | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 9678868..0ea67c9 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -69,7 +69,7 @@ #endif #if defined(Q_OS_SYMBIAN) -// Open C in Symbian doesn't support symbolic links to directories +#define Q_NO_SYMLINKS #define Q_NO_SYMLINKS_TO_DIRS #endif @@ -597,6 +597,7 @@ void tst_QDir::entryList() expected.removeAll(".."); #endif +#ifndef Q_NO_SYMLINKS #if defined(Q_OS_WIN) // ### Sadly, this is a platform difference right now. QFile::link(SRCDIR "entryList/file", SRCDIR "entrylist/linktofile.lnk"); @@ -651,6 +652,7 @@ void tst_QDir::entryList() QFile::link("directory", SRCDIR "entrylist/linktodirectory.lnk"); QFile::link("nothing", SRCDIR "entrylist/brokenlink.lnk"); #endif +#endif //Q_NO_SYMLINKS #ifdef Q_WS_MAC if (qstrcmp(QTest::currentDataTag(), "unprintablenames") == 0) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index ee799f3..925bdec 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -1285,6 +1285,9 @@ static QString getWorkingDirectoryForLink(const QString &linkFileName) void tst_QFile::link() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian does not support links", SkipAll); +#endif QFile::remove("myLink.lnk"); QFileInfo info1("tst_qfile.cpp"); QVERIFY(QFile::link("tst_qfile.cpp", "myLink.lnk")); @@ -1324,6 +1327,9 @@ void tst_QFile::linkToDir() void tst_QFile::absolutePathLinkToRelativePath() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian does not support links", SkipAll); +#endif QFile::remove("myDir/test.txt"); QFile::remove("myDir/myLink.lnk"); QDir dir; @@ -1346,6 +1352,9 @@ void tst_QFile::absolutePathLinkToRelativePath() void tst_QFile::readBrokenLink() { +#if defined(Q_OS_SYMBIAN) + QSKIP("Symbian does not support links", SkipAll); +#endif QFile::remove("myLink2.lnk"); QFileInfo info1("file12"); #if defined(Q_OS_SYMBIAN) @@ -2753,6 +2762,10 @@ void tst_QFile::map() QFETCH(int, size); QFETCH(QFile::FileError, error); +#ifdef Q_OS_SYMBIAN + QSKIP("memory mapped files not supported on this platform", SkipAll); +#endif + QString fileName = QDir::currentPath() + '/' + "qfile_map_testfile"; #ifdef Q_WS_WINCE @@ -2874,6 +2887,10 @@ void tst_QFile::mapResource() QFETCH(int, size); QFETCH(QFile::FileError, error); +#ifdef Q_OS_SYMBIAN + QSKIP("memory mapped files not supported on this platform", SkipAll); +#endif + QFile file(fileName); uchar *memory = file.map(offset, size); QCOMPARE(file.error(), error); @@ -2898,6 +2915,11 @@ void tst_QFile::mapOpenMode() { QFETCH(int, openMode); static const qint64 fileSize = 4096; + +#ifdef Q_OS_SYMBIAN + QSKIP("memory mapped files not supported on this platform", SkipAll); +#endif + QByteArray pattern(fileSize, 'A'); QString fileName = QDir::currentPath() + '/' + "qfile_map_testfile"; -- cgit v0.12 From 55648bc7a197367e8bacb2334339025ffbb83647 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 15 Sep 2010 11:46:10 +0100 Subject: tst_qdir fixes 1. change the test case names in relativeFilePath_data so they are all unique. 2. enable the canonical path tests related to rootPath on all OS, which were previously added only for symbian/windows. Reviewed-By: joao --- tests/auto/qdir/tst_qdir.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 0ea67c9..554b685 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -815,11 +815,11 @@ void tst_QDir::canonicalPath_data() #endif QTest::newRow("nonexistant") << "testd" << QString(); + QTest::newRow("rootPath") << QDir::rootPath() << QDir::rootPath(); + QTest::newRow("rootPath + ./") << QDir::rootPath().append("./") << QDir::rootPath(); + QTest::newRow("rootPath + ../.. ") << QDir::rootPath().append("../..") << QDir::rootPath(); #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - QTest::newRow("drive:/") << QDir::rootPath() << QDir::rootPath(); QTest::newRow("drive:\\") << QDir::toNativeSeparators(QDir::rootPath()) << QDir::rootPath(); - QTest::newRow("drive:/./") << QDir::rootPath().append("./") << QDir::rootPath(); - QTest::newRow("drive:/../.. ") << QDir::rootPath().append("../..") << QDir::rootPath(); QTest::newRow("drive:\\.\\") << QDir::toNativeSeparators(QDir::rootPath().append("./")) << QDir::rootPath(); QTest::newRow("drive:\\..\\..") << QDir::toNativeSeparators(QDir::rootPath().append("../..")) << QDir::rootPath(); QTest::newRow("drive:") << QDir().canonicalPath().left(2) << QDir().canonicalPath(); @@ -1106,24 +1106,24 @@ void tst_QDir::relativeFilePath_data() QTest::newRow("14") << "C:/foo/bar" << "/ding/dong" << "../../ding/dong"; QTest::newRow("15") << "C:/foo/bar" << "D:/ding/dong" << "D:/ding/dong"; QTest::newRow("16") << "C:" << "C:/ding/dong" << "ding/dong"; - QTest::newRow("16") << "C:/" << "C:/ding/dong" << "ding/dong"; - QTest::newRow("17") << "C:" << "C:" << ""; - QTest::newRow("18") << "C:/" << "C:" << ""; - QTest::newRow("19") << "C:" << "C:/" << ""; - QTest::newRow("20") << "C:/" << "C:/" << ""; - QTest::newRow("17") << "C:" << "C:file.txt" << "file.txt"; - QTest::newRow("18") << "C:/" << "C:file.txt" << "file.txt"; - QTest::newRow("19") << "C:" << "C:/file.txt" << "file.txt"; - QTest::newRow("20") << "C:/" << "C:/file.txt" << "file.txt"; - QTest::newRow("21") << "C:" << "D:" << "D:"; - QTest::newRow("22") << "C:" << "D:/" << "D:/"; - QTest::newRow("23") << "C:/" << "D:" << "D:"; - QTest::newRow("24") << "C:/" << "D:/" << "D:/"; + QTest::newRow("17") << "C:/" << "C:/ding/dong" << "ding/dong"; + QTest::newRow("18") << "C:" << "C:" << ""; + QTest::newRow("19") << "C:/" << "C:" << ""; + QTest::newRow("20") << "C:" << "C:/" << ""; + QTest::newRow("21") << "C:/" << "C:/" << ""; + QTest::newRow("22") << "C:" << "C:file.txt" << "file.txt"; + QTest::newRow("23") << "C:/" << "C:file.txt" << "file.txt"; + QTest::newRow("24") << "C:" << "C:/file.txt" << "file.txt"; + QTest::newRow("25") << "C:/" << "C:/file.txt" << "file.txt"; + QTest::newRow("26") << "C:" << "D:" << "D:"; + QTest::newRow("27") << "C:" << "D:/" << "D:/"; + QTest::newRow("28") << "C:/" << "D:" << "D:"; + QTest::newRow("29") << "C:/" << "D:/" << "D:/"; # if !defined(Q_OS_SYMBIAN) - QTest::newRow("25") << "C:/foo/bar" << "//anotherHost/foo/bar" << "//anotherHost/foo/bar"; - QTest::newRow("26") << "//anotherHost/foo" << "//anotherHost/foo/bar" << "bar"; - QTest::newRow("27") << "//anotherHost/foo" << "bar" << "bar"; - QTest::newRow("28") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar"; + QTest::newRow("30") << "C:/foo/bar" << "//anotherHost/foo/bar" << "//anotherHost/foo/bar"; + QTest::newRow("31") << "//anotherHost/foo" << "//anotherHost/foo/bar" << "bar"; + QTest::newRow("32") << "//anotherHost/foo" << "bar" << "bar"; + QTest::newRow("33") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar"; # endif #endif } -- cgit v0.12 From 864c19e036017c32db9bf55edb38b992d2a5f962 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 15 Sep 2010 11:54:36 +0100 Subject: Change handle related tests in tst_qfile for symbian Getting a posix file handle from a natively opened QFile isn't supported so that part of the test is skipped. Reviewed-By: joao --- tests/auto/qfile/tst_qfile.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 925bdec..2524e6e 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -2503,10 +2503,11 @@ void tst_QFile::standarderror() void tst_QFile::handle() { -#ifndef Q_OS_WINCE + int fd; +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) QFile file(SRCDIR "tst_qfile.cpp"); QVERIFY(file.open(QIODevice::ReadOnly)); - int fd = int(file.handle()); + fd = int(file.handle()); QVERIFY(fd > 2); QCOMPARE(int(file.handle()), fd); char c = '\0'; @@ -2533,6 +2534,7 @@ void tst_QFile::handle() QCOMPARE(c, '*'); #endif + //test round trip of adopted stdio file handle QFile file2; FILE *fp = fopen(SRCDIR "tst_qfile.cpp", "r"); file2.open(fp, QIODevice::ReadOnly); @@ -2540,6 +2542,7 @@ void tst_QFile::handle() QCOMPARE(int(file2.handle()), int(fileno(fp))); fclose(fp); + //test round trip of adopted posix file handle #ifdef Q_OS_UNIX QFile file3; fd = QT_OPEN(SRCDIR "tst_qfile.cpp", QT_OPEN_RDONLY); @@ -2551,6 +2554,9 @@ void tst_QFile::handle() void tst_QFile::nativeHandleLeaks() { +#ifdef Q_OS_SYMBIAN + QSKIP("test assumptions invalid for symbian", SkipAll); +#else int fd1, fd2; #ifdef Q_OS_WIN @@ -2592,6 +2598,7 @@ void tst_QFile::nativeHandleLeaks() #ifdef Q_OS_WIN QCOMPARE( handle2, handle1 ); #endif +#endif } void tst_QFile::readEof_data() -- cgit v0.12 From 925194abd863057618f39dd1289e574dc2a34208 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 15 Sep 2010 13:38:12 +0200 Subject: Wrong size for directories on windows. We have to ignore the size returned by GetFileAttributeEx() for directories. Also dont use the size_ to check for error when stating for file size. Reviewed-by: Joao --- src/corelib/io/qfilesystemengine_win.cpp | 22 +++++++++++++++------- src/corelib/io/qfsfileengine_win.cpp | 3 +-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 2e9f94b..8526cf2 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -438,9 +438,13 @@ void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, bool setLi creationTime_ = findData.ftCreationTime; lastAccessTime_ = findData.ftLastAccessTime; lastWriteTime_ = findData.ftLastWriteTime; - size_ = findData.nFileSizeHigh; - size_ <<= 32; - size_ += findData.nFileSizeLow; + if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) { + size_ = 0; + } else { + size_ = findData.nFileSizeHigh; + size_ <<= 32; + size_ += findData.nFileSizeLow; + } knownFlagsMask |= Times | SizeAttribute; if (setLinkType) { knownFlagsMask |= LinkType; @@ -460,15 +464,19 @@ void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo) creationTime_ = fileInfo.ftCreationTime; lastAccessTime_ = fileInfo.ftLastAccessTime; lastWriteTime_ = fileInfo.ftLastWriteTime; - size_ = fileInfo.nFileSizeHigh; - size_ <<= 32; - size_ += fileInfo.nFileSizeLow; + if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) { + size_ = 0; + } else { + size_ = fileInfo.nFileSizeHigh; + size_ <<= 32; + size_ += fileInfo.nFileSizeLow; + } knownFlagsMask |= Times | SizeAttribute; } void QFileSystemEngine::clearWinStatData(QFileSystemMetaData &data) { - data.size_ = -1; + data.size_ = 0; data.fileAttribute_ = 0; } diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 2bf377a..dde499a 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -266,9 +266,8 @@ qint64 QFSFileEnginePrivate::nativeSize() const else filled = doStat(QFileSystemMetaData::SizeAttribute); - if (!filled || metaData.size() == -1) { + if (!filled) { thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno)); - return 0; } return metaData.size(); } -- cgit v0.12 From fd4463c07f577d9df212388062028f9119e19add Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 15 Sep 2010 14:59:38 +0200 Subject: Fix tst_QFileSystemEntry::getSetCheck() on windows. Updated the name of the data field. Reviewed-by: Joao --- tests/auto/qfilesystementry/tst_qfilesystementry.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index e00a214..49afab6 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -123,7 +123,7 @@ void tst_QFileSystemEntry::getSetCheck() QFETCH(QString, internalnativeFilePath); QFETCH(QString, filepath); QFETCH(QString, filename); - QFETCH(QString, basename); + QFETCH(QString, baseName); QFETCH(QString, completeBasename); QFETCH(QString, suffix); QFETCH(QString, completeSuffix); @@ -137,7 +137,7 @@ void tst_QFileSystemEntry::getSetCheck() QCOMPARE(entry1.completeSuffix(), completeSuffix); QCOMPARE(entry1.isAbsolute(), absolute); QCOMPARE(entry1.isRelative(), !absolute); - QCOMPARE(entry1.baseName(), basename); + QCOMPARE(entry1.baseName(), baseName); QCOMPARE(entry1.completeBaseName(), completeBasename); QFileSystemEntry entry2(nativeFilePath, QFileSystemEntry::FromNativePath()); @@ -150,7 +150,7 @@ void tst_QFileSystemEntry::getSetCheck() // the object shouldnot change nativeFilePath. QCOMPARE(entry2.nativeFilePath(), nativeFilePath); QCOMPARE(entry2.fileName(), filename); - QCOMPARE(entry2.baseName(), basename); + QCOMPARE(entry2.baseName(), baseName); QCOMPARE(entry2.completeBaseName(), completeBasename); } -- cgit v0.12 From 6bc165d0fbbc4704d87e59cc0795dc2769228dc3 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 15 Sep 2010 17:10:21 +0200 Subject: Implement QFileSystemIterator for windows. The search is implemented using FindFirstFileEx(). Following optimizations are done * Using large Fetch buffer on Windows 7 * Querying only the long file name * Querying for directories only, depending on QDir::Filters Reviewed-by: Joao --- qmake/Makefile.win32 | 5 - qmake/Makefile.win32-g++ | 4 - qmake/Makefile.win32-g++-sh | 4 - qmake/qmake.pri | 2 +- src/corelib/io/io.pri | 1 - src/corelib/io/qfilesystemiterator_p.h | 6 + src/corelib/io/qfilesystemiterator_win.cpp | 84 ++++++++++++- src/corelib/io/qfsfileengine_iterator.cpp | 20 ---- src/corelib/io/qfsfileengine_iterator_p.h | 10 -- src/corelib/io/qfsfileengine_iterator_win.cpp | 162 -------------------------- src/tools/bootstrap/bootstrap.pro | 1 - tools/configure/configure.pro | 1 - tools/qtestlib/wince/cetest/bootstrapped.pri | 1 - 13 files changed, 87 insertions(+), 214 deletions(-) delete mode 100644 src/corelib/io/qfsfileengine_iterator_win.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index fa17b9d..906d284 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -104,7 +104,6 @@ QTOBJS= \ qtemporaryfile.obj \ qabstractfileengine.obj \ qfsfileengine_win.obj \ - qfsfileengine_iterator_win.obj \ qfileinfo.obj \ qglobal.obj \ qhash.obj \ @@ -161,7 +160,6 @@ clean:: -del qtemporaryfile.obj -del qabstractfileengine.obj -del qfsfileengine_win.obj - -del qfsfileengine_iterator_win.obj -del qfileinfo.obj -del qglobal.obj -del qhash.obj @@ -333,9 +331,6 @@ qfilesystemiterator_win.obj: $(SOURCE_PATH)\src\corelib\io\qfilesystemiterator_w qfsfileengine_win.obj: $(SOURCE_PATH)\src\corelib\io\qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfsfileengine_win.cpp -qfsfileengine_iterator_win.obj: $(SOURCE_PATH)\src\corelib\io\qfsfileengine_iterator_win.cpp - $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfsfileengine_iterator_win.cpp - qfsfileengine.obj: $(SOURCE_PATH)\src\corelib\io\qfsfileengine.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)\src\corelib\io\qfsfileengine.cpp diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index 57ea3d5..2bab255 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -68,7 +68,6 @@ QTOBJS= \ qfsfileengine.o \ qfsfileengine_iterator.o \ qfsfileengine_win.o \ - qfsfileengine_iterator_win.o \ qglobal.o \ qhash.o \ qiodevice.o \ @@ -211,9 +210,6 @@ qfilesystemiterator_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win qfsfileengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp -qfsfileengine_iterator_win.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_win.cpp - $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_win.cpp - qfsfileengine.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index 33deb01..db78933 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -67,7 +67,6 @@ QTOBJS= \ qfsfileengine.o \ qfsfileengine_iterator.o \ qfsfileengine_win.o \ - qfsfileengine_iterator_win.o \ qglobal.o \ qhash.o \ qiodevice.o \ @@ -206,9 +205,6 @@ qfilesystemiterator_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemiterator_win qfsfileengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_win.cpp -qfsfileengine_iterator_win.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_win.cpp - $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine_iterator_win.cpp - qfsfileengine.o: $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfsfileengine.cpp diff --git a/qmake/qmake.pri b/qmake/qmake.pri index cd81c82..1d35183 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -135,7 +135,7 @@ bootstrap { #Qt code LIBS += -framework ApplicationServices } } else:win32 { - SOURCES += qfilesystemengine_win.cpp qfsfileengine_win.cpp qfilesystemiterator_win.cpp qfsfileengine_iterator_win.cpp qsettings_win.cpp + SOURCES += qfilesystemengine_win.cpp qfsfileengine_win.cpp qfilesystemiterator_win.cpp qsettings_win.cpp win32-msvc*:LIBS += ole32.lib advapi32.lib win32-g++*:LIBS += -lole32 -luuid } diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 4a2f042..9d209ea 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -65,7 +65,6 @@ win32 { SOURCES += io/qprocess_win.cpp SOURCES += io/qfsfileengine_win.cpp - SOURCES += io/qfsfileengine_iterator_win.cpp SOURCES += io/qfilesystemwatcher_win.cpp HEADERS += io/qfilesystemwatcher_win_p.h HEADERS += io/qwindowspipewriter_p.h diff --git a/src/corelib/io/qfilesystemiterator_p.h b/src/corelib/io/qfilesystemiterator_p.h index d3b195d..66f4b1e 100644 --- a/src/corelib/io/qfilesystemiterator_p.h +++ b/src/corelib/io/qfilesystemiterator_p.h @@ -86,6 +86,12 @@ private: // Platform-specific data #if defined(Q_OS_WIN) + QFileSystemEntry::NativePath dirPath; + HANDLE findFileHandle; + QStringList uncShares; + bool uncFallback; + int uncShareIndex; + bool onlyDirs; #elif defined (Q_OS_SYMBIAN) RDir dirHandle; TEntryArray entries; diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 3c73496..373a50a 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -40,26 +40,102 @@ ****************************************************************************/ #include "qfilesystemiterator_p.h" +#include "qfilesystemengine_p.h" +#include "qplatformdefs.h" QT_BEGIN_NAMESPACE +bool done = true; + QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters, const QStringList &nameFilters, QDirIterator::IteratorFlags flags) + : nativePath(entry.nativeFilePath()) + , dirPath(entry.filePath()) + , findFileHandle(INVALID_HANDLE_VALUE) + , uncFallback(false) + , uncShareIndex(0) + , onlyDirs(false) { - Q_UNUSED(entry) - Q_UNUSED(filters) Q_UNUSED(nameFilters) Q_UNUSED(flags) + if (nativePath.endsWith(QLatin1String(".lnk"))) { + QFileSystemMetaData metaData; + QFileSystemEntry link = QFileSystemEngine::getLinkTarget(entry, metaData); + nativePath = link.nativeFilePath(); + } + if (!nativePath.endsWith(QLatin1Char('\\'))) + nativePath.append(QLatin1Char('\\')); + nativePath.append(QLatin1Char('*')); + if (!dirPath.endsWith(QLatin1Char('//'))) + dirPath.append(QLatin1Char('//')); + if ((filters & (QDir::Dirs|QDir::Drives)) && (!(filters & (QDir::Files)))) + onlyDirs = true; } QFileSystemIterator::~QFileSystemIterator() { + if (findFileHandle != INVALID_HANDLE_VALUE) + FindClose(findFileHandle); } bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) { - Q_UNUSED(fileEntry) - Q_UNUSED(metaData) + bool haveData = false; + WIN32_FIND_DATA findData; + + if (findFileHandle == INVALID_HANDLE_VALUE && !uncFallback) { + haveData = true; + DWORD dwAdditionalFlags = 0; + if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) + dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH + int searchOps = 0; // FindExSearchNameMatch + if (onlyDirs) + searchOps = 1 ; // FindExSearchLimitToDirectories +#if !defined(Q_OS_WINCE) + int infoLevel = 1 ; // FindExInfoBasic; +#else + int infoLevel = 0; // FindExInfoStandard; +#endif + findFileHandle = FindFirstFileEx((const wchar_t *)nativePath.utf16(), FINDEX_INFO_LEVELS(infoLevel), &findData, + FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags); + if (findFileHandle == INVALID_HANDLE_VALUE) { + if (nativePath.startsWith(QLatin1String("\\\\?\\UNC\\"))) { + QStringList parts = nativePath.split(QLatin1Char('\\'), QString::SkipEmptyParts); + if (parts.count() == 4 && QFileSystemEngine::uncListSharesOnServer( + QLatin1String("\\\\") + parts.at(2), &uncShares)) { + if (uncShares.isEmpty()) + return false; // No shares found in the server + else + uncFallback = true; + } + } + } + } + if (findFileHandle == INVALID_HANDLE_VALUE && !uncFallback) + return false; + // Retrieve the new file information. + if (!haveData) { + if (uncFallback) { + if (++uncShareIndex >= uncShares.count()) + return false; + } else { + if (!FindNextFile(findFileHandle, &findData)) + return false; + } + } + // Create the new file system entry & meta data. + if (uncFallback) { + fileEntry = QFileSystemEntry(dirPath + uncShares.at(uncShareIndex)); + metaData.fillFromFileAttribute(FILE_ATTRIBUTE_DIRECTORY); + return true; + } else { + QString fileName = QString::fromWCharArray(findData.cFileName); + fileEntry = QFileSystemEntry(dirPath + fileName); + if (!fileName.endsWith(QLatin1String(".lnk"))) { + metaData.fillFromFindData(findData, true); + } + return true; + } return false; } diff --git a/src/corelib/io/qfsfileengine_iterator.cpp b/src/corelib/io/qfsfileengine_iterator.cpp index 4617f49..f6f08c7 100644 --- a/src/corelib/io/qfsfileengine_iterator.cpp +++ b/src/corelib/io/qfsfileengine_iterator.cpp @@ -49,23 +49,14 @@ QT_BEGIN_NAMESPACE QFSFileEngineIterator::QFSFileEngineIterator(QDir::Filters filters, const QStringList &filterNames) : QAbstractFileEngineIterator(filters, filterNames) -#ifdef Q_OS_UNIX , done(false) -#endif { -#ifndef Q_OS_UNIX - newPlatformSpecifics(); -#endif } QFSFileEngineIterator::~QFSFileEngineIterator() { -#ifndef Q_OS_UNIX - deletePlatformSpecifics(); -#endif } -#ifdef Q_OS_UNIX bool QFSFileEngineIterator::hasNext() const { if (!done && !nativeIterator) { @@ -76,7 +67,6 @@ bool QFSFileEngineIterator::hasNext() const return !done; } -#endif QString QFSFileEngineIterator::next() { @@ -87,7 +77,6 @@ QString QFSFileEngineIterator::next() return currentFilePath(); } -#ifdef Q_OS_UNIX void QFSFileEngineIterator::advance() const { currentInfo = nextInfo; @@ -101,24 +90,15 @@ void QFSFileEngineIterator::advance() const nativeIterator.reset(); } } -#endif QString QFSFileEngineIterator::currentFileName() const { -#ifdef Q_OS_UNIX return currentInfo.fileName(); -#else - return currentEntry; -#endif } QFileInfo QFSFileEngineIterator::currentFileInfo() const { -#ifdef Q_OS_UNIX return currentInfo; -#else - return QAbstractFileEngineIterator::currentFileInfo(); -#endif } QT_END_NAMESPACE diff --git a/src/corelib/io/qfsfileengine_iterator_p.h b/src/corelib/io/qfsfileengine_iterator_p.h index 7940fbd..ac9598d 100644 --- a/src/corelib/io/qfsfileengine_iterator_p.h +++ b/src/corelib/io/qfsfileengine_iterator_p.h @@ -77,21 +77,11 @@ public: QFileInfo currentFileInfo() const; private: -#ifdef Q_OS_UNIX void advance() const; mutable QScopedPointer nativeIterator; mutable QFileInfo currentInfo; mutable QFileInfo nextInfo; mutable bool done; -#else - QFSFileEngineIteratorPlatformSpecificData *platform; - friend class QFSFileEngineIteratorPlatformSpecificData; - void newPlatformSpecifics(); - void deletePlatformSpecifics(); - void advance(); - - QString currentEntry; -#endif }; QT_END_NAMESPACE diff --git a/src/corelib/io/qfsfileengine_iterator_win.cpp b/src/corelib/io/qfsfileengine_iterator_win.cpp deleted file mode 100644 index d4e6f5a..0000000 --- a/src/corelib/io/qfsfileengine_iterator_win.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qfsfileengine_iterator_p.h" -#include "qfsfileengine_p.h" -#include "qfilesystemengine_p.h" -#include "qplatformdefs.h" - -#include - -QT_BEGIN_NAMESPACE - -class QFSFileEngineIteratorPlatformSpecificData -{ -public: - inline QFSFileEngineIteratorPlatformSpecificData() - : uncShareIndex(-1), findFileHandle(INVALID_HANDLE_VALUE), - done(false), uncFallback(false) - {} - - QFSFileEngineIterator *it; - - QStringList uncShares; - int uncShareIndex; - - HANDLE findFileHandle; - WIN32_FIND_DATA findData; - bool done; - bool uncFallback; - - void saveCurrentFileName(); -}; - -void QFSFileEngineIteratorPlatformSpecificData::saveCurrentFileName() -{ - if (uncFallback) { - // Windows share / UNC path - it->currentEntry = uncShares.at(uncShareIndex - 1); - } else { - // Local directory - it->currentEntry = QString::fromWCharArray(findData.cFileName); - } -} - -void QFSFileEngineIterator::advance() -{ - platform->saveCurrentFileName(); - - if (platform->done) - return; - - if (platform->uncFallback) { - ++platform->uncShareIndex; - } else if (platform->findFileHandle != INVALID_HANDLE_VALUE) { - if (!FindNextFile(platform->findFileHandle, &platform->findData)) { - platform->done = true; - FindClose(platform->findFileHandle); - } - } -} - -void QFSFileEngineIterator::newPlatformSpecifics() -{ - platform = new QFSFileEngineIteratorPlatformSpecificData; - platform->it = this; -} - -void QFSFileEngineIterator::deletePlatformSpecifics() -{ - delete platform; - platform = 0; -} - -bool QFSFileEngineIterator::hasNext() const -{ - if (platform->done) - return false; - - if (platform->uncFallback) - return platform->uncShareIndex > 0 && platform->uncShareIndex <= platform->uncShares.size(); - - if (platform->findFileHandle == INVALID_HANDLE_VALUE) { - QString path = this->path(); - // Local directory - if (path.endsWith(QLatin1String(".lnk"))) - path = QFileInfo(path).readLink(); - - if (!path.endsWith(QLatin1Char('/'))) - path.append(QLatin1Char('/')); - path.append(QLatin1String("*.*")); - - QString fileName = QFSFileEnginePrivate::longFileName(path); - platform->findFileHandle = FindFirstFile((const wchar_t *)fileName.utf16(), &platform->findData); - - if (platform->findFileHandle == INVALID_HANDLE_VALUE) { - if (path.startsWith(QLatin1String("//"))) { - path = this->path(); - // UNC - QStringList parts = QDir::toNativeSeparators(path).split(QLatin1Char('\\'), QString::SkipEmptyParts); - - if (parts.count() == 1 && QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(0), - &platform->uncShares)) { - if (platform->uncShares.isEmpty()) { - platform->done = true; - } else { - platform->uncShareIndex = 1; - } - platform->uncFallback = true; - } else { - platform->done = true; - } - } else { - platform->done = true; - } - } - - if (!platform->done && (!platform->uncFallback || !platform->uncShares.isEmpty())) - platform->saveCurrentFileName(); - } - - return !platform->done; -} - -QT_END_NAMESPACE diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 81b785a..179cb0b 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -92,7 +92,6 @@ unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \ win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ ../../corelib/io/qfilesystemiterator_win.cpp \ ../../corelib/io/qfsfileengine_win.cpp \ - ../../corelib/io/qfsfileengine_iterator_win.cpp macx: { QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 #enables weak linking for 10.4 (exported) diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro index fe1b028..6450038 100644 --- a/tools/configure/configure.pro +++ b/tools/configure/configure.pro @@ -97,7 +97,6 @@ SOURCES = main.cpp configureapp.cpp environment.cpp tools.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qiodevice.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qtextstream.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.cpp \ diff --git a/tools/qtestlib/wince/cetest/bootstrapped.pri b/tools/qtestlib/wince/cetest/bootstrapped.pri index 76245b0..56c8ab7 100644 --- a/tools/qtestlib/wince/cetest/bootstrapped.pri +++ b/tools/qtestlib/wince/cetest/bootstrapped.pri @@ -12,7 +12,6 @@ SOURCES += \ $$QT_SOURCE_TREE/src/corelib/io/qabstractfileengine.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator.cpp \ - $$QT_SOURCE_TREE/src/corelib/io/qfsfileengine_iterator_win.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qfileinfo.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qtemporaryfile.cpp \ $$QT_SOURCE_TREE/src/corelib/io/qdiriterator.cpp \ -- cgit v0.12 From 5e2fc1468572098cd02df25061f277b60e9b35bd Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 15 Sep 2010 17:48:39 +0100 Subject: Integrate media use case performance tests to qdir tree benchmarks These tests measure the performance of QDirIterator across: - 1000 files in one directory (based on photos) - 1000 files as 100 directories each with 10 files (based on music albums) The test counts and totals the sizes of files, to make sure this isn't causing unwanted filesystem accesses. Reviewed-By: joao --- .../corelib/io/qdir/tree/bench_qdir_tree.cpp | 52 +++++++++++++++++++++- tests/shared/filesystem.h | 10 +++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp index cbe931d..81a1262 100644 --- a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp +++ b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp @@ -55,12 +55,20 @@ class bench_QDir_tree public: bench_QDir_tree() - : prefix("./test-tree/") + : prefix("./test-tree/"), + musicprefix(QLatin1String("music")), + photoprefix(QLatin1String("photos")), + musicsize(0), + photosize(0) { } private: QByteArray prefix; + QString musicprefix; + QString photoprefix; + qint64 musicsize; + qint64 photosize; private slots: void initTestCase() @@ -105,6 +113,23 @@ private slots: line.clear(); } + + //Use case: music collection - 10 files in 100 directories (albums) + QVERIFY(fs.createDirectory(musicprefix)); + for (int i=0;i<1000;i++) { + if ((i % 10) == 0) + QVERIFY(fs.createDirectory(QString("%1/directory%2").arg(musicprefix).arg(i/10))); + qint64 size = fs.createFileWithContent(QString("%1/directory%2/file%3").arg(musicprefix).arg(i/10).arg(i)); + QVERIFY(size > 0); + musicsize += size; + } + //Use case: photos - 1000 files in 1 directory + QVERIFY(fs.createDirectory(photoprefix)); + for (int i=0;i<1000;i++) { + qint64 size = fs.createFileWithContent(QString("%1/file%2").arg(photoprefix).arg(i)); + QVERIFY(size > 0); + photosize += size; + } } void fileSearch_data() const @@ -166,6 +191,31 @@ private slots: QCOMPARE(count, 11963); } + void thousandFiles_data() const + { + QTest::addColumn("dirName"); + QTest::addColumn("expectedSize"); + QTest::newRow("music") << musicprefix << musicsize; + QTest::newRow("photos") << photoprefix << photosize; + } + + void thousandFiles() const + { + QFETCH(QString, dirName); + QFETCH(qint64, expectedSize); + QBENCHMARK { + qint64 totalsize = 0; + int count = 0; + QDirIterator iter(dirName, QDir::Files, QDirIterator::Subdirectories); + while(iter.hasNext()) { + iter.next(); + count++; + totalsize += iter.fileInfo().size(); + } + QCOMPARE(count, 1000); + QCOMPARE(totalsize, expectedSize); + } + } private: FileSystem fs; }; diff --git a/tests/shared/filesystem.h b/tests/shared/filesystem.h index 079a6dc..8274346 100644 --- a/tests/shared/filesystem.h +++ b/tests/shared/filesystem.h @@ -87,6 +87,16 @@ struct FileSystem return false; } + qint64 createFileWithContent(const QString &fileName) + { + QFile file(fileName); + if (file.open(QIODevice::WriteOnly)) { + createdFiles << fileName; + return file.write(fileName.toUtf8()); + } + return -1; + } + bool createLink(const QString &destination, const QString &linkName) { if (QFile::link(destination, linkName)) { -- cgit v0.12 From 81c2b37cbcd2f0432d3036765d6b1d0cdaa4872a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 15 Sep 2010 18:01:12 +0100 Subject: On symbian, set the "execute" permission for directories This is the same as the windows port does for non NTFS drives. For files, execute permission is set to false, as the /sys/bin directory is not listable by normal applications. Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 9b81571..02b4c48 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -171,13 +171,13 @@ void QFileSystemMetaData::fillFromTEntry(const TEntry& entry) entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); knownFlagsMask |= QFileSystemMetaData::SymbianTEntryFlags; //Symbian doesn't have unix type file permissions - entryFlags |= QFileSystemMetaData::Permissions; - if(entry.IsReadOnly()) { - entryFlags &= ~(QFileSystemMetaData::WritePermissions); + entryFlags |= QFileSystemMetaData::ReadPermissions; + if(!entry.IsReadOnly()) { + entryFlags |= QFileSystemMetaData::WritePermissions; } //set the type if(entry.IsDir()) - entryFlags |= QFileSystemMetaData::DirectoryType; + entryFlags |= (QFileSystemMetaData::DirectoryType | QFileSystemMetaData::ExecutePermissions); else entryFlags |= QFileSystemMetaData::FileType; -- cgit v0.12 From 6437e4083bf088a3a67660d7b015de8647557609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 15 Sep 2010 19:28:48 +0200 Subject: Fix typo --- src/corelib/io/qfilesystemengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 6d8b3ff..6290d68 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -193,7 +193,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, } //static -QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, , QFileSystemMetaData &data) +QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data) { if (entry.isEmpty() || entry.isRoot()) return entry; -- cgit v0.12 From 6f716cbdc8a054d2bedc0ffa2bb3a48c12e24695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 16 Sep 2010 11:31:19 +0200 Subject: Fix QSettings auto test to use QTRY_VERIFY ... instead of relying on qApp->processEvents. Reviewed-by: Olivier Goffart --- tests/auto/qsettings/tst_qsettings.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp index 058a750..48c5fd1 100644 --- a/tests/auto/qsettings/tst_qsettings.cpp +++ b/tests/auto/qsettings/tst_qsettings.cpp @@ -51,6 +51,7 @@ #include #include #include +#include "../../shared/util.h" #if !defined(Q_OS_SYMBIAN) # include @@ -1719,26 +1720,22 @@ void tst_QSettings::testUpdateRequestEvent() settings1.setValue("key1", 1); QVERIFY(QFileInfo("foo").size() == 0); - qApp->processEvents(); - QVERIFY(QFileInfo("foo").size() > 0); + QTRY_VERIFY(QFileInfo("foo").size() > 0); settings1.remove("key1"); QVERIFY(QFileInfo("foo").size() > 0); - qApp->processEvents(); - QVERIFY(QFileInfo("foo").size() == 0); + QTRY_VERIFY(QFileInfo("foo").size() == 0); settings1.setValue("key2", 2); QVERIFY(QFileInfo("foo").size() == 0); - qApp->processEvents(); - QVERIFY(QFileInfo("foo").size() > 0); + QTRY_VERIFY(QFileInfo("foo").size() > 0); settings1.clear(); QVERIFY(QFileInfo("foo").size() > 0); - qApp->processEvents(); - QVERIFY(QFileInfo("foo").size() == 0); + QTRY_VERIFY(QFileInfo("foo").size() == 0); } const int NumIterations = 5; -- cgit v0.12 From 4d45a868536a235b33029115a70795119b8f3822 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 16 Sep 2010 11:34:23 +0100 Subject: integrate "source" use case to bench_qdir_tree Although there's already some real source (4.6.0 file list) in the test, we decided it's useful to still have this benchmark for a standard directory structure in the 1000 file test. The source benchmark is 10 directories, each containing 10 subdirectories, which each contain 10 files. --- .../corelib/io/qdir/tree/bench_qdir_tree.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp index 81a1262..84922f6 100644 --- a/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp +++ b/tests/benchmarks/corelib/io/qdir/tree/bench_qdir_tree.cpp @@ -58,8 +58,10 @@ public: : prefix("./test-tree/"), musicprefix(QLatin1String("music")), photoprefix(QLatin1String("photos")), + sourceprefix(QLatin1String("source")), musicsize(0), - photosize(0) + photosize(0), + sourcesize(0) { } @@ -67,8 +69,10 @@ private: QByteArray prefix; QString musicprefix; QString photoprefix; + QString sourceprefix; qint64 musicsize; qint64 photosize; + qint64 sourcesize; private slots: void initTestCase() @@ -130,6 +134,17 @@ private slots: QVERIFY(size > 0); photosize += size; } + //Use case: source - 10 files in 10 subdirectories in 10 directories (1000 total) + QVERIFY(fs.createDirectory(sourceprefix)); + for (int i=0;i<1000;i++) { + if ((i % 100) == 0) + QVERIFY(fs.createDirectory(QString("%1/directory%2").arg(sourceprefix).arg(i/100))); + if ((i % 10) == 0) + QVERIFY(fs.createDirectory(QString("%1/directory%2/subdirectory%3").arg(sourceprefix).arg(i/100).arg(i/10))); + qint64 size = fs.createFileWithContent(QString("%1/directory%2/subdirectory%3/file%4").arg(sourceprefix).arg(i/100).arg(i/10).arg(i)); + QVERIFY(size > 0); + sourcesize += size; + } } void fileSearch_data() const @@ -197,6 +212,7 @@ private slots: QTest::addColumn("expectedSize"); QTest::newRow("music") << musicprefix << musicsize; QTest::newRow("photos") << photoprefix << photosize; + QTest::newRow("src") << sourceprefix << sourcesize; } void thousandFiles() const -- cgit v0.12 From 186bcd5f6f65ce4d52b2e9cd0c25caba0ae66eda Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 15 Sep 2010 14:44:58 +0200 Subject: Remove stale comment --- src/corelib/io/qfileinfo.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 4f5a4ab..471da2e 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -397,7 +397,6 @@ bool QFileInfo::operator==(const QFileInfo &fileinfo) const return false; sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive; - // if both are native just compare the canonicalFilePath of both. } else { if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive()) return false; -- cgit v0.12 From b9b55234a777c3b206332bafbe227e1355ca9186 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 15 Sep 2010 14:44:38 +0200 Subject: Make QDir use QFileSystemEngine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The creation of a QAbstractFileEngine derived class will now be avoided if the dir we are watching is on the native file system and from then on all access will be through the direct API Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 183 ++++++++++++++++++++++++++++++------------------ 1 file changed, 114 insertions(+), 69 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 8c99226..efc0ba9 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -53,6 +53,10 @@ #include "qvector.h" #include "qalgorithms.h" #include "qvarlengtharray.h" +#include "qfilesystementry_p.h" +#include "qfilesystemmetadata_p.h" +#include "qfilesystemengine_p.h" +#include #ifdef QT_BUILD_CORE_LIB # include "qresource.h" @@ -117,7 +121,6 @@ public: QDirPrivate(const QDirPrivate ©) : QSharedData(copy) - , path(copy.path) , nameFilters(copy.nameFilters) , sort(copy.sort) , filters(copy.filters) @@ -126,11 +129,19 @@ public: , matchAllDirs(copy.matchAllDirs) #endif , fileListsInitialized(false) + , dirEntry(copy.dirEntry) + , metaData(copy.metaData) { } bool exists() const { + if (fileEngine.isNull()) { + if (!metaData.hasFlags(QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType)) + QFileSystemEngine::fillMetaData(dirEntry, metaData, + QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); + return metaData.exists() && metaData.isDirectory(); + } const QAbstractFileEngine::FileFlags info = fileEngine->fileFlags(QAbstractFileEngine::DirectoryType | QAbstractFileEngine::ExistsFlag @@ -141,7 +152,7 @@ public: } void initFileEngine(); - void initFileLists() const; + void initFileLists(const QDir &dir) const; static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *); @@ -174,21 +185,32 @@ public: p.truncate(p.length() - 1); } - path = p; + dirEntry = QFileSystemEntry(p); initFileEngine(); - - // set the path to be the qt friendly version so then we can operate on it using just / - path = fileEngine->fileName(QAbstractFileEngine::DefaultName); clearFileLists(); + absoluteDirEntry = QFileSystemEntry(); } - inline void clearFileLists() { + inline void clearFileLists() + { fileListsInitialized = false; files.clear(); fileInfos.clear(); } - QString path; + inline void resolveAbsoluteEntry() const + { + if (!absoluteDirEntry.isEmpty() || dirEntry.isEmpty()) + return; + + if (dirEntry.isRelative()) { + QFileSystemEntry answer = QFileSystemEngine::absoluteName(dirEntry); + absoluteDirEntry = QFileSystemEntry(QDir::cleanPath(answer.filePath())); + } else { + absoluteDirEntry = dirEntry; + } + } + QStringList nameFilters; QDir::SortFlags sort; QDir::Filters filters; @@ -203,6 +225,10 @@ public: mutable bool fileListsInitialized; mutable QStringList files; mutable QFileInfoList fileInfos; + + QFileSystemEntry dirEntry; + mutable QFileSystemEntry absoluteDirEntry; + mutable QFileSystemMetaData metaData; }; /* For sorting */ @@ -316,11 +342,11 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, } } -inline void QDirPrivate::initFileLists() const +inline void QDirPrivate::initFileLists(const QDir &dir) const { if (!fileListsInitialized) { QFileInfoList l; - QDirIterator it(path, nameFilters, filters); + QDirIterator it(dir); while (it.hasNext()) { it.next(); l.append(it.fileInfo()); @@ -332,7 +358,7 @@ inline void QDirPrivate::initFileLists() const inline void QDirPrivate::initFileEngine() { - fileEngine.reset(QAbstractFileEngine::create(path)); + fileEngine.reset(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(dirEntry, metaData)); } /*! @@ -597,7 +623,7 @@ void QDir::setPath(const QString &path) QString QDir::path() const { const QDirPrivate* d = d_ptr.constData(); - return d->path; + return d->dirEntry.filePath(); } /*! @@ -611,10 +637,8 @@ QString QDir::path() const QString QDir::absolutePath() const { const QDirPrivate* d = d_ptr.constData(); - QString ret = d->path; - if (QDir::isRelativePath(ret)) - ret = absoluteFilePath(QString::fromLatin1("")); - return cleanPath(ret); + d->resolveAbsoluteEntry(); + return d->absoluteDirEntry.filePath(); } /*! @@ -635,7 +659,12 @@ QString QDir::absolutePath() const */ QString QDir::canonicalPath() const { - return cleanPath(d_ptr->fileEngine->fileName(QAbstractFileEngine::CanonicalName)); + const QDirPrivate* d = d_ptr.constData(); + if (d->fileEngine.isNull()) { + QFileSystemEntry answer = QFileSystemEngine::canonicalName(d->dirEntry, d->metaData); + return answer.filePath(); + } + return d->fileEngine->fileName(QAbstractFileEngine::CanonicalName); } /*! @@ -652,10 +681,7 @@ QString QDir::canonicalPath() const QString QDir::dirName() const { const QDirPrivate* d = d_ptr.constData(); - int pos = d->path.lastIndexOf(QLatin1Char('/')); - if (pos == -1) - return d->path; - return d->path.mid(pos + 1); + return d->dirEntry.fileName(); } /*! @@ -673,7 +699,7 @@ QString QDir::filePath(const QString &fileName) const if (isAbsolutePath(fileName)) return QString(fileName); - QString ret = d->path; + QString ret = d->dirEntry.filePath(); if (!fileName.isEmpty()) { if (!ret.isEmpty() && ret[(int)ret.length()-1] != QLatin1Char('/') && fileName[0] != QLatin1Char('/')) ret += QLatin1Char('/'); @@ -696,22 +722,12 @@ QString QDir::absoluteFilePath(const QString &fileName) const if (isAbsolutePath(fileName)) return fileName; - QString ret; -#ifndef QT_NO_FSFILEENGINE - if (isRelativePath(d->path)) //get pwd - ret = QFSFileEngine::currentPath(fileName); -#endif - if (!d->path.isEmpty() && d->path != QLatin1String(".")) { - if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) - ret += QLatin1Char('/'); - ret += d->path; - } - if (!fileName.isEmpty()) { - if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/'))) - ret += QLatin1Char('/'); - ret += fileName; - } - return ret; + d->resolveAbsoluteEntry(); + if (fileName.isEmpty()) + return d->absoluteDirEntry.filePath(); + if (!d->absoluteDirEntry.isRoot()) + return d->absoluteDirEntry.filePath() % QLatin1Char('/') % fileName; + return d->absoluteDirEntry.filePath() % fileName; } /*! @@ -857,21 +873,22 @@ bool QDir::cd(const QString &dirName) if (dirName.isEmpty() || dirName == QLatin1String(".")) return true; - QString newPath = d->path; + QString newPath; if (isAbsolutePath(dirName)) { newPath = cleanPath(dirName); } else { if (isRoot()) { if (dirName == QLatin1String("..")) return false; + newPath = d->dirEntry.filePath(); } else { - newPath += QLatin1Char('/'); + newPath = d->dirEntry.filePath() % QLatin1Char('/'); } newPath += dirName; if (dirName.indexOf(QLatin1Char('/')) >= 0 - || d->path == QLatin1String(".") - || dirName == QLatin1String("..")) { + || dirName == QLatin1String("..") + || d->dirEntry.filePath() == QLatin1String(".")) { newPath = cleanPath(newPath); /* If newPath starts with .., we convert it to absolute to @@ -889,7 +906,6 @@ bool QDir::cd(const QString &dirName) QScopedPointer dir(new QDirPrivate(*d_ptr.constData())); dir->setPath(newPath); - if (!dir->exists()) return false; @@ -1202,7 +1218,7 @@ void QDir::setSorting(SortFlags sort) uint QDir::count() const { const QDirPrivate* d = d_ptr.constData(); - d->initFileLists(); + d->initFileLists(*this); return d->files.count(); } @@ -1216,7 +1232,7 @@ uint QDir::count() const QString QDir::operator[](int pos) const { const QDirPrivate* d = d_ptr.constData(); - d->initFileLists(); + d->initFileLists(*this); return d->files[pos]; } @@ -1299,12 +1315,12 @@ QStringList QDir::entryList(const QStringList &nameFilters, Filters filters, sort = d->sort; if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) { - d->initFileLists(); + d->initFileLists(*this); return d->files; } QFileInfoList l; - QDirIterator it(d->path, nameFilters, filters); + QDirIterator it(d->dirEntry.filePath(), nameFilters, filters); while (it.hasNext()) { it.next(); l.append(it.fileInfo()); @@ -1345,12 +1361,12 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter sort = d->sort; if (filters == d->filters && sort == d->sort && nameFilters == d->nameFilters) { - d->initFileLists(); + d->initFileLists(*this); return d->fileInfos; } QFileInfoList l; - QDirIterator it(d->path, nameFilters, filters); + QDirIterator it(d->dirEntry.filePath(), nameFilters, filters); while (it.hasNext()) { it.next(); l.append(it.fileInfo()); @@ -1377,6 +1393,8 @@ bool QDir::mkdir(const QString &dirName) const } QString fn = filePath(dirName); + if (d->fileEngine.isNull()) + return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), false); return d->fileEngine->mkdir(fn, false); } @@ -1399,6 +1417,9 @@ bool QDir::rmdir(const QString &dirName) const } QString fn = filePath(dirName); + if (d->fileEngine.isNull()) + return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), false); + return d->fileEngine->rmdir(fn, false); } @@ -1422,6 +1443,8 @@ bool QDir::mkpath(const QString &dirPath) const } QString fn = filePath(dirPath); + if (d->fileEngine.isNull()) + return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), true); return d->fileEngine->mkdir(fn, true); } @@ -1446,6 +1469,8 @@ bool QDir::rmpath(const QString &dirPath) const } QString fn = filePath(dirPath); + if (d->fileEngine.isNull()) + return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), true); return d->fileEngine->rmdir(fn, true); } @@ -1462,6 +1487,13 @@ bool QDir::isReadable() const { const QDirPrivate* d = d_ptr.constData(); + if (d->fileEngine.isNull()) { + if (!d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission)) + QFileSystemEngine::fillMetaData(d->dirEntry, d->metaData, QFileSystemMetaData::UserReadPermission); + + return (d->metaData.permissions() & QFile::ReadUser) != 0; + } + const QAbstractFileEngine::FileFlags info = d->fileEngine->fileFlags(QAbstractFileEngine::DirectoryType | QAbstractFileEngine::PermsMask); @@ -1500,6 +1532,8 @@ bool QDir::exists() const */ bool QDir::isRoot() const { + if (d_ptr->fileEngine.isNull()) + return d_ptr->dirEntry.isRoot(); return d_ptr->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag; } @@ -1530,7 +1564,7 @@ bool QDir::isRoot() const */ bool QDir::isRelative() const { - return d_ptr->fileEngine->isRelativePath(); + return d_ptr->dirEntry.isRelative(); } @@ -1541,19 +1575,23 @@ bool QDir::isRelative() const \sa isAbsolute() isAbsolutePath() isRelative() cleanPath() */ -bool QDir::makeAbsolute() // ### What do the return values signify? +bool QDir::makeAbsolute() { - QString absolutePath = d_ptr.constData()->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); - if (QDir::isRelativePath(absolutePath)) - return false; - - QScopedPointer dir(new QDirPrivate(*d_ptr.constData())); - dir->setPath(absolutePath); - - if (!(dir->fileEngine->fileFlags(QAbstractFileEngine::TypesMask) & QAbstractFileEngine::DirectoryType)) - return false; + const QDirPrivate *d = d_ptr.constData(); + QScopedPointer dir; + if (!d->fileEngine.isNull()) { + QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); + if (QDir::isRelativePath(absolutePath)) + return false; - d_ptr = dir.take(); + dir.reset(new QDirPrivate(*d_ptr.constData())); + dir->setPath(absolutePath); + } else { // native FS + d->resolveAbsoluteEntry(); + dir.reset(new QDirPrivate(*d_ptr.constData())); + dir->setPath(d->absoluteDirEntry.filePath()); + } + d_ptr = dir.take(); // actually detach return true; } @@ -1573,17 +1611,24 @@ bool QDir::operator==(const QDir &dir) const if (d == other) return true; - if (d->fileEngine->caseSensitive() != other->fileEngine->caseSensitive()) - return false; + Qt::CaseSensitivity sensitive; + if (d->fileEngine.isNull() || other->fileEngine.isNull()) { + if (d->fileEngine.data() != other->fileEngine.data()) // one is native, the other is a custom file-engine + return false; + + sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive; + } else { + if (d->fileEngine->caseSensitive() != other->fileEngine->caseSensitive()) + return false; + sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive; + } + if (d->filters == other->filters && d->sort == other->sort && d->nameFilters == other->nameFilters) { - QString dir1 = absolutePath(), dir2 = dir.absolutePath(); - if (!other->fileEngine->caseSensitive()) - return (dir1.toLower() == dir2.toLower()); - - return (dir1 == dir2); - + d->resolveAbsoluteEntry(); + other->resolveAbsoluteEntry(); + return d->absoluteDirEntry.filePath().compare(other->absoluteDirEntry.filePath(), sensitive) == 0; } return false; } -- cgit v0.12 From 3df81c23e6ab7dae949315a4f0ca4e54469ab2bf Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 16 Sep 2010 16:02:01 +0100 Subject: Fix for QDir constructed with a path containing native separators. QFileSystemEntry's m_filePath should always contain a path with / as separator. Reviewed-By: Thomas Zander --- src/corelib/io/qdir.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index efc0ba9..a45c104 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -175,13 +175,15 @@ public: return ret; } - inline void setPath(QString p) + inline void setPath(const QString &path) { - if ((p.endsWith(QLatin1Char('/')) || p.endsWith(QLatin1Char('\\'))) - && p.length() > 1) { + QString p = QDir::fromNativeSeparators(path); + if (p.endsWith(QLatin1Char('/')) + && p.length() > 1 #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - if (!(p.length() == 3 && p.at(1) == QLatin1Char(':'))) + && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) #endif + ) { p.truncate(p.length() - 1); } -- cgit v0.12 From 206f49020bce11e142c4290b6655ac7c15592b43 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Fri, 17 Sep 2010 15:04:27 +0200 Subject: Differntiate different types of absolute paths on windows. QFileSystemEntry now differentiates between various types of absolute paths on Windows and Symbian. The new behavior is shown the table below. Anybody who uses this class should NOT treat that !isRelative() == isAbsolute(). The differentiation is puerly for internal use by the windows and symbian implementations of QFileSystemEngine. |============================================| |Filename isRelative isAbsolute | |============================================| | Somefile.txt 1 0 | | Some/file.txt 1 0 | | a:Somefile.txt 0 0 | | /Somefile.txt 0 0 | | a:/somefile.txt 0 1 | | //abc/somefile.txt 0 1 | |============================================| Reviewed-by: Joao Reviewed-by: Shane Kearns --- src/corelib/io/qfilesystemengine_symbian.cpp | 2 +- src/corelib/io/qfilesystemengine_win.cpp | 20 ++++----- src/corelib/io/qfilesystementry.cpp | 30 ++++++++++---- src/corelib/io/qfilesystementry_p.h | 4 +- .../auto/qfilesystementry/tst_qfilesystementry.cpp | 47 ++++++++++++++++++---- 5 files changed, 74 insertions(+), 29 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 02b4c48..b4f0f88 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -114,7 +114,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) const bool isDriveRelative = (orig.size() > 2 && orig.at(1).unicode() == ':' && orig.at(2).unicode() != '/'); const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) || orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/."))); - const bool isAbsolute = entry.isAbsolute(); + const bool isAbsolute = !entry.isRelative(); if (isAbsolute && !(needsDrive || isDriveLetter || isDriveRelative || isDirty)) return entry; diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 8526cf2..119ed7c 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -545,18 +545,18 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) if (!entry.isRelative()) { #if !defined(Q_OS_WINCE) - if (entry.filePath().startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt - entry.filePath().size() == 2 || // It's a drive letter that needs to get a working dir appended - (entry.filePath().size() > 2 && entry.filePath().at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt - entry.filePath().contains(QLatin1String("/../")) || entry.filePath().contains(QLatin1String("/./")) || - entry.filePath().endsWith(QLatin1String("/..")) || entry.filePath().endsWith(QLatin1String("/."))) - { - ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath())); - } else -#endif - { + if (entry.isAbsolute() + && !entry.filePath().contains(QLatin1String("/../")) + && !entry.filePath().contains(QLatin1String("/./")) + && !entry.filePath().endsWith(QLatin1String("/..")) + && !entry.filePath().endsWith(QLatin1String("/."))) { ret = entry.filePath(); + } else { + ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath())); } +#else + ret = entry.filePath(); +#endif } else { ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath()); } diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 733a226..10b59fd 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -225,17 +225,33 @@ QString QFileSystemEntry::completeSuffix() const return m_filePath.mid(qMax((qint16)0, m_lastSeparator) + m_firstDotInFileName + 1); } +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) +bool QFileSystemEntry::isRelative() const +{ + resolveFilePath(); + return (m_filePath.isEmpty() || (!m_filePath.isEmpty() && (m_filePath[0].unicode() != '/') + && (!(m_filePath.length() >= 2 && m_filePath[1].unicode() == ':')))); +} + bool QFileSystemEntry::isAbsolute() const { resolveFilePath(); - return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/') -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - || (m_filePath.length() >= 2 - && ((m_filePath[0].isLetter() && m_filePath[1].unicode() == ':') - || (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/')))) -#endif - ); + return (!m_filePath.isEmpty() && ((m_filePath.length() >= 3 + && (m_filePath[0].isLetter() && m_filePath[1].unicode() == ':' && m_filePath[2].unicode() == '/')) + || (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/'))))); +} +#else +bool QFileSystemEntry::isRelative() const +{ + return !isAbsolute(); +} + +bool QFileSystemEntry::isAbsolute() const +{ + resolveFilePath(); + return (!m_filePath.isEmpty() && (m_filePath[0].unicode() == '/')); } +#endif #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) bool QFileSystemEntry::isDriveRoot() const diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 5a41782..7a9c2a5 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -88,9 +88,7 @@ public: QString suffix() const; QString completeSuffix() const; bool isAbsolute() const; - bool isRelative() const { - return !isAbsolute(); - } + bool isRelative() const; #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) bool isDriveRoot() const; diff --git a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp index 49afab6..4375f99 100644 --- a/tests/auto/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/qfilesystementry/tst_qfilesystementry.cpp @@ -64,6 +64,10 @@ private slots: void baseName(); void completeBaseName_data(); void completeBaseName(); +#if defined(WIN_STUFF) + void absoluteOrRelative_data(); + void absoluteOrRelative(); +#endif }; #if defined(WIN_STUFF) @@ -78,6 +82,7 @@ void tst_QFileSystemEntry::getSetCheck_data() QTest::addColumn("suffix"); QTest::addColumn("completeSuffix"); QTest::addColumn("absolute"); + QTest::addColumn("relative"); QString absPrefix = QLatin1String("\\\\?\\"); QString relPrefix = absPrefix @@ -88,33 +93,33 @@ void tst_QFileSystemEntry::getSetCheck_data() << QString("A:\\home\\qt\\in\\a\\dir.tar.gz") << absPrefix + QString("A:\\home\\qt\\in\\a\\dir.tar.gz") << "A:/home/qt/in/a/dir.tar.gz" - << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << true; + << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << true << false; QTest::newRow("relative") << QString("in\\a\\dir.tar.gz") << relPrefix + QString("in\\a\\dir.tar.gz") << "in/a/dir.tar.gz" - << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << false; + << "dir.tar.gz" << "dir" << "dir.tar" << "gz" << "tar.gz" << false <("path"); + QTest::addColumn("isAbsolute"); + QTest::addColumn("isRelative"); + + QTest::newRow("data0") << "file.tar" << false << true; + QTest::newRow("data1") << "/path/file/file.tar.gz" << false << false; + QTest::newRow("data1") << "C:path/file/file.tar.gz" << false << false; + QTest::newRow("data3") << "C:/path/file" << true << false; + QTest::newRow("data3") << "//machine/share" << true << false; +} + +void tst_QFileSystemEntry::absoluteOrRelative() +{ + QFETCH(QString, path); + QFETCH(bool, isAbsolute); + QFETCH(bool, isRelative); + + QFileSystemEntry fi(path); + QCOMPARE(fi.isAbsolute(), isAbsolute); + QCOMPARE(fi.isRelative(), isRelative); +} +#endif QTEST_MAIN(tst_QFileSystemEntry) #include -- cgit v0.12 From 768009af920c642834b1730136d9c8b156277c1d Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Fri, 17 Sep 2010 16:04:35 +0200 Subject: Fix QDir autotest failures on windows The canonicalName now checks the file existance before it returns the path. It will also fill in the metadata in case the existance was never checked before. Reviewed-by: Joao --- src/corelib/io/qfilesystemengine_win.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 119ed7c..20b9b4d 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -503,8 +503,13 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, //static QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data) { - // The caller has to verify whether the file exists or not. - return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); + if (data.missingFlags(QFileSystemMetaData::ExistsAttribute)) + QFileSystemEngine::fillMetaData(entry, data, QFileSystemMetaData::ExistsAttribute); + + if (data.exists()) + return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); + else + return QFileSystemEntry(); } //static -- cgit v0.12 From 63d50fdfa59cd198f7bf87f37770960e1b93945d Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 17 Sep 2010 15:05:04 +0100 Subject: Move rootPath, homePath, tempPath, currentPath and setCurrentPath Moved these functions inside the QFilesystemEngine and redirected the QFSFileEngine copies. Reviewed-By: joao --- src/corelib/io/qdir.cpp | 31 ++--------- src/corelib/io/qfilesystemengine_p.h | 9 +++- src/corelib/io/qfilesystemengine_symbian.cpp | 67 ++++++++++++++++++++++- src/corelib/io/qfilesystemengine_unix.cpp | 57 +++++++++++++++++++- src/corelib/io/qfilesystemengine_win.cpp | 67 +++++++++++++++++++++++ src/corelib/io/qfilesystementry.cpp | 8 ++- src/corelib/io/qfsfileengine_unix.cpp | 79 ++-------------------------- src/corelib/io/qfsfileengine_win.cpp | 51 ++---------------- src/corelib/kernel/qcoreapplication.cpp | 7 +++ 9 files changed, 225 insertions(+), 151 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index a45c104..e65dc11 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1779,12 +1779,7 @@ QChar QDir::separator() */ bool QDir::setCurrent(const QString &path) { -#ifdef QT_NO_FSFILEENGINE - Q_UNUSED(path); - return false; -#else - return QFSFileEngine::setCurrentPath(path); -#endif + return QFileSystemEngine::setCurrentPath(QFileSystemEntry(fromNativeSeparators(path))); } /*! @@ -1805,11 +1800,7 @@ bool QDir::setCurrent(const QString &path) */ QString QDir::currentPath() { -#ifdef QT_NO_FSFILEENGINE - return QString(); -#else - return QFSFileEngine::currentPath(); -#endif + return QFileSystemEngine::currentPath().filePath(); } /*! @@ -1867,11 +1858,7 @@ QString QDir::currentPath() */ QString QDir::homePath() { -#ifdef QT_NO_FSFILEENGINE - return QString(); -#else - return cleanPath(QFSFileEngine::homePath()); -#endif + return QFileSystemEngine::homePath(); } /*! @@ -1910,11 +1897,7 @@ QString QDir::homePath() */ QString QDir::tempPath() { -#ifdef QT_NO_FSFILEENGINE - return QString(); -#else - return cleanPath(QFSFileEngine::tempPath()); -#endif + return QFileSystemEngine::tempPath(); } /*! @@ -1941,11 +1924,7 @@ QString QDir::tempPath() */ QString QDir::rootPath() { -#ifdef QT_NO_FSFILEENGINE - return QString(); -#else - return QFSFileEngine::rootPath(); -#endif + return QFileSystemEngine::rootPath(); } /*! diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index b3bbd65..20b664d 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -88,11 +88,13 @@ public: QFileSystemMetaData::MetaDataFlags what); static bool fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what); - static QString homePath(); - static QString rootPath(); static QString owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own); static QString nativeAbsoluteFilePath(const QString &path); #endif + //homePath, rootPath and tempPath shall return clean paths + static QString homePath(); + static QString rootPath(); + static QString tempPath(); static bool createDirectory(const QFileSystemEntry &entry, bool createParents); static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents); @@ -106,6 +108,9 @@ public: static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data = 0); + static bool setCurrentPath(const QFileSystemEntry &entry); + static QFileSystemEntry currentPath(); + static QAbstractFileEngine *resolveEntryAndCreateLegacyEngine(QFileSystemEntry &entry, QFileSystemMetaData &data); private: diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index b4f0f88..ce2166d 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -42,8 +42,11 @@ #include "qfilesystemengine_p.h" #include "qfsfileengine.h" #include +#include #include +#include +#include QT_BEGIN_NAMESPACE @@ -121,7 +124,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) QString result; if (needsDrive || isDriveLetter || isDriveRelative || !isAbsolute || orig.isEmpty()) { - QFileSystemEntry cur(QFSFileEngine::currentPath()); + QFileSystemEntry cur(currentPath()); if(needsDrive) result = cur.filePath().left(2); else if(isDriveRelative && cur.filePath().at(0) != orig.at(0)) @@ -339,4 +342,66 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per return err == KErrNone; // TODO error reporting } +QString QFileSystemEngine::homePath() +{ + QString home = QDir::fromNativeSeparators(qt_TDesC2QString(PathInfo::PhoneMemoryRootPath())); + if(home.endsWith(QLatin1Char('/'))) + home.chop(1); + return home; +} + +QString QFileSystemEngine::rootPath() +{ + TChar drive; + TInt err = RFs::DriveToChar(RFs::GetSystemDrive(), drive); //RFs::GetSystemDriveChar not supported on S60 3.1 + Q_ASSERT(err == KErrNone); //RFs::GetSystemDrive() shall always return a convertible drive number on a valid OS configuration + return QString(QChar(drive)).append(QLatin1String(":/")); +} + +QString QFileSystemEngine::tempPath() +{ + return rootPath().append(QLatin1String("system/temp")); +} + +//static +bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry) +{ + QFileSystemMetaData meta; + QFileSystemEntry absname = absoluteName(entry); + fillMetaData(absname, meta, QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); + if(!(meta.exists() && meta.isDirectory())) + return false; + + RFs& fs = qt_s60GetRFs(); + QString abspath = absname.nativeFilePath(); + if(!abspath.endsWith(QLatin1Char('\\'))) + abspath.append(QLatin1Char('\\')); + TInt r = fs.SetSessionPath(qt_QString2TPtrC(abspath)); + //SetSessionPath succeeds for non existant directory, which is why it's checked above + if (r == KErrNone) { + __ASSERT_COMPILE(sizeof(wchar_t) == sizeof(unsigned short)); + //attempt to set open C to the same path + r = ::wchdir(reinterpret_cast(absname.filePath().utf16())); + if (r < 0) + qWarning("failed to sync path to open C"); + return true; + } + return false; +} + +//static +QFileSystemEntry QFileSystemEngine::currentPath() +{ + TFileName fn; + QFileSystemEntry ret; + TInt r = qt_s60GetRFs().SessionPath(fn); + if(r == KErrNone) { + //remove terminating slash from non root paths (session path is clean, absolute and always ends in a \) + if(fn.Length() > 3 && fn[fn.Length() - 1] == '\\') + fn.SetLength(fn.Length() - 1); + ret = QFileSystemEntry(qt_TDesC2QString(fn), QFileSystemEntry::FromNativePath()); + } + return ret; +} + QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 6290d68..8724b15 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -246,7 +246,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) QByteArray orig = entry.nativeFilePath(); QByteArray result; if (orig.isEmpty() || !orig.startsWith('/')) { - QFileSystemEntry cur(QFSFileEngine::currentPath()); + QFileSystemEntry cur(currentPath()); result = cur.nativeFilePath(); } if (!orig.isEmpty() && !(orig.length() == 1 && orig[0] == '.')) { @@ -548,4 +548,59 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per return false; // TODO implement; } +QString QFileSystemEngine::homePath() +{ + QString home = QFile::decodeName(qgetenv("HOME")); + if (home.isNull()) + home = rootPath(); + return QDir::cleanPath(home); +} + +QString QFileSystemEngine::rootPath() +{ + return QLatin1String("/"); +} + +QString QFileSystemEngine::tempPath() +{ + QString temp = QFile::decodeName(qgetenv("TMPDIR")); + if (temp.isEmpty()) + temp = QLatin1String("/tmp/"); + return QDir::cleanPath(temp); +} + +bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &path) +{ + int r; + r = QT_CHDIR(path.nativeFilePath()); + return r >= 0; +} + +QFileSystemEntry QFileSystemEngine::currentPath() +{ + QFileSystemEntry result; + QT_STATBUF st; + if (QT_STAT(".", &st) == 0) { +#if defined(__GLIBC__) && !defined(PATH_MAX) + char *currentName = ::get_current_dir_name(); + if (currentName) { + result = QFile::decodeName(QByteArray(currentName)); + ::free(currentName); + } +#else + char currentName[PATH_MAX+1]; + if (::getcwd(currentName, PATH_MAX)) + result = QFileSystemEntry(QByteArray(currentName), QFileSystemEntry::FromNativePath()); +# if defined(QT_DEBUG) + if (result.isEmpty()) + qWarning("QFSFileEngine::currentPath: getcwd() failed"); +# endif +#endif + } else { +# if defined(QT_DEBUG) + qWarning("QFSFileEngine::currentPath: stat(\".\") failed"); +# endif + } + return result; +} QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 20b9b4d..cef7236 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1098,6 +1098,73 @@ QString QFileSystemEngine::homePath() return QDir::fromNativeSeparators(ret); } +QString QFileSystemEngine::tempPath() +{ + QString ret; + wchar_t tempPath[MAX_PATH]; + DWORD len = GetTempPath(MAX_PATH, tempPath); + if (len) + ret = QString::fromWCharArray(tempPath, len); + if (!ret.isEmpty()) { + while (ret.endsWith(QLatin1Char('\\'))) + ret.chop(1); + ret = QDir::fromNativeSeparators(ret); + } + if (ret.isEmpty()) { +#if !defined(Q_OS_WINCE) + ret = QLatin1String("c:/tmp"); +#else + ret = QLatin1String("/Temp"); +#endif + } + return ret; +} + +bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry) +{ + QFileSystemMetaData meta; + fillMetaData(entry, meta, QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); + if(!(meta.exists() && meta.isDirectory())) + return false; + +#if !defined(Q_OS_WINCE) + //TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo + //which causes many problems later on when it's returned through currentPath() + return ::SetCurrentDirectory(reinterpret_cast(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0; +#else + qfsPrivateCurrentDir = entry.filePath(); + return true; +#endif +} + +QFileSystemEntry QFileSystemEngine::currentPath() +{ + QString ret; +#if !defined(Q_OS_WINCE) + DWORD size = 0; + wchar_t currentName[PATH_MAX]; + size = ::GetCurrentDirectory(PATH_MAX, currentName); + if (size != 0) { + if (size > PATH_MAX) { + wchar_t *newCurrentName = new wchar_t[size]; + if (::GetCurrentDirectory(PATH_MAX, newCurrentName) != 0) + ret = QString::fromWCharArray(newCurrentName, size); + delete [] newCurrentName; + } else { + ret = QString::fromWCharArray(currentName, size); + } + } +#else + Q_UNUSED(fileName); + //TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads + if (qfsPrivateCurrentDir.isEmpty()) + qfsPrivateCurrentDir = QCoreApplication::applicationDirPath(); + + ret = qfsPrivateCurrentDir; +#endif + return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath()); +} + //static bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) { diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 10b59fd..12de135 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -121,8 +121,14 @@ QFileSystemEntry::NativePath QFileSystemEntry::nativeFilePath() const void QFileSystemEntry::resolveFilePath() const { if (m_filePath.isEmpty() && !m_nativeFilePath.isEmpty()) { -#ifdef QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16 +#if defined(QFILESYSTEMENTRY_NATIVE_PATH_IS_UTF16) m_filePath = QDir::fromNativeSeparators(m_nativeFilePath); +#ifdef Q_OS_WIN + if (m_filePath.startsWith(QLatin1String("//?/UNC/"))) + m_filePath = m_filePath.remove(2,6); + if (m_filePath.startsWith(QLatin1String("//?/"))) + m_filePath = m_filePath.remove(0,4); +#endif #else m_filePath = QDir::fromNativeSeparators(QFile::decodeName(m_nativeFilePath)); #endif diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 2e9d10c..84054d8 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -691,96 +691,27 @@ bool QFSFileEngine::caseSensitive() const bool QFSFileEngine::setCurrentPath(const QString &path) { - int r; - r = QT_CHDIR(QFile::encodeName(path)); - return r >= 0; + return QFileSystemEngine::setCurrentPath(QFileSystemEntry(QDir::fromNativeSeparators(path))); } QString QFSFileEngine::currentPath(const QString &) { - QString result; - QT_STATBUF st; -#if defined(Q_OS_SYMBIAN) - char nativeCurrentName[PATH_MAX+1]; - if (::getcwd(nativeCurrentName, PATH_MAX)) - result = QDir::fromNativeSeparators(QFile::decodeName(QByteArray(nativeCurrentName))); - if (result.isEmpty()) { -# if defined(QT_DEBUG) - qWarning("QFSFileEngine::currentPath: getcwd() failed"); -# endif - } else -#endif - if (QT_STAT(".", &st) == 0) { -#if defined(__GLIBC__) && !defined(PATH_MAX) - char *currentName = ::get_current_dir_name(); - if (currentName) { - result = QFile::decodeName(QByteArray(currentName)); - ::free(currentName); - } -#elif !defined(Q_OS_SYMBIAN) - char currentName[PATH_MAX+1]; - if (::getcwd(currentName, PATH_MAX)) - result = QFile::decodeName(QByteArray(currentName)); -# if defined(QT_DEBUG) - if (result.isNull()) - qWarning("QFSFileEngine::currentPath: getcwd() failed"); -# endif -#endif - } else { -#if defined(Q_OS_SYMBIAN) - // If current dir returned by Open C doesn't exist, - // try to create it (can happen with application private dirs) - // Ignore mkdir failures; we want to be consistent with Open C - // current path regardless. - QT_MKDIR(QFile::encodeName(QLatin1String(nativeCurrentName)), 0777); -#else -# if defined(QT_DEBUG) - qWarning("QFSFileEngine::currentPath: stat(\".\") failed"); -# endif -#endif - } - return result; + return QFileSystemEngine::currentPath().filePath(); } QString QFSFileEngine::homePath() { -#if defined(Q_OS_SYMBIAN) - QString home = QDir::cleanPath(QDir::fromNativeSeparators(qt_TDesC2QString(PathInfo::PhoneMemoryRootPath()))); -#else - QString home = QFile::decodeName(qgetenv("HOME")); - if (home.isNull()) - home = rootPath(); -#endif - return home; + return QFileSystemEngine::homePath(); } QString QFSFileEngine::rootPath() { -#if defined(Q_OS_SYMBIAN) - TChar drive; - TInt err = RFs::DriveToChar(RFs::GetSystemDrive(), drive); //RFs::GetSystemDriveChar not supported on S60 3.1 - Q_ASSERT(err == KErrNone); //RFs::GetSystemDrive() shall always return a convertible drive number on a valid OS configuration - return QString(QChar(drive)).append(QLatin1String(":/")); -#else - return QLatin1String("/"); -#endif + return QFileSystemEngine::rootPath(); } QString QFSFileEngine::tempPath() { -#if defined(Q_OS_SYMBIAN) - TFileName symbianPath = PathInfo::PhoneMemoryRootPath(); - QString temp = QDir::fromNativeSeparators(qt_TDesC2QString(symbianPath)); - temp += QLatin1String( "temp/"); - - // Just to verify that folder really exist on hardware - QT_MKDIR(QFile::encodeName(temp), 0777); -#else - QString temp = QFile::decodeName(qgetenv("TMPDIR")); - if (temp.isEmpty()) - temp = QLatin1String("/tmp/"); -#endif - return temp; + return QFileSystemEngine::tempPath(); } QFileInfoList QFSFileEngine::drives() diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index dde499a..b2009c3 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -544,15 +544,7 @@ bool QFSFileEngine::caseSensitive() const bool QFSFileEngine::setCurrentPath(const QString &path) { - if (!QDir(path).exists()) - return false; - -#if !defined(Q_OS_WINCE) - return ::SetCurrentDirectory((wchar_t*)path.utf16()) != 0; -#else - qfsPrivateCurrentDir = QFSFileEnginePrivate::longFileName(path); - return true; -#endif + return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path)); } QString QFSFileEngine::currentPath(const QString &fileName) @@ -571,29 +563,14 @@ QString QFSFileEngine::currentPath(const QString &fileName) } if (ret.isEmpty()) { //just the pwd - DWORD size = 0; - wchar_t currentName[PATH_MAX]; - size = ::GetCurrentDirectory(PATH_MAX, currentName); - if (size != 0) { - if (size > PATH_MAX) { - wchar_t *newCurrentName = new wchar_t[size]; - if (::GetCurrentDirectory(PATH_MAX, newCurrentName) != 0) - ret = QString::fromWCharArray(newCurrentName); - delete [] newCurrentName; - } else { - ret = QString::fromWCharArray(currentName); - } - } + ret = QFileSystemEngine::currentPath().filePath(); } if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. - return QDir::fromNativeSeparators(ret); + return ret; #else Q_UNUSED(fileName); - if (qfsPrivateCurrentDir.isEmpty()) - qfsPrivateCurrentDir = QCoreApplication::applicationDirPath(); - - return QDir::fromNativeSeparators(qfsPrivateCurrentDir); + return QFileSystemEngine::currentPath(); #endif } @@ -609,25 +586,7 @@ QString QFSFileEngine::rootPath() QString QFSFileEngine::tempPath() { - QString ret; - { - wchar_t tempPath[MAX_PATH]; - if (GetTempPath(MAX_PATH, tempPath)) - ret = QString::fromWCharArray(tempPath); - if (!ret.isEmpty()) { - while (ret.endsWith(QLatin1Char('\\'))) - ret.chop(1); - ret = QDir::fromNativeSeparators(ret); - } - } - if (ret.isEmpty()) { -#if !defined(Q_OS_WINCE) - ret = QLatin1String("c:/tmp"); -#else - ret = QLatin1String("/Temp"); -#endif - } - return ret; + return QFileSystemEngine::tempPath(); } QFileInfoList QFSFileEngine::drives() diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index ad645e3..d94cf6d 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -71,6 +71,7 @@ # include # include "qeventdispatcher_symbian_p.h" # include "private/qcore_symbian_p.h" +# include "private/qfilesystemengine_p.h" #elif defined(Q_OS_UNIX) # if !defined(QT_NO_GLIB) # include "qeventdispatcher_glib_p.h" @@ -568,6 +569,12 @@ void QCoreApplication::init() Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object"); QCoreApplication::self = this; +#ifdef Q_OS_SYMBIAN + //ensure temp and working directories exist + QFileSystemEngine::createDirectory(QFileSystemEntry(QFileSystemEngine::tempPath()), true); + QFileSystemEngine::createDirectory(QFileSystemEntry(QFileSystemEngine::currentPath()), true); +#endif + #ifndef QT_NO_THREAD QThread::initialize(); #endif -- cgit v0.12 From 883b223c2fc17e313c8a080c14055bba02ae655c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 17 Sep 2010 18:13:50 +0100 Subject: Make use of new isRelative / isAbsolute functions Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index ce2166d..efb3539 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -112,16 +112,17 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) { QString orig = entry.filePath(); - const bool needsDrive = (!orig.isEmpty() && orig.at(0).unicode() == '/'); - const bool isDriveLetter = (orig.size() == 2 && orig.at(1).unicode() == ':'); - const bool isDriveRelative = (orig.size() > 2 && orig.at(1).unicode() == ':' && orig.at(2).unicode() != '/'); + const bool isAbsolute = entry.isAbsolute(); const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) || orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/."))); - const bool isAbsolute = !entry.isRelative(); - if (isAbsolute && - !(needsDrive || isDriveLetter || isDriveRelative || isDirty)) + if (isAbsolute && !isDirty) return entry; + const bool isRelative = entry.isRelative(); + const bool needsDrive = (!orig.isEmpty() && orig.at(0).unicode() == '/'); + const bool isDriveLetter = !needsDrive && !isAbsolute && !isRelative && orig.length() == 2; + const bool isDriveRelative = !needsDrive && !isAbsolute && !isRelative && orig.length() > 2; + QString result; if (needsDrive || isDriveLetter || isDriveRelative || !isAbsolute || orig.isEmpty()) { QFileSystemEntry cur(currentPath()); -- cgit v0.12 From 333b30dc2b3c065dec2c84cf9750a526c2636d34 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 17 Sep 2010 18:23:11 +0100 Subject: Remove UNC paths on symbian, it doesn't support UNC Reviewed-By: joao --- src/corelib/io/qfilesystementry.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 12de135..bc7f121 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -244,7 +244,10 @@ bool QFileSystemEntry::isAbsolute() const resolveFilePath(); return (!m_filePath.isEmpty() && ((m_filePath.length() >= 3 && (m_filePath[0].isLetter() && m_filePath[1].unicode() == ':' && m_filePath[2].unicode() == '/')) - || (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/'))))); +#ifdef Q_OS_WIN + || (m_filePath.length() >= 2 && (m_filePath.at(0) == QLatin1Char('/') && m_filePath.at(1) == QLatin1Char('/'))) +#endif + )); } #else bool QFileSystemEntry::isRelative() const -- cgit v0.12 From b22bc06f8dac7723026014ba39a108b198f16d66 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 21 Sep 2010 14:21:07 +0200 Subject: Make QDirIterator cheaper when constructed with a QDir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure we share the pre-calculated entry and avoid resolving the fileEngine if we know its a native FS based file. Reviewed-by: João Abecasis --- qmake/qmake.pri | 1 + src/corelib/io/io.pri | 1 + src/corelib/io/qdir.cpp | 226 +++++++++++++++++----------------------- src/corelib/io/qdir_p.h | 98 +++++++++++++++++ src/corelib/io/qdiriterator.cpp | 39 ++++--- 5 files changed, 216 insertions(+), 149 deletions(-) create mode 100644 src/corelib/io/qdir_p.h diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 1d35183..889338f 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -98,6 +98,7 @@ bootstrap { #Qt code qdatetime.h \ qdatetime_p.h \ qdir.h \ + qdir_p.h \ qdiriterator.h \ qfile.h \ qabstractfileengine.h \ diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 9d209ea..f81ffaf 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -9,6 +9,7 @@ HEADERS += \ io/qdataurl_p.h \ io/qdebug.h \ io/qdir.h \ + io/qdir_p.h \ io/qdiriterator.h \ io/qfile.h \ io/qfileinfo.h \ diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index e65dc11..5c882fd 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -41,6 +41,7 @@ #include "qplatformdefs.h" #include "qdir.h" +#include "qdir_p.h" #include "qabstractfileengine.h" #ifndef QT_NO_DEBUG_STREAM #include "qdebug.h" @@ -85,153 +86,123 @@ static QString driveSpec(const QString &path) } //************* QDirPrivate -class QDirPrivate - : public QSharedData -{ -public: - QDirPrivate(const QString &path, - const QStringList &nameFilters_ = QStringList(), - QDir::SortFlags sort_ = QDir::SortFlags(QDir::Name | QDir::IgnoreCase), - QDir::Filters filters_ = QDir::AllEntries) - : QSharedData() - , nameFilters(nameFilters_) - , sort(sort_) - , filters(filters_) +QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, QDir::SortFlags sort_, QDir::Filters filters_) + : QSharedData() + , nameFilters(nameFilters_) + , sort(sort_) + , filters(filters_) #ifdef QT3_SUPPORT - , filterSepChar(0) - , matchAllDirs(false) + , filterSepChar(0) + , matchAllDirs(false) #endif - , fileListsInitialized(false) - { - setPath(path.isEmpty() ? QString::fromLatin1(".") : path); - - bool empty = nameFilters.isEmpty(); - if (!empty) { - empty = true; - for (int i = 0; i < nameFilters.size(); ++i) { - if (!nameFilters.at(i).isEmpty()) { - empty = false; - break; - } + , fileListsInitialized(false) +{ + setPath(path.isEmpty() ? QString::fromLatin1(".") : path); + + bool empty = nameFilters.isEmpty(); + if (!empty) { + empty = true; + for (int i = 0; i < nameFilters.size(); ++i) { + if (!nameFilters.at(i).isEmpty()) { + empty = false; + break; } } - if (empty) - nameFilters = QStringList(QString::fromLatin1("*")); } + if (empty) + nameFilters = QStringList(QString::fromLatin1("*")); +} - QDirPrivate(const QDirPrivate ©) - : QSharedData(copy) - , nameFilters(copy.nameFilters) - , sort(copy.sort) - , filters(copy.filters) +QDirPrivate::QDirPrivate(const QDirPrivate ©) + : QSharedData(copy) + , nameFilters(copy.nameFilters) + , sort(copy.sort) + , filters(copy.filters) #ifdef QT3_SUPPORT - , filterSepChar(copy.filterSepChar) - , matchAllDirs(copy.matchAllDirs) + , filterSepChar(copy.filterSepChar) + , matchAllDirs(copy.matchAllDirs) #endif - , fileListsInitialized(false) - , dirEntry(copy.dirEntry) - , metaData(copy.metaData) - { - } + , fileListsInitialized(false) + , dirEntry(copy.dirEntry) + , metaData(copy.metaData) +{ +} - bool exists() const - { - if (fileEngine.isNull()) { - if (!metaData.hasFlags(QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType)) - QFileSystemEngine::fillMetaData(dirEntry, metaData, - QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); - return metaData.exists() && metaData.isDirectory(); - } - const QAbstractFileEngine::FileFlags info = - fileEngine->fileFlags(QAbstractFileEngine::DirectoryType - | QAbstractFileEngine::ExistsFlag - | QAbstractFileEngine::Refresh); - if (!(info & QAbstractFileEngine::DirectoryType)) - return false; - return info & QAbstractFileEngine::ExistsFlag; +bool QDirPrivate::exists() const +{ + if (fileEngine.isNull()) { + if (!metaData.hasFlags(QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType)) + QFileSystemEngine::fillMetaData(dirEntry, metaData, + QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); + return metaData.exists() && metaData.isDirectory(); } + const QAbstractFileEngine::FileFlags info = + fileEngine->fileFlags(QAbstractFileEngine::DirectoryType + | QAbstractFileEngine::ExistsFlag + | QAbstractFileEngine::Refresh); + if (!(info & QAbstractFileEngine::DirectoryType)) + return false; + return info & QAbstractFileEngine::ExistsFlag; +} - void initFileEngine(); - void initFileLists(const QDir &dir) const; - - static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *); - - static inline QChar getFilterSepChar(const QString &nameFilter) - { - QChar sep(QLatin1Char(';')); - int i = nameFilter.indexOf(sep, 0); - if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1) - sep = QChar(QLatin1Char(' ')); - return sep; - } +// static +inline QChar QDirPrivate::getFilterSepChar(const QString &nameFilter) +{ + QChar sep(QLatin1Char(';')); + int i = nameFilter.indexOf(sep, 0); + if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1) + sep = QChar(QLatin1Char(' ')); + return sep; +} - static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0) - { - if (sep == 0) - sep = getFilterSepChar(nameFilter); - QStringList ret = nameFilter.split(sep); - for (int i = 0; i < ret.count(); ++i) - ret[i] = ret[i].trimmed(); - return ret; - } +// static +inline QStringList QDirPrivate::splitFilters(const QString &nameFilter, QChar sep) +{ + if (sep == 0) + sep = getFilterSepChar(nameFilter); + QStringList ret = nameFilter.split(sep); + for (int i = 0; i < ret.count(); ++i) + ret[i] = ret[i].trimmed(); + return ret; +} - inline void setPath(const QString &path) - { - QString p = QDir::fromNativeSeparators(path); - if (p.endsWith(QLatin1Char('/')) - && p.length() > 1 +inline void QDirPrivate::setPath(const QString &path) +{ + QString p = QDir::fromNativeSeparators(path); + if (p.endsWith(QLatin1Char('/')) + && p.length() > 1 #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) - && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) + && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) #endif - ) { - p.truncate(p.length() - 1); - } - - dirEntry = QFileSystemEntry(p); - initFileEngine(); - clearFileLists(); - absoluteDirEntry = QFileSystemEntry(); + ) { + p.truncate(p.length() - 1); } - inline void clearFileLists() - { - fileListsInitialized = false; - files.clear(); - fileInfos.clear(); - } - - inline void resolveAbsoluteEntry() const - { - if (!absoluteDirEntry.isEmpty() || dirEntry.isEmpty()) - return; - - if (dirEntry.isRelative()) { - QFileSystemEntry answer = QFileSystemEngine::absoluteName(dirEntry); - absoluteDirEntry = QFileSystemEntry(QDir::cleanPath(answer.filePath())); - } else { - absoluteDirEntry = dirEntry; - } - } - - QStringList nameFilters; - QDir::SortFlags sort; - QDir::Filters filters; - -#ifdef QT3_SUPPORT - QChar filterSepChar; - bool matchAllDirs; -#endif + dirEntry = QFileSystemEntry(p); + initFileEngine(); + clearFileLists(); + absoluteDirEntry = QFileSystemEntry(); +} - QScopedPointer fileEngine; +inline void QDirPrivate::clearFileLists() +{ + fileListsInitialized = false; + files.clear(); + fileInfos.clear(); +} - mutable bool fileListsInitialized; - mutable QStringList files; - mutable QFileInfoList fileInfos; +inline void QDirPrivate::resolveAbsoluteEntry() const +{ + if (!absoluteDirEntry.isEmpty() || dirEntry.isEmpty()) + return; - QFileSystemEntry dirEntry; - mutable QFileSystemEntry absoluteDirEntry; - mutable QFileSystemMetaData metaData; -}; + if (dirEntry.isRelative()) { + QFileSystemEntry answer = QFileSystemEngine::absoluteName(dirEntry); + absoluteDirEntry = QFileSystemEntry(QDir::cleanPath(answer.filePath())); + } else { + absoluteDirEntry = dirEntry; + } +} /* For sorting */ struct QDirSortItem @@ -343,7 +314,6 @@ inline void QDirPrivate::sortFileList(QDir::SortFlags sort, QFileInfoList &l, } } } - inline void QDirPrivate::initFileLists(const QDir &dir) const { if (!fileListsInitialized) { diff --git a/src/corelib/io/qdir_p.h b/src/corelib/io/qdir_p.h new file mode 100644 index 0000000..5f97c1f --- /dev/null +++ b/src/corelib/io/qdir_p.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDIR_PRIVATE_H +#define QDIR_PRIVATE_H + +#include "qfilesystementry_p.h" +#include "qfilesystemmetadata_p.h" + +QT_BEGIN_NAMESPACE + +class QDirPrivate : public QSharedData +{ +public: + QDirPrivate(const QString &path, const QStringList &nameFilters_ = QStringList(), + QDir::SortFlags sort_ = QDir::SortFlags(QDir::Name | QDir::IgnoreCase), + QDir::Filters filters_ = QDir::AllEntries); + + QDirPrivate(const QDirPrivate ©); + + bool exists() const; + + void initFileEngine(); + void initFileLists(const QDir &dir) const; + + static void sortFileList(QDir::SortFlags, QFileInfoList &, QStringList *, QFileInfoList *); + + static inline QChar getFilterSepChar(const QString &nameFilter); + + static inline QStringList splitFilters(const QString &nameFilter, QChar sep = 0); + + inline void setPath(const QString &path); + + inline void clearFileLists(); + + inline void resolveAbsoluteEntry() const; + + QStringList nameFilters; + QDir::SortFlags sort; + QDir::Filters filters; + +#ifdef QT3_SUPPORT + QChar filterSepChar; + bool matchAllDirs; +#endif + + QScopedPointer fileEngine; + + mutable bool fileListsInitialized; + mutable QStringList files; + mutable QFileInfoList fileInfos; + + QFileSystemEntry dirEntry; + mutable QFileSystemEntry absoluteDirEntry; + mutable QFileSystemMetaData metaData; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 582fb85..a8192ea 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -90,6 +90,7 @@ */ #include "qdiriterator.h" +#include "qdir_p.h" #include "qabstractfileengine.h" @@ -119,8 +120,8 @@ public: class QDirIteratorPrivate { public: - QDirIteratorPrivate(const QString &path, const QStringList &nameFilters, - QDir::Filters filters, QDirIterator::IteratorFlags flags); + QDirIteratorPrivate(const QFileSystemEntry &entry, const QStringList &nameFilters, + QDir::Filters filters, QDirIterator::IteratorFlags flags, bool resolveEngine = true); void advance(); @@ -131,7 +132,7 @@ public: QScopedPointer engine; - const QString path; + QFileSystemEntry dirEntry; const QStringList nameFilters; const QDir::Filters filters; const QDirIterator::IteratorFlags iteratorFlags; @@ -153,9 +154,9 @@ public: /*! \internal */ -QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList &nameFilters, - QDir::Filters filters, QDirIterator::IteratorFlags flags) - : path(path) +QDirIteratorPrivate::QDirIteratorPrivate(const QFileSystemEntry &entry, const QStringList &nameFilters, + QDir::Filters filters, QDirIterator::IteratorFlags flags, bool resolveEngine) + : dirEntry(entry) , nameFilters(nameFilters.contains(QLatin1String("*")) ? QStringList() : nameFilters) , filters(QDir::NoFilter == filters ? QDir::AllEntries : filters) , iteratorFlags(flags) @@ -168,17 +169,10 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList (filters & QDir::CaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive, QRegExp::Wildcard)); #endif - -#ifdef Q_OS_UNIX - QFileSystemEntry fileEntry(path); QFileSystemMetaData metaData; - - engine.reset(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(fileEntry, metaData)); - QFileInfo fileInfo(new QFileInfoPrivate(fileEntry, metaData)); -#else - engine.reset(QAbstractFileEngine::create(path)); - QFileInfo fileInfo(path); -#endif + if (resolveEngine) + engine.reset(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(dirEntry, metaData)); + QFileInfo fileInfo(new QFileInfoPrivate(dirEntry, metaData)); // Populate fields for hasNext() and next() pushDirectory(fileInfo); @@ -411,8 +405,11 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf \sa hasNext(), next(), IteratorFlags */ QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags) - : d(new QDirIteratorPrivate(dir.path(), dir.nameFilters(), dir.filter(), flags)) { + // little trick to get hold of the QDirPrivate while there is no API on QDir to give it to us + class MyQDir : public QDir { public: const QDirPrivate *priv() const { return d_ptr.constData(); } }; + const QDirPrivate *other = static_cast(&dir)->priv(); + d.reset(new QDirIteratorPrivate(other->dirEntry, other->nameFilters, other->filters, flags, !other->fileEngine.isNull())); } /*! @@ -432,7 +429,7 @@ QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags) \sa hasNext(), next(), IteratorFlags */ QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorFlags flags) - : d(new QDirIteratorPrivate(path, QStringList(), filters, flags)) + : d(new QDirIteratorPrivate(QFileSystemEntry(path), QStringList(), filters, flags)) { } @@ -449,7 +446,7 @@ QDirIterator::QDirIterator(const QString &path, QDir::Filters filters, IteratorF \sa hasNext(), next(), IteratorFlags */ QDirIterator::QDirIterator(const QString &path, IteratorFlags flags) - : d(new QDirIteratorPrivate(path, QStringList(), QDir::NoFilter, flags)) + : d(new QDirIteratorPrivate(QFileSystemEntry(path), QStringList(), QDir::NoFilter, flags)) { } @@ -471,7 +468,7 @@ QDirIterator::QDirIterator(const QString &path, IteratorFlags flags) */ QDirIterator::QDirIterator(const QString &path, const QStringList &nameFilters, QDir::Filters filters, IteratorFlags flags) - : d(new QDirIteratorPrivate(path, nameFilters, filters, flags)) + : d(new QDirIteratorPrivate(QFileSystemEntry(path), nameFilters, filters, flags)) { } @@ -552,7 +549,7 @@ QFileInfo QDirIterator::fileInfo() const */ QString QDirIterator::path() const { - return d->path; + return d->dirEntry.filePath(); } QT_END_NAMESPACE -- cgit v0.12 From 49d5e73b52a8830f88041f0c1e726133e791f999 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 22 Sep 2010 11:32:15 +0200 Subject: Fix regression in QDir::cd() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On changing path we always have to clear the metadata as thats from the old directory and we need to re-stat for the new data. Reviewed-by: João Abecasis --- src/corelib/io/qdir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 5c882fd..c7cf87f 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -179,6 +179,7 @@ inline void QDirPrivate::setPath(const QString &path) } dirEntry = QFileSystemEntry(p); + metaData.clear(); initFileEngine(); clearFileLists(); absoluteDirEntry = QFileSystemEntry(); -- cgit v0.12 From c798fc3bf3ed8551185d0914f25dc7ed6fd123dd Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 22 Sep 2010 12:45:32 +0200 Subject: Fix QDirIterator on Windows XP. The find option "FindExInfoBasic" which queries only the long file nmae is available only on Windows 7 and above. All other version have to use the "FindExInfoStandard" option which queries both short and long file names. Reviewed-by: Joao --- src/corelib/io/qfilesystemiterator_win.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 373a50a..4050199 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -85,17 +85,15 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa if (findFileHandle == INVALID_HANDLE_VALUE && !uncFallback) { haveData = true; + int infoLevel = 0 ; // FindExInfoStandard; DWORD dwAdditionalFlags = 0; - if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) + if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) { dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH + infoLevel = 1 ; // FindExInfoBasic; + } int searchOps = 0; // FindExSearchNameMatch if (onlyDirs) searchOps = 1 ; // FindExSearchLimitToDirectories -#if !defined(Q_OS_WINCE) - int infoLevel = 1 ; // FindExInfoBasic; -#else - int infoLevel = 0; // FindExInfoStandard; -#endif findFileHandle = FindFirstFileEx((const wchar_t *)nativePath.utf16(), FINDEX_INFO_LEVELS(infoLevel), &findData, FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags); if (findFileHandle == INVALID_HANDLE_VALUE) { -- cgit v0.12 From 9f2aee2a22d5a7c53480cc6c5794293bfe04cf8c Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 22 Sep 2010 13:14:16 +0200 Subject: Remove warnings --- src/corelib/io/qfilesystemengine_unix.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 8724b15..0672490 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -102,6 +102,7 @@ static inline bool _q_isMacHidden(const char *nativePath) #else static inline bool _q_isMacHidden(const char *nativePath) { + Q_UNUSED(nativePath); // no-op return false; } @@ -294,6 +295,8 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) return QCFString::toQString((CFStringRef)name); } } +#else + Q_UNUSED(entry); #endif return QString(); } -- cgit v0.12 From db9fb7195155f4ec929ae4ac73c5c5d4422e5aa6 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 22 Sep 2010 14:00:55 +0200 Subject: Implement unix permissions setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 29 +++++++++++++++++- src/corelib/io/qfsfileengine_unix.cpp | 49 +++++-------------------------- 2 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 0672490..e85eb00 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -43,6 +43,7 @@ #include "qfilesystemengine_p.h" #include "qplatformdefs.h" #include "qfsfileengine.h" +#include "qfile.h" #include // for realpath() #include @@ -548,7 +549,33 @@ bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) //static bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) { - return false; // TODO implement; + mode_t mode = 0; + if (permissions & QFile::ReadOwner) + mode |= S_IRUSR; + if (permissions & QFile::WriteOwner) + mode |= S_IWUSR; + if (permissions & QFile::ExeOwner) + mode |= S_IXUSR; + if (permissions & QFile::ReadUser) + mode |= S_IRUSR; + if (permissions & QFile::WriteUser) + mode |= S_IWUSR; + if (permissions & QFile::ExeUser) + mode |= S_IXUSR; + if (permissions & QFile::ReadGroup) + mode |= S_IRGRP; + if (permissions & QFile::WriteGroup) + mode |= S_IWGRP; + if (permissions & QFile::ExeGroup) + mode |= S_IXGRP; + if (permissions & QFile::ReadOther) + mode |= S_IROTH; + if (permissions & QFile::WriteOther) + mode |= S_IWOTH; + if (permissions & QFile::ExeOther) + mode |= S_IXOTH; + + return ::chmod(entry.nativeFilePath().constData(), mode) == 0; } QString QFileSystemEngine::homePath() diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 84054d8..7b7cd7f 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -938,18 +938,23 @@ QString QFSFileEngine::owner(FileOwner own) const return QString(); } -#ifdef Q_OS_SYMBIAN bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); - //TODO: connect up error reporting properly if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), 0)) { - setError(QFile::PermissionsError, QString()); + setError(QFile::PermissionsError, +#ifdef Q_OS_SYMBIAN + //TODO: connect up error reporting properly + QString()); +#else + qt_error_string(errno)); +#endif return false; } return true; } +#ifdef Q_OS_SYMBIAN bool QFSFileEngine::setSize(qint64 size) { Q_D(QFSFileEngine); @@ -983,44 +988,6 @@ bool QFSFileEngine::setSize(qint64 size) return ret; } #else -bool QFSFileEngine::setPermissions(uint perms) -{ - Q_D(QFSFileEngine); - bool ret = false; - mode_t mode = 0; - if (perms & ReadOwnerPerm) - mode |= S_IRUSR; - if (perms & WriteOwnerPerm) - mode |= S_IWUSR; - if (perms & ExeOwnerPerm) - mode |= S_IXUSR; - if (perms & ReadUserPerm) - mode |= S_IRUSR; - if (perms & WriteUserPerm) - mode |= S_IWUSR; - if (perms & ExeUserPerm) - mode |= S_IXUSR; - if (perms & ReadGroupPerm) - mode |= S_IRGRP; - if (perms & WriteGroupPerm) - mode |= S_IWGRP; - if (perms & ExeGroupPerm) - mode |= S_IXGRP; - if (perms & ReadOtherPerm) - mode |= S_IROTH; - if (perms & WriteOtherPerm) - mode |= S_IWOTH; - if (perms & ExeOtherPerm) - mode |= S_IXOTH; - if (d->fd != -1) - ret = fchmod(d->fd, mode) == 0; - else - ret = ::chmod(d->fileEntry.nativeFilePath().constData(), mode) == 0; - if (!ret) - setError(QFile::PermissionsError, qt_error_string(errno)); - return ret; -} - bool QFSFileEngine::setSize(qint64 size) { Q_D(QFSFileEngine); -- cgit v0.12 From 43866e6a2709c8098de0dfb0e51177042f046c52 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 22 Sep 2010 15:16:02 +0200 Subject: Test 'QDir::cd' a bit better --- tests/auto/qdir/tst_qdir.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 554b685..2bb0a3e 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -937,6 +937,7 @@ void tst_QDir::cd() QFETCH(QString, newDir); QDir d = startDir; + bool notUsed = d.exists(); // make sure we cache this before so we can see if 'cd' fails to flush this QCOMPARE(d.cd(cdDir), successExpected); if (successExpected) QCOMPARE(d.absolutePath(), newDir); -- cgit v0.12 From ecd4dfd5edef036a87ecd354f21d81f3f0a40f0e Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 22 Sep 2010 17:47:38 +0200 Subject: Fix QDir autotests on Windows The QFileSystemMetaData is reused when enumerating directories. Clear this content before filling it with the WIN32_FIND_DATA. Reviewed-by: Joao --- src/corelib/io/qfilesystemiterator_win.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 4050199..0be6413 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -130,6 +130,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa QString fileName = QString::fromWCharArray(findData.cFileName); fileEntry = QFileSystemEntry(dirPath + fileName); if (!fileName.endsWith(QLatin1String(".lnk"))) { + metaData = QFileSystemMetaData(); metaData.fillFromFindData(findData, true); } return true; -- cgit v0.12 From 584416b0d95063b761c6b81dbeaae325818dd9af Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 22 Sep 2010 17:47:38 +0200 Subject: Fix QDir autotests on Windows The QFileSystemMetaData is reused when enumerating directories. Clear this content before filling it with the WIN32_FIND_DATA. Reviewed-by: Joao --- src/corelib/io/qfilesystemiterator_win.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 0be6413..5fc64e4 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -129,6 +129,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa } else { QString fileName = QString::fromWCharArray(findData.cFileName); fileEntry = QFileSystemEntry(dirPath + fileName); + metaData = QFileSystemMetaData(); if (!fileName.endsWith(QLatin1String(".lnk"))) { metaData = QFileSystemMetaData(); metaData.fillFromFindData(findData, true); -- cgit v0.12 From 0ad8e783a9a60c8a77ceb2648f54cdba79c328c5 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 22 Sep 2010 17:58:11 +0200 Subject: Remove an extra initialization Reviewed-by: Joao --- src/corelib/io/qfilesystemiterator_win.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 5fc64e4..62912a6 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -131,7 +131,6 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa fileEntry = QFileSystemEntry(dirPath + fileName); metaData = QFileSystemMetaData(); if (!fileName.endsWith(QLatin1String(".lnk"))) { - metaData = QFileSystemMetaData(); metaData.fillFromFindData(findData, true); } return true; -- cgit v0.12 From d7df693b54337ea5050391751ae3243cee2f9159 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 23 Sep 2010 10:05:33 +0200 Subject: Force uppercase for drive letters in QDir::currentPath() on Windows. This was done previously for helping file dialogs and other UI elements using the path. So we need to retain this old behavior. Reviewed-by: Joao --- src/corelib/io/qfilesystemengine_win.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index cef7236..1aba4a7 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1154,6 +1154,8 @@ QFileSystemEntry QFileSystemEngine::currentPath() ret = QString::fromWCharArray(currentName, size); } } + if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) + ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. #else Q_UNUSED(fileName); //TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads -- cgit v0.12 From 52090d6e292c165bfb08140c28068b796e295b10 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Thu, 23 Sep 2010 11:14:01 +0200 Subject: Make setPermissions update meta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit in the unix QFileSystemEngine::setPermissions we now update the QFileSystemMetaData instance passed in on success, to avoid another stat later. Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index e85eb00..060cf25 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -575,7 +575,13 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per if (permissions & QFile::ExeOther) mode |= S_IXOTH; - return ::chmod(entry.nativeFilePath().constData(), mode) == 0; + bool success = ::chmod(entry.nativeFilePath().constData(), mode) == 0; + if (success && data) { + data->entryFlags &= ~QFileSystemMetaData::Permissions; + data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions)); + data->knownFlagsMask |= QFileSystemMetaData::Permissions; + } + return success; } QString QFileSystemEngine::homePath() -- cgit v0.12 From 59491b5cb9c7dc54f701ba19185fede58a7355db Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Thu, 23 Sep 2010 11:33:38 +0200 Subject: Mark the QFileSystemEngine::copyFile/unix done. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no native implementation for this (the old FSFilesystemEngine never had one either) so no code to move. Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 060cf25..c17d4c7 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -531,7 +531,10 @@ bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSy //static bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) { - return false; // TODO implement; + Q_UNUSED(source); + Q_UNUSED(target); + // # we can implement this using sendfile(2) + return false; } //static -- cgit v0.12 From 2645784f05db7b1e631621c511e94c88fc5cd211 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Thu, 23 Sep 2010 16:10:46 +0200 Subject: Move resolving names to qfilesystemengine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve username and group names code is now in the QFileSystemEngine Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemengine_unix.cpp | 53 +++++++++++++++++++++++++++++-- src/corelib/io/qfsfileengine_unix.cpp | 47 ++------------------------- 2 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index c17d4c7..1dee09b 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -45,6 +45,8 @@ #include "qfsfileengine.h" #include "qfile.h" +#include + #include // for realpath() #include #include @@ -275,13 +277,60 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) //static QString QFileSystemEngine::resolveUserName(uint userId) { - return QString(); // TODO +#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) + int size_max = sysconf(_SC_GETPW_R_SIZE_MAX); + if (size_max == -1) + size_max = 1024; + QVarLengthArray buf(size_max); +#endif + + struct passwd *pw = 0; +#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) + struct passwd entry; + getpwuid_r(userId, &entry, buf.data(), buf.size(), &pw); +#else + pw = getpwuid(userId); +#endif + if (pw) + return QFile::decodeName(QByteArray(pw->pw_name)); + return QString(); } //static QString QFileSystemEngine::resolveGroupName(uint groupId) { - return QString(); // TODO +#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) + int size_max = sysconf(_SC_GETPW_R_SIZE_MAX); + if (size_max == -1) + size_max = 1024; + QVarLengthArray buf(size_max); +#endif + +#if !defined(Q_OS_SYMBIAN) + struct group *gr = 0; +#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) + size_max = sysconf(_SC_GETGR_R_SIZE_MAX); + if (size_max == -1) + size_max = 1024; + buf.resize(size_max); + struct group entry; + // Some large systems have more members than the POSIX max size + // Loop over by doubling the buffer size (upper limit 250k) + for (unsigned size = size_max; size < 256000; size += size) + { + buf.resize(size); + // ERANGE indicates that the buffer was too small + if (!getgrgid_r(groupId, &entry, buf.data(), buf.size(), &gr) + || errno != ERANGE) + break; + } +#else + gr = getgrgid(groupId); +#endif + if (gr) + return QFile::decodeName(QByteArray(gr->gr_name)); +#endif + return QString(); } //static diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 7b7cd7f..0845cb3 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -892,50 +892,9 @@ uint QFSFileEngine::ownerId(FileOwner own) const QString QFSFileEngine::owner(FileOwner own) const { -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) - int size_max = sysconf(_SC_GETPW_R_SIZE_MAX); - if (size_max == -1) - size_max = 1024; - QVarLengthArray buf(size_max); -#endif - - if (own == OwnerUser) { - struct passwd *pw = 0; -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) - struct passwd entry; - getpwuid_r(ownerId(own), &entry, buf.data(), buf.size(), &pw); -#else - pw = getpwuid(ownerId(own)); -#endif - if (pw) - return QFile::decodeName(QByteArray(pw->pw_name)); - } else if (own == OwnerGroup) { -#if !defined(Q_OS_SYMBIAN) - struct group *gr = 0; -#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) - size_max = sysconf(_SC_GETGR_R_SIZE_MAX); - if (size_max == -1) - size_max = 1024; - buf.resize(size_max); - struct group entry; - // Some large systems have more members than the POSIX max size - // Loop over by doubling the buffer size (upper limit 250k) - for (unsigned size = size_max; size < 256000; size += size) - { - buf.resize(size); - // ERANGE indicates that the buffer was too small - if (!getgrgid_r(ownerId(own), &entry, buf.data(), buf.size(), &gr) - || errno != ERANGE) - break; - } -#else - gr = getgrgid(ownerId(own)); -#endif - if (gr) - return QFile::decodeName(QByteArray(gr->gr_name)); -#endif - } - return QString(); + if (own == OwnerUser) + return QFileSystemEngine::resolveUserName(ownerId(own)); + return QFileSystemEngine::resolveGroupName(ownerId(own)); } bool QFSFileEngine::setPermissions(uint perms) -- cgit v0.12 From 838ed9c68aef4d5a4f0b4d4dbbc1c1f7797cde91 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 29 Sep 2010 12:05:50 +0200 Subject: Compile fixes for windows --- qmake/Makefile.win32 | 1 - src/corelib/io/qfilesystemengine_win.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 9b86215..4333d45 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -89,7 +89,6 @@ QTOBJS= \ qabstractfileengine.obj \ qfsfileengine_win.obj \ qsystemlibrary.obj \ - qfsfileengine_iterator_win.obj \ qfileinfo.obj \ qglobal.obj \ qhash.obj \ diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 8fd0919..b164044 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -45,7 +45,7 @@ #include "qplatformdefs.h" #include "qabstractfileengine.h" #include "private/qfsfileengine_p.h" -#include "qfilesystemengine_p.h" +#include #include #include "qfile.h" -- cgit v0.12 From 71f04c22f128a52353f0a53d6d118375c0e99e33 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 7 Oct 2010 12:50:21 +0200 Subject: Compile fixes for mingw --- qmake/Makefile.win32-g++-sh | 4 +++ src/corelib/io/qfilesystemengine_win.cpp | 53 ------------------------------ src/corelib/io/qfilesystemiterator_win.cpp | 4 +-- src/corelib/io/qfilesystemmetadata_p.h | 53 ++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 55 deletions(-) diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index 97be5b5..2530fe8 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -62,6 +62,7 @@ QTOBJS= \ qfileinfo.o \ qabstractfileengine.o \ qfilesystementry.o \ + qfilesystemengine.o \ qfilesystemengine_win.o \ qfilesystemiterator_win.o \ qfsfileengine.o \ @@ -197,6 +198,9 @@ qabstractfileengine.o: $(SOURCE_PATH)/src/corelib/io/qabstractfileengine.cpp qfilesystementry.o: $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystementry.cpp +qfilesystemengine.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine.cpp + qfilesystemengine_win.o: $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qfilesystemengine_win.cpp diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index b164044..1f7a9b9 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -421,59 +421,6 @@ bool QFileSystemEngine::uncListSharesOnServer(const QString &server, QStringList return false; } -void QFileSystemMetaData::fillFromFileAttribute(DWORD fileAttribute,bool isDriveRoot) -{ - fileAttribute_ = fileAttribute; - // Ignore the hidden attribute for drives. - if (!isDriveRoot && (fileAttribute_ & FILE_ATTRIBUTE_HIDDEN)) - entryFlags |= HiddenAttribute; - entryFlags |= ((fileAttribute & FILE_ATTRIBUTE_DIRECTORY) ? DirectoryType: FileType); - entryFlags |= ExistsAttribute; - knownFlagsMask |= FileType | DirectoryType | HiddenAttribute | ExistsAttribute; -} - -void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType, bool isDriveRoot) -{ - fillFromFileAttribute(findData.dwFileAttributes, isDriveRoot); - creationTime_ = findData.ftCreationTime; - lastAccessTime_ = findData.ftLastAccessTime; - lastWriteTime_ = findData.ftLastWriteTime; - if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) { - size_ = 0; - } else { - size_ = findData.nFileSizeHigh; - size_ <<= 32; - size_ += findData.nFileSizeLow; - } - knownFlagsMask |= Times | SizeAttribute; - if (setLinkType) { - knownFlagsMask |= LinkType; - entryFlags &= ~LinkType; - if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) - && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK - || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { - entryFlags |= LinkType; - } - - } -} - -void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo) -{ - fillFromFileAttribute(fileInfo.dwFileAttributes); - creationTime_ = fileInfo.ftCreationTime; - lastAccessTime_ = fileInfo.ftLastAccessTime; - lastWriteTime_ = fileInfo.ftLastWriteTime; - if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) { - size_ = 0; - } else { - size_ = fileInfo.nFileSizeHigh; - size_ <<= 32; - size_ += fileInfo.nFileSizeLow; - } - knownFlagsMask |= Times | SizeAttribute; -} - void QFileSystemEngine::clearWinStatData(QFileSystemMetaData &data) { data.size_ = 0; diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 62912a6..9181789 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -66,8 +66,8 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi if (!nativePath.endsWith(QLatin1Char('\\'))) nativePath.append(QLatin1Char('\\')); nativePath.append(QLatin1Char('*')); - if (!dirPath.endsWith(QLatin1Char('//'))) - dirPath.append(QLatin1Char('//')); + if (!dirPath.endsWith(QLatin1Char('/'))) + dirPath.append(QLatin1Char('/')); if ((filters & (QDir::Dirs|QDir::Drives)) && (!(filters & (QDir::Files)))) onlyDirs = true; } diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 29ef987..24dfe6b 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -336,6 +336,59 @@ inline uint QFileSystemMetaData::ownerId(QAbstractFileEngine::FileOwner owner) c else return groupId(); } + +inline void QFileSystemMetaData::fillFromFileAttribute(DWORD fileAttribute,bool isDriveRoot) +{ + fileAttribute_ = fileAttribute; + // Ignore the hidden attribute for drives. + if (!isDriveRoot && (fileAttribute_ & FILE_ATTRIBUTE_HIDDEN)) + entryFlags |= HiddenAttribute; + entryFlags |= ((fileAttribute & FILE_ATTRIBUTE_DIRECTORY) ? DirectoryType: FileType); + entryFlags |= ExistsAttribute; + knownFlagsMask |= FileType | DirectoryType | HiddenAttribute | ExistsAttribute; +} + +inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType, bool isDriveRoot) +{ + fillFromFileAttribute(findData.dwFileAttributes, isDriveRoot); + creationTime_ = findData.ftCreationTime; + lastAccessTime_ = findData.ftLastAccessTime; + lastWriteTime_ = findData.ftLastWriteTime; + if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) { + size_ = 0; + } else { + size_ = findData.nFileSizeHigh; + size_ <<= 32; + size_ += findData.nFileSizeLow; + } + knownFlagsMask |= Times | SizeAttribute; + if (setLinkType) { + knownFlagsMask |= LinkType; + entryFlags &= ~LinkType; + if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) + && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK + || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { + entryFlags |= LinkType; + } + + } +} + +inline void QFileSystemMetaData::fillFromFindInfo(BY_HANDLE_FILE_INFORMATION &fileInfo) +{ + fillFromFileAttribute(fileInfo.dwFileAttributes); + creationTime_ = fileInfo.ftCreationTime; + lastAccessTime_ = fileInfo.ftLastAccessTime; + lastWriteTime_ = fileInfo.ftLastWriteTime; + if (fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY) { + size_ = 0; + } else { + size_ = fileInfo.nFileSizeHigh; + size_ <<= 32; + size_ += fileInfo.nFileSizeLow; + } + knownFlagsMask |= Times | SizeAttribute; +} #endif QT_END_NAMESPACE -- cgit v0.12 From b7bc57cca9e34d3622afc1c1a9ff322024f350df Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 4 Oct 2010 13:22:25 +0100 Subject: Implement error reporting for file APIs Part of the refactoring broke error reporting (false would be return on failure, but the QFile::error() would not return the right thing) A string is passed to the QFileSystemEngine functions which need to return an error, and filled in via the error code when a function fails. For windows, this is GetLastError() as for the previous workaround For unix, this is errno, as for the previous workaround For symbian, this is the integer error code returned by the function Reviewed-By: Thomas Zander Reviewed-By: Prasanth Ullattil --- src/corelib/io/qfilesystemengine_p.h | 13 ++- src/corelib/io/qfilesystemengine_symbian.cpp | 92 +++++++++++++++-- src/corelib/io/qfilesystemengine_unix.cpp | 29 ++++-- src/corelib/io/qfilesystemengine_win.cpp | 22 ++-- src/corelib/io/qfsfileengine_unix.cpp | 55 +++------- src/corelib/io/qfsfileengine_win.cpp | 20 ++-- src/s60installs/bwins/QtCoreu.def | 51 ++++++++- src/s60installs/bwins/QtDeclarativeu.def | 137 ++----------------------- src/s60installs/bwins/QtGuiu.def | 1 - src/s60installs/eabi/QtCoreu.def | 1 - src/s60installs/eabi/QtDeclarativeu.def | 148 ++------------------------- src/s60installs/eabi/QtGuiu.def | 1 - 12 files changed, 214 insertions(+), 356 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 20b664d..f4d942a 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -91,6 +91,9 @@ public: static QString owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own); static QString nativeAbsoluteFilePath(const QString &path); #endif +#ifdef Q_OS_SYMBIAN + static QString errorString(int errorcode); +#endif //homePath, rootPath and tempPath shall return clean paths static QString homePath(); static QString rootPath(); @@ -99,13 +102,13 @@ public: static bool createDirectory(const QFileSystemEntry &entry, bool createParents); static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents); - static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target); + static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString); - static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target); - static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target); - static bool removeFile(const QFileSystemEntry &entry); + static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString); + static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString); + static bool removeFile(const QFileSystemEntry &entry, QString &errorString); - static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, + static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QString &errorString, QFileSystemMetaData *data = 0); static bool setCurrentPath(const QFileSystemEntry &entry); diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index efb3539..1e6f277 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -282,49 +282,56 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } //static -bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { Q_UNUSED(source) Q_UNUSED(target) + errorString = QLatin1String("not supported"); return false; } //static -bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { - //TODO: review - should this be a singleton? + //CFileMan is allocated each time because it is not thread-safe CFileMan *fm = 0; TRAPD(err, fm = CFileMan::NewL(qt_s60GetRFs())); - if(err == KErrNone) { + if (err == KErrNone) { err = fm->Copy(qt_QString2TPtrC(source.nativeFilePath()), qt_QString2TPtrC(target.nativeFilePath()), 0); delete fm; return true; } - //TODO: error reporting d->setSymbianError(err, QFile::CopyError); + errorString = QFileSystemEngine::errorString(err); return false; } //static -bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { QString sourcepath = absoluteName(source).nativeFilePath(); QString targetpath = absoluteName(target).nativeFilePath(); RFs& fs(qt_s60GetRFs()); TInt err = fs.Rename(qt_QString2TPtrC(sourcepath), qt_QString2TPtrC(targetpath)); - return err == KErrNone; // TODO error reporting; + if (err == KErrNone) + return true; + errorString = QFileSystemEngine::errorString(err); + return false; } //static -bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QString &errorString) { QString targetpath = absoluteName(entry).nativeFilePath(); RFs& fs(qt_s60GetRFs()); TInt err = fs.Delete(qt_QString2TPtrC(targetpath)); - return err == KErrNone; // TODO error reporting; + if (err == KErrNone) + return true; + errorString = QFileSystemEngine::errorString(err); + return false; } //static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QString &errorString, QFileSystemMetaData *data) { QString targetpath = absoluteName(entry).nativeFilePath(); TUint setmask = 0; @@ -340,7 +347,10 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions)); data->knownFlagsMask |= QFileSystemMetaData::Permissions; } - return err == KErrNone; // TODO error reporting + if (err == KErrNone) + return true; + errorString = QFileSystemEngine::errorString(err); + return false; } QString QFileSystemEngine::homePath() @@ -405,4 +415,64 @@ QFileSystemEntry QFileSystemEngine::currentPath() return ret; } +QString QFileSystemEngine::errorString(int errorcode) +{ + switch (errorcode) { + case KErrNotFound: + return QLatin1String("not found"); + case KErrCancel: + return QLatin1String("cancelled"); + case KErrNoMemory: + return QLatin1String("out of memory"); + case KErrNotSupported: + return QLatin1String("not supported"); + case KErrBadHandle: + return QLatin1String("bad handle"); //KERN-EXEC 0 panic is more likely + case KErrAlreadyExists: + return QLatin1String("already exists"); + case KErrPathNotFound: + return QLatin1String("path not found"); + case KErrInUse: + return QLatin1String("in use"); + case KErrNotReady: + return QLatin1String("not ready (e.g. FS dismounted, no memory card)"); + case KErrCorrupt: + return QLatin1String("corrupt"); + case KErrAccessDenied: + return QLatin1String("access denied"); + case KErrLocked: + return QLatin1String("locked"); + case KErrWrite: + return QLatin1String("incomplete write error"); + case KErrDisMounted: + return QLatin1String("file system dismounted during operation"); //i.e. a forcible dismount was done while we had files open + case KErrEof: + return QLatin1String("end of file"); + case KErrDiskFull: + return QLatin1String("no space in file system"); + case KErrBadName: + return QLatin1String("invalid filename"); + case KErrTimedOut: + return QLatin1String("timed out"); + case KErrBadDescriptor: + return QLatin1String("bad descriptor (passed address on stack to async call?)"); + case KErrAbort: + return QLatin1String("aborted"); + case KErrTooBig: + return QLatin1String("too big"); //e.g. trying to open a >2GB file with 32 bit API + case KErrBadPower: + return QLatin1String("insufficient power"); + case KErrDirFull: + return QLatin1String("no space in directory table"); + case KErrHardwareNotAvailable: + return QLatin1String("hardware not available"); + case KErrSessionClosed: + return QLatin1String("session closed"); + case KErrPermissionDenied: + return QLatin1String("permission denied"); + default: + return QString(QLatin1String("symbian error %d")).arg(errorcode); + } +} + QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 1dee09b..7c733c4 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -572,34 +572,45 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } //static -bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { - return (::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0); + if (::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0) + return true; + errorString = qt_error_string(errno); + return false; } //static -bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { Q_UNUSED(source); Q_UNUSED(target); // # we can implement this using sendfile(2) + errorString = QLatin1String("Not implemented!") return false; } //static -bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { - return (::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0); + if (::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0) + return true; + errorString = qt_error_string(errno); + return false; } //static -bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QString &errorString) { - return (unlink(entry.nativeFilePath().constData()) == 0); + if (unlink(entry.nativeFilePath().constData()) == 0) + return true; + errorString = qt_error_string(errno); + return false; + } //static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QFileSystemMetaData *data) +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QString &errorString, QFileSystemMetaData *data) { mode_t mode = 0; if (permissions & QFile::ReadOwner) @@ -633,6 +644,8 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per data->entryFlags |= QFileSystemMetaData::MetaDataFlag(uint(permissions)); data->knownFlagsMask |= QFileSystemMetaData::Permissions; } + if (!success) + errorString = qt_error_string(errno); return success; } diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 1f7a9b9..5cc7395 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1115,36 +1115,43 @@ QFileSystemEntry QFileSystemEngine::currentPath() } //static -bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { + errorString = QLatin1String("not implemented"); return false; // TODO implement; } //static -bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { bool ret = ::CopyFile((wchar_t*)source.nativeFilePath().utf16(), (wchar_t*)target.nativeFilePath().utf16(), true) != 0; + if(!ret) + errorString = qt_error_string(::GetLastError()); return ret; } //static -bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target) +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) { bool ret = ::MoveFile((wchar_t*)source.nativeFilePath().utf16(), (wchar_t*)target.nativeFilePath().utf16()) != 0; + if(!ret) + errorString = qt_error_string(::GetLastError()); return ret; } //static -bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry) +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QString &errorString) { bool ret = ::DeleteFile((wchar_t*)entry.nativeFilePath().utf16()) != 0; + if(!ret) + errorString = qt_error_string(::GetLastError()); return ret; } //static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QString &errorString, QFileSystemMetaData *data) { Q_UNUSED(data); @@ -1160,7 +1167,10 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per if (mode == 0) // not supported return false; - return ::_wchmod((wchar_t*)entry.nativeFilePath().utf16(), mode) == 0; + bool ret = (::_wchmod((wchar_t*)entry.nativeFilePath().utf16(), mode) == 0); + if(!ret) + errorString = qt_error_string(errno); + return ret; } static inline QDateTime fileTimeToQDateTime(const FILETIME *time) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 0845cb3..acb58a5 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -588,15 +588,11 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - bool ret = QFileSystemEngine::removeFile(d->fileEntry); + QString errorString; + bool ret = QFileSystemEngine::removeFile(d->fileEntry, errorString); d->metaData.clear(); if (!ret) { -#ifdef Q_OS_SYMBIAN - //TODO: error reporting - d->setSymbianError(KErrGeneral, QFile::RemoveError, QLatin1String("remove error")); -#else - setError(QFile::RemoveError, qt_error_string(errno)); -#endif + setError(QFile::RemoveError, errorString); } return ret; } @@ -604,16 +600,10 @@ bool QFSFileEngine::remove() bool QFSFileEngine::copy(const QString &newName) { Q_D(QFSFileEngine); - bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName)); + QString error; + bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error); if (!ret) { -#ifdef Q_OS_SYMBIAN - //TODO: error reporting - d->setSymbianError(KErrGeneral, QFile::CopyError, QLatin1String("copy error")); -#else - // ### Add copy code for Unix to the filesystem engine - setError(QFile::UnspecifiedError, QLatin1String("Not implemented!")); - //setError(QFile::CopyError, qt_error_string(errno)); -#endif + setError(QFile::CopyError, error); } return ret; } @@ -621,15 +611,11 @@ bool QFSFileEngine::copy(const QString &newName) bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName)); + QString error; + bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); if (!ret) { -#ifdef Q_OS_SYMBIAN - //TODO: error reporting - d->setSymbianError(KErrGeneral, QFile::RenameError, QLatin1String("rename error")); -#else - setError(QFile::RenameError, qt_error_string(errno)); -#endif + setError(QFile::RenameError, error); } return ret; @@ -638,14 +624,10 @@ bool QFSFileEngine::rename(const QString &newName) bool QFSFileEngine::link(const QString &newName) { Q_D(QFSFileEngine); - bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName)); + QString error; + bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), error); if (!ret) { -#ifdef Q_OS_SYMBIAN - //TODO: error reporting - d->setSymbianError(KErrNotSupported, QFile::RenameError, QLatin1String("not supported")); -#else - setError(QFile::RenameError, qt_error_string(errno)); -#endif + setError(QFile::RenameError, error); } return ret; } @@ -900,14 +882,9 @@ QString QFSFileEngine::owner(FileOwner own) const bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); - if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), 0)) { - setError(QFile::PermissionsError, -#ifdef Q_OS_SYMBIAN - //TODO: connect up error reporting properly - QString()); -#else - qt_error_string(errno)); -#endif + QString error; + if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)) { + setError(QFile::PermissionsError, error); return false; } return true; @@ -940,7 +917,7 @@ bool QFSFileEngine::setSize(qint64 size) } if (!ret) { if (err) - d->setSymbianError(err, QFile::ResizeError, QString()); + setError(QFile::ResizeError, QFileSystemEngine::errorString(err)); else setError(QFile::ResizeError, qt_error_string(errno)); } diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index b2009c3..63f2a9f 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -503,27 +503,30 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - bool ret = QFileSystemEngine::removeFile(d->fileEntry); + QString error; + bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); if (!ret) - setError(QFile::RemoveError, qt_error_string()); + setError(QFile::RemoveError, error); return ret; } bool QFSFileEngine::copy(const QString ©Name) { Q_D(QFSFileEngine); - bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(copyName)); + QString error; + bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(copyName), error); if (!ret) - setError(QFile::CopyError, qt_error_string()); + setError(QFile::CopyError, error); return ret; } bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName)); + QString error; + bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); if (!ret) - setError(QFile::RenameError, qt_error_string()); + setError(QFile::RenameError, error); return ret; } @@ -851,9 +854,10 @@ QString QFSFileEngine::owner(FileOwner own) const bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); - bool ret = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms)); + QString error; + bool ret = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error); if (!ret) - setError(QFile::PermissionsError, qt_error_string(errno)); + setError(QFile::PermissionsError, error); return ret; } diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 5eeb244..052ec9a 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -59,7 +59,7 @@ EXPORTS ??0QChildEvent@@QAE@W4Type@QEvent@@PAVQObject@@@Z @ 58 NONAME ; QChildEvent::QChildEvent(enum QEvent::Type, class QObject *) ??0QCoreApplication@@IAE@AAVQCoreApplicationPrivate@@@Z @ 59 NONAME ; QCoreApplication::QCoreApplication(class QCoreApplicationPrivate &) ??0QCoreApplication@@QAE@AAHPAPAD@Z @ 60 NONAME ; QCoreApplication::QCoreApplication(int &, char * *) - ??0QCoreApplicationPrivate@@QAE@AAHPAPAD@Z @ 61 NONAME ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *) + ??0QCoreApplicationPrivate@@QAE@AAHPAPAD@Z @ 61 NONAME ABSENT ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *) ??0QCryptographicHash@@QAE@W4Algorithm@0@@Z @ 62 NONAME ; QCryptographicHash::QCryptographicHash(enum QCryptographicHash::Algorithm) ??0QDataStream@@QAE@ABVQByteArray@@@Z @ 63 NONAME ; QDataStream::QDataStream(class QByteArray const &) ??0QDataStream@@QAE@PAVQByteArray@@V?$QFlags@W4OpenModeFlag@QIODevice@@@@@Z @ 64 NONAME ; QDataStream::QDataStream(class QByteArray *, class QFlags) @@ -3123,7 +3123,7 @@ EXPORTS ?reset@QMetaProperty@@QBE_NPAVQObject@@@Z @ 3122 NONAME ; bool QMetaProperty::reset(class QObject *) const ?reset@QTextStream@@QAEXXZ @ 3123 NONAME ; void QTextStream::reset(void) ?resetCurrentSender@QObjectPrivate@@SAXPAVQObject@@PAUSender@1@1@Z @ 3124 NONAME ; void QObjectPrivate::resetCurrentSender(class QObject *, struct QObjectPrivate::Sender *, struct QObjectPrivate::Sender *) - ?resetDeleteWatch@QObjectPrivate@@SAXPAV1@PAHH@Z @ 3125 NONAME ; void QObjectPrivate::resetDeleteWatch(class QObjectPrivate *, int *, int) + ?resetDeleteWatch@QObjectPrivate@@SAXPAV1@PAHH@Z @ 3125 NONAME ABSENT ; void QObjectPrivate::resetDeleteWatch(class QObjectPrivate *, int *, int) ?resetStatus@QDataStream@@QAEXXZ @ 3126 NONAME ; void QDataStream::resetStatus(void) ?resetStatus@QTextStream@@QAEXXZ @ 3127 NONAME ; void QTextStream::resetStatus(void) ?resize@QBitArray@@QAEXH@Z @ 3128 NONAME ; void QBitArray::resize(int) @@ -3296,7 +3296,7 @@ EXPORTS ?setDefault@QLocale@@SAXABV1@@Z @ 3295 NONAME ; void QLocale::setDefault(class QLocale const &) ?setDefaultFormat@QSettings@@SAXW4Format@1@@Z @ 3296 NONAME ; void QSettings::setDefaultFormat(enum QSettings::Format) ?setDefaultState@QHistoryState@@QAEXPAVQAbstractState@@@Z @ 3297 NONAME ; void QHistoryState::setDefaultState(class QAbstractState *) - ?setDeleteWatch@QObjectPrivate@@SAPAHPAV1@PAH@Z @ 3298 NONAME ; int * QObjectPrivate::setDeleteWatch(class QObjectPrivate *, int *) + ?setDeleteWatch@QObjectPrivate@@SAPAHPAV1@PAH@Z @ 3298 NONAME ABSENT ; int * QObjectPrivate::setDeleteWatch(class QObjectPrivate *, int *) ?setDevice@QDataStream@@QAEXPAVQIODevice@@@Z @ 3299 NONAME ; void QDataStream::setDevice(class QIODevice *) ?setDevice@QTextStream@@QAEXPAVQIODevice@@@Z @ 3300 NONAME ; void QTextStream::setDevice(class QIODevice *) ?setDevice@QXmlStreamReader@@QAEXPAVQIODevice@@@Z @ 3301 NONAME ; void QXmlStreamReader::setDevice(class QIODevice *) @@ -4482,5 +4482,48 @@ EXPORTS ?textDirection@QLocale@@QBE?AW4LayoutDirection@Qt@@XZ @ 4481 NONAME ; enum Qt::LayoutDirection QLocale::textDirection(void) const ?msecsSinceReference@QElapsedTimer@@QBE_JXZ @ 4482 NONAME ; long long QElapsedTimer::msecsSinceReference(void) const ?selectThread@QEventDispatcherSymbian@@AAEAAVQSelectThread@@XZ @ 4483 NONAME ; class QSelectThread & QEventDispatcherSymbian::selectThread(void) - ?qt_symbian_SetupThreadHeap@@YAHHAAUSStdEpocThreadCreateInfo@@@Z @ 4484 NONAME ; int qt_symbian_SetupThreadHeap(int, struct SStdEpocThreadCreateInfo &) + ??0QCoreApplication@@QAE@AAHPAPADH@Z @ 4484 NONAME ; QCoreApplication::QCoreApplication(int &, char * *, int) + ??0QCoreApplicationPrivate@@QAE@AAHPAPADI@Z @ 4485 NONAME ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *, unsigned int) + ?connect@QObject@@SA_NPBV1@ABVQMetaMethod@@01W4ConnectionType@Qt@@@Z @ 4486 NONAME ; bool QObject::connect(class QObject const *, class QMetaMethod const &, class QObject const *, class QMetaMethod const &, enum Qt::ConnectionType) + ?contains@QString@@QBE?AVQBool@@ABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4487 NONAME ; class QBool QString::contains(class QStringRef const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@ABV1@W4CaseSensitivity@Qt@@@Z @ 4488 NONAME ; class QBool QStringRef::contains(class QStringRef const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@ABVQString@@W4CaseSensitivity@Qt@@@Z @ 4489 NONAME ; class QBool QStringRef::contains(class QString const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@VQChar@@W4CaseSensitivity@Qt@@@Z @ 4490 NONAME ; class QBool QStringRef::contains(class QChar, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@VQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4491 NONAME ; class QBool QStringRef::contains(class QLatin1String, enum Qt::CaseSensitivity) const + ?count@QString@@QBEHABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4492 NONAME ; int QString::count(class QStringRef const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHABV1@W4CaseSensitivity@Qt@@@Z @ 4493 NONAME ; int QStringRef::count(class QStringRef const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHABVQString@@W4CaseSensitivity@Qt@@@Z @ 4494 NONAME ; int QStringRef::count(class QString const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHVQChar@@W4CaseSensitivity@Qt@@@Z @ 4495 NONAME ; int QStringRef::count(class QChar, enum Qt::CaseSensitivity) const + ?disconnect@QObject@@SA_NPBV1@ABVQMetaMethod@@01@Z @ 4496 NONAME ; bool QObject::disconnect(class QObject const *, class QMetaMethod const &, class QObject const *, class QMetaMethod const &) + ?endsWith@QString@@QBE_NABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4497 NONAME ; bool QString::endsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NABV1@W4CaseSensitivity@Qt@@@Z @ 4498 NONAME ; bool QStringRef::endsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NABVQString@@W4CaseSensitivity@Qt@@@Z @ 4499 NONAME ; bool QStringRef::endsWith(class QString const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NVQChar@@W4CaseSensitivity@Qt@@@Z @ 4500 NONAME ; bool QStringRef::endsWith(class QChar, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NVQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4501 NONAME ; bool QStringRef::endsWith(class QLatin1String, enum Qt::CaseSensitivity) const + ?indexOf@QString@@QBEHABVQStringRef@@HW4CaseSensitivity@Qt@@@Z @ 4502 NONAME ; int QString::indexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHABV1@HW4CaseSensitivity@Qt@@@Z @ 4503 NONAME ; int QStringRef::indexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHABVQString@@HW4CaseSensitivity@Qt@@@Z @ 4504 NONAME ; int QStringRef::indexOf(class QString const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHVQChar@@HW4CaseSensitivity@Qt@@@Z @ 4505 NONAME ; int QStringRef::indexOf(class QChar, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHVQLatin1String@@HW4CaseSensitivity@Qt@@@Z @ 4506 NONAME ; int QStringRef::indexOf(class QLatin1String, int, enum Qt::CaseSensitivity) const + ?isLocalFile@QUrl@@QBE_NXZ @ 4507 NONAME ; bool QUrl::isLocalFile(void) const + ?lastIndexOf@QString@@QBEHABVQStringRef@@HW4CaseSensitivity@Qt@@@Z @ 4508 NONAME ; int QString::lastIndexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHABV1@HW4CaseSensitivity@Qt@@@Z @ 4509 NONAME ; int QStringRef::lastIndexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHABVQString@@HW4CaseSensitivity@Qt@@@Z @ 4510 NONAME ; int QStringRef::lastIndexOf(class QString const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHVQChar@@HW4CaseSensitivity@Qt@@@Z @ 4511 NONAME ; int QStringRef::lastIndexOf(class QChar, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHVQLatin1String@@HW4CaseSensitivity@Qt@@@Z @ 4512 NONAME ; int QStringRef::lastIndexOf(class QLatin1String, int, enum Qt::CaseSensitivity) const + ?lockInline@QMutex@@QAEXXZ @ 4513 NONAME ; void QMutex::lockInline(void) + ?lockInternal@QMutex@@AAEXXZ @ 4514 NONAME ; void QMutex::lockInternal(void) + ?nativeKey@QSharedMemory@@QBE?AVQString@@XZ @ 4515 NONAME ; class QString QSharedMemory::nativeKey(void) const + ?senderSignalIndex@QObject@@IBEHXZ @ 4516 NONAME ; int QObject::senderSignalIndex(void) const + ?setNativeKey@QSharedMemory@@QAEXABVQString@@@Z @ 4517 NONAME ; void QSharedMemory::setNativeKey(class QString const &) + ?startsWith@QString@@QBE_NABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4518 NONAME ; bool QString::startsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NABV1@W4CaseSensitivity@Qt@@@Z @ 4519 NONAME ; bool QStringRef::startsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NABVQString@@W4CaseSensitivity@Qt@@@Z @ 4520 NONAME ; bool QStringRef::startsWith(class QString const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NVQChar@@W4CaseSensitivity@Qt@@@Z @ 4521 NONAME ; bool QStringRef::startsWith(class QChar, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NVQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4522 NONAME ; bool QStringRef::startsWith(class QLatin1String, enum Qt::CaseSensitivity) const + ?tryLockInline@QMutex@@QAE_NXZ @ 4523 NONAME ; bool QMutex::tryLockInline(void) + ?unlockInline@QMutex@@QAEXXZ @ 4524 NONAME ; void QMutex::unlockInline(void) + ?unlockInternal@QMutex@@AAEXXZ @ 4525 NONAME ; void QMutex::unlockInternal(void) + ?waitForDone@QThreadPool@@QAE_NH@Z @ 4526 NONAME ; bool QThreadPool::waitForDone(int) + ?app_compile_version@QCoreApplicationPrivate@@2HA @ 4527 NONAME ; int QCoreApplicationPrivate::app_compile_version diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index cf0398a..cf2f325 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -142,7 +142,7 @@ EXPORTS ?setEnumOrFlag@QMetaPropertyBuilder@@QAEX_N@Z @ 141 NONAME ; void QMetaPropertyBuilder::setEnumOrFlag(bool) ?getStaticMetaObject@QDeclarativeRectangle@@SAABUQMetaObject@@XZ @ 142 NONAME ; struct QMetaObject const & QDeclarativeRectangle::getStaticMetaObject(void) ?isValid@QDeclarativeProperty@@QBE_NXZ @ 143 NONAME ; bool QDeclarativeProperty::isValid(void) const - ?isConnected@QDeclarativeDebugClient@@QBE_NXZ @ 144 NONAME ABSENT ; bool QDeclarativeDebugClient::isConnected(void) const + ?isConnected@QDeclarativeDebugClient@@QBE_NXZ @ 144 NONAME ; bool QDeclarativeDebugClient::isConnected(void) const ?enabled@QDeclarativeBinding@@QBE_NXZ @ 145 NONAME ; bool QDeclarativeBinding::enabled(void) const ?setSource@QDeclarativeView@@QAEXABVQUrl@@@Z @ 146 NONAME ; void QDeclarativeView::setSource(class QUrl const &) ??_EQDeclarativeDebugService@@UAE@I@Z @ 147 NONAME ; QDeclarativeDebugService::~QDeclarativeDebugService(unsigned int) @@ -242,7 +242,7 @@ EXPORTS ?idString@QDeclarativeDebugObjectReference@@QBE?AVQString@@XZ @ 241 NONAME ; class QString QDeclarativeDebugObjectReference::idString(void) const ?customTypeData@QDeclarativeDomObject@@QBE?AVQByteArray@@XZ @ 242 NONAME ; class QByteArray QDeclarativeDomObject::customTypeData(void) const ?stop@QDeclarativeTransition@@QAEXXZ @ 243 NONAME ; void QDeclarativeTransition::stop(void) - ?data@QDeclarativeListModel@@UBE?AV?$QHash@HVQVariant@@@@HABV?$QList@H@@@Z @ 244 NONAME ABSENT ; class QHash QDeclarativeListModel::data(int, class QList const &) const + ?data@QDeclarativeListModel@@UBE?AV?$QHash@HVQVariant@@@@HABV?$QList@H@@@Z @ 244 NONAME ; class QHash QDeclarativeListModel::data(int, class QList const &) const ?verticalCenterOffset@QDeclarativeAnchors@@QBEMXZ @ 245 NONAME ; float QDeclarativeAnchors::verticalCenterOffset(void) const ?metaObject@QDeclarativeText@@UBEPBUQMetaObject@@XZ @ 246 NONAME ; struct QMetaObject const * QDeclarativeText::metaObject(void) const ??0QDeclarativeComponent@@QAE@PAVQDeclarativeEngine@@PAVQObject@@@Z @ 247 NONAME ; QDeclarativeComponent::QDeclarativeComponent(class QDeclarativeEngine *, class QObject *) @@ -461,7 +461,7 @@ EXPORTS ?qt_metacall@QDeclarativeContext@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 460 NONAME ; int QDeclarativeContext::qt_metacall(enum QMetaObject::Call, int, void * *) ??_EQDeclarativeValueType@@UAE@I@Z @ 461 NONAME ; QDeclarativeValueType::~QDeclarativeValueType(unsigned int) ?qt_metacall@QDeclarativeState@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 462 NONAME ; int QDeclarativeState::qt_metacall(enum QMetaObject::Call, int, void * *) - ?isEnabled@QDeclarativeDebugService@@QBE_NXZ @ 463 NONAME ABSENT ; bool QDeclarativeDebugService::isEnabled(void) const + ?isEnabled@QDeclarativeDebugService@@QBE_NXZ @ 463 NONAME ; bool QDeclarativeDebugService::isEnabled(void) const ?stateChanged@QDeclarativeDebugWatch@@IAEXW4State@1@@Z @ 464 NONAME ; void QDeclarativeDebugWatch::stateChanged(enum QDeclarativeDebugWatch::State) ??0QMetaMethodBuilder@@AAE@PBVQMetaObjectBuilder@@H@Z @ 465 NONAME ; QMetaMethodBuilder::QMetaMethodBuilder(class QMetaObjectBuilder const *, int) ??4QDeclarativeListReference@@QAEAAV0@ABV0@@Z @ 466 NONAME ; class QDeclarativeListReference & QDeclarativeListReference::operator=(class QDeclarativeListReference const &) @@ -608,7 +608,7 @@ EXPORTS ??_EQDeclarativeDebugObjectExpressionWatch@@UAE@I@Z @ 607 NONAME ; QDeclarativeDebugObjectExpressionWatch::~QDeclarativeDebugObjectExpressionWatch(unsigned int) ?computeTransformOrigin@QDeclarativeItemPrivate@@QBE?AVQPointF@@XZ @ 608 NONAME ; class QPointF QDeclarativeItemPrivate::computeTransformOrigin(void) const ??0QDeclarativeListReference@@QAE@PAVQObject@@PBDPAVQDeclarativeEngine@@@Z @ 609 NONAME ; QDeclarativeListReference::QDeclarativeListReference(class QObject *, char const *, class QDeclarativeEngine *) - ?setData@QListModelInterface@@UAE_NHABV?$QHash@HVQVariant@@@@@Z @ 610 NONAME ABSENT ; bool QListModelInterface::setData(int, class QHash const &) + ?setData@QListModelInterface@@UAE_NHABV?$QHash@HVQVariant@@@@@Z @ 610 NONAME ; bool QListModelInterface::setData(int, class QHash const &) ??0QDeclarativePen@@QAE@PAVQObject@@@Z @ 611 NONAME ; QDeclarativePen::QDeclarativePen(class QObject *) ?trUtf8@QPacketProtocol@@SA?AVQString@@PBD0H@Z @ 612 NONAME ; class QString QPacketProtocol::trUtf8(char const *, char const *, int) ?setContextObject@QDeclarativeContext@@QAEXPAVQObject@@@Z @ 613 NONAME ; void QDeclarativeContext::setContextObject(class QObject *) @@ -1028,7 +1028,7 @@ EXPORTS ?qmlInfo@@YA?AVQDeclarativeInfo@@PBVQObject@@ABVQDeclarativeError@@@Z @ 1027 NONAME ; class QDeclarativeInfo qmlInfo(class QObject const *, class QDeclarativeError const &) ?staticMetaObject@QDeclarativeText@@2UQMetaObject@@B @ 1028 NONAME ; struct QMetaObject const QDeclarativeText::staticMetaObject ?color@QDeclarativeRectangle@@QBE?AVQColor@@XZ @ 1029 NONAME ; class QColor QDeclarativeRectangle::color(void) const - ?isEnabled@QDeclarativeDebugClient@@QBE_NXZ @ 1030 NONAME ABSENT ; bool QDeclarativeDebugClient::isEnabled(void) const + ?isEnabled@QDeclarativeDebugClient@@QBE_NXZ @ 1030 NONAME ; bool QDeclarativeDebugClient::isEnabled(void) const ?send@QPacketProtocol@@QAEXABVQPacket@@@Z @ 1031 NONAME ; void QPacketProtocol::send(class QPacket const &) ?width@QDeclarativePixmap@@QBEHXZ @ 1032 NONAME ; int QDeclarativePixmap::width(void) const ?error@QDeclarativeCustomParser@@IAEXABVQDeclarativeCustomParserNode@@ABVQString@@@Z @ 1033 NONAME ; void QDeclarativeCustomParser::error(class QDeclarativeCustomParserNode const &, class QString const &) @@ -1147,7 +1147,7 @@ EXPORTS ?removeNotifySignal@QMetaPropertyBuilder@@QAEXXZ @ 1146 NONAME ; void QMetaPropertyBuilder::removeNotifySignal(void) ?trUtf8@QDeclarativeDebugService@@SA?AVQString@@PBD0@Z @ 1147 NONAME ; class QString QDeclarativeDebugService::trUtf8(char const *, char const *) ?setImportPathList@QDeclarativeEngine@@QAEXABVQStringList@@@Z @ 1148 NONAME ; void QDeclarativeEngine::setImportPathList(class QStringList const &) - ?enabledChanged@QDeclarativeDebugService@@MAEX_N@Z @ 1149 NONAME ABSENT ; void QDeclarativeDebugService::enabledChanged(bool) + ?enabledChanged@QDeclarativeDebugService@@MAEX_N@Z @ 1149 NONAME ; void QDeclarativeDebugService::enabledChanged(bool) ?addWatch@QDeclarativeEngineDebug@@QAEPAVQDeclarativeDebugWatch@@ABVQDeclarativeDebugObjectReference@@PAVQObject@@@Z @ 1150 NONAME ; class QDeclarativeDebugWatch * QDeclarativeEngineDebug::addWatch(class QDeclarativeDebugObjectReference const &, class QObject *) ?asAST@Variant@QDeclarativeParser@@QBEPAVNode@AST@QDeclarativeJS@@XZ @ 1151 NONAME ; class QDeclarativeJS::AST::Node * QDeclarativeParser::Variant::asAST(void) const ?indexOfClassInfo@QMetaObjectBuilder@@QAEHABVQByteArray@@@Z @ 1152 NONAME ; int QMetaObjectBuilder::indexOfClassInfo(class QByteArray const &) @@ -1386,7 +1386,7 @@ EXPORTS ?qmlTypes@QDeclarativeMetaType@@SA?AV?$QList@PAVQDeclarativeType@@@@XZ @ 1385 NONAME ; class QList QDeclarativeMetaType::qmlTypes(void) ?valueTypeCoreIndex@QDeclarativePropertyPrivate@@SAHABVQDeclarativeProperty@@@Z @ 1386 NONAME ; int QDeclarativePropertyPrivate::valueTypeCoreIndex(class QDeclarativeProperty const &) ?writeEnumProperty@QDeclarativePropertyPrivate@@SA_NABVQMetaProperty@@HPAVQObject@@ABVQVariant@@H@Z @ 1387 NONAME ; bool QDeclarativePropertyPrivate::writeEnumProperty(class QMetaProperty const &, int, class QObject *, class QVariant const &, int) - ?setEnabled@QDeclarativeDebugClient@@QAEX_N@Z @ 1388 NONAME ABSENT ; void QDeclarativeDebugClient::setEnabled(bool) + ?setEnabled@QDeclarativeDebugClient@@QAEX_N@Z @ 1388 NONAME ; void QDeclarativeDebugClient::setEnabled(bool) ??1QMetaObjectBuilder@@UAE@XZ @ 1389 NONAME ; QMetaObjectBuilder::~QMetaObjectBuilder(void) ?tr@QDeclarativeStateOperation@@SA?AVQString@@PBD0@Z @ 1390 NONAME ; class QString QDeclarativeStateOperation::tr(char const *, char const *) ?clear@QPacket@@QAEXXZ @ 1391 NONAME ; void QPacket::clear(void) @@ -1715,127 +1715,4 @@ EXPORTS ??0QDeclarativeListModel@@AAE@PBV0@PAVQDeclarativeListModelWorkerAgent@@@Z @ 1714 NONAME ; QDeclarativeListModel::QDeclarativeListModel(class QDeclarativeListModel const *, class QDeclarativeListModelWorkerAgent *) ?inWorkerThread@QDeclarativeListModel@@ABE_NXZ @ 1715 NONAME ; bool QDeclarativeListModel::inWorkerThread(void) const ?canMove@QDeclarativeListModel@@ABE_NHHH@Z @ 1716 NONAME ; bool QDeclarativeListModel::canMove(int, int, int) const - ?getScriptEngine@QDeclarativeDebugHelper@@SAPAVQScriptEngine@@PAVQDeclarativeEngine@@@Z @ 1717 NONAME ; class QScriptEngine * QDeclarativeDebugHelper::getScriptEngine(class QDeclarativeEngine *) - ?setAnimationSlowDownFactor@QDeclarativeDebugHelper@@SAXM@Z @ 1718 NONAME ; void QDeclarativeDebugHelper::setAnimationSlowDownFactor(float) - ?add@QDeclarativeBasePositioner@@QBEPAVQDeclarativeTransition@@XZ @ 1719 NONAME ; class QDeclarativeTransition * QDeclarativeBasePositioner::add(void) const - ?setLoops@QDeclarativeAbstractAnimation@@QAEXH@Z @ 1720 NONAME ; void QDeclarativeAbstractAnimation::setLoops(int) - ?trUtf8@QDeclarativeAbstractAnimation@@SA?AVQString@@PBD0@Z @ 1721 NONAME ; class QString QDeclarativeAbstractAnimation::trUtf8(char const *, char const *) - ?tr@QDeclarativeBasePositioner@@SA?AVQString@@PBD0@Z @ 1722 NONAME ; class QString QDeclarativeBasePositioner::tr(char const *, char const *) - ?staticMetaObject@QDeclarativeAbstractAnimation@@2UQMetaObject@@B @ 1723 NONAME ; struct QMetaObject const QDeclarativeAbstractAnimation::staticMetaObject - ?setMove@QDeclarativeBasePositioner@@QAEXPAVQDeclarativeTransition@@@Z @ 1724 NONAME ; void QDeclarativeBasePositioner::setMove(class QDeclarativeTransition *) - ?setRunning@QDeclarativeTimer@@QAEX_N@Z @ 1725 NONAME ; void QDeclarativeTimer::setRunning(bool) - ?tr@QDeclarativeTimer@@SA?AVQString@@PBD0@Z @ 1726 NONAME ; class QString QDeclarativeTimer::tr(char const *, char const *) - ?qt_metacall@QDeclarativeTimer@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1727 NONAME ; int QDeclarativeTimer::qt_metacall(enum QMetaObject::Call, int, void * *) - ?setPaused@QDeclarativeAbstractAnimation@@QAEX_N@Z @ 1728 NONAME ; void QDeclarativeAbstractAnimation::setPaused(bool) - ?d_func@QDeclarativeBasePositioner@@ABEPBVQDeclarativeBasePositionerPrivate@@XZ @ 1729 NONAME ; class QDeclarativeBasePositionerPrivate const * QDeclarativeBasePositioner::d_func(void) const - ?setRepeating@QDeclarativeTimer@@QAEX_N@Z @ 1730 NONAME ; void QDeclarativeTimer::setRepeating(bool) - ?interval@QDeclarativeTimer@@QBEHXZ @ 1731 NONAME ; int QDeclarativeTimer::interval(void) const - ?start@QDeclarativeTimer@@QAEXXZ @ 1732 NONAME ; void QDeclarativeTimer::start(void) - ?transition@QDeclarativeAbstractAnimation@@UAEXAAV?$QList@VQDeclarativeAction@@@@AAV?$QList@VQDeclarativeProperty@@@@W4TransitionDirection@1@@Z @ 1733 NONAME ; void QDeclarativeAbstractAnimation::transition(class QList &, class QList &, enum QDeclarativeAbstractAnimation::TransitionDirection) - ?componentComplete@QDeclarativeAbstractAnimation@@UAEXXZ @ 1734 NONAME ; void QDeclarativeAbstractAnimation::componentComplete(void) - ?statusChanged@QDeclarativeDebugService@@MAEXW4Status@1@@Z @ 1735 NONAME ; void QDeclarativeDebugService::statusChanged(enum QDeclarativeDebugService::Status) - ?runningChanged@QDeclarativeAbstractAnimation@@IAEX_N@Z @ 1736 NONAME ; void QDeclarativeAbstractAnimation::runningChanged(bool) - ?trUtf8@QDeclarativeAbstractAnimation@@SA?AVQString@@PBD0H@Z @ 1737 NONAME ; class QString QDeclarativeAbstractAnimation::trUtf8(char const *, char const *, int) - ??_EQDeclarativeBasePositioner@@UAE@I@Z @ 1738 NONAME ; QDeclarativeBasePositioner::~QDeclarativeBasePositioner(unsigned int) - ?metaObject@QDeclarativeTimer@@UBEPBUQMetaObject@@XZ @ 1739 NONAME ; struct QMetaObject const * QDeclarativeTimer::metaObject(void) const - ?setGroup@QDeclarativeAbstractAnimation@@QAEXPAVQDeclarativeAnimationGroup@@@Z @ 1740 NONAME ; void QDeclarativeAbstractAnimation::setGroup(class QDeclarativeAnimationGroup *) - ?isRepeating@QDeclarativeTimer@@QBE_NXZ @ 1741 NONAME ; bool QDeclarativeTimer::isRepeating(void) const - ?setTriggeredOnStart@QDeclarativeTimer@@QAEX_N@Z @ 1742 NONAME ; void QDeclarativeTimer::setTriggeredOnStart(bool) - ?currentTime@QDeclarativeAbstractAnimation@@QAEHXZ @ 1743 NONAME ; int QDeclarativeAbstractAnimation::currentTime(void) - ?status@QDeclarativeEngineDebug@@QBE?AW4Status@1@XZ @ 1744 NONAME ; enum QDeclarativeEngineDebug::Status QDeclarativeEngineDebug::status(void) const - ??1QDeclarativeAbstractAnimation@@UAE@XZ @ 1745 NONAME ; QDeclarativeAbstractAnimation::~QDeclarativeAbstractAnimation(void) - ?triggered@QDeclarativeTimer@@IAEXXZ @ 1746 NONAME ; void QDeclarativeTimer::triggered(void) - ?getStaticMetaObject@QDeclarativeBasePositioner@@SAABUQMetaObject@@XZ @ 1747 NONAME ; struct QMetaObject const & QDeclarativeBasePositioner::getStaticMetaObject(void) - ?finished@QDeclarativeTimer@@AAEXXZ @ 1748 NONAME ; void QDeclarativeTimer::finished(void) - ?pausedChanged@QDeclarativeAbstractAnimation@@IAEX_N@Z @ 1749 NONAME ; void QDeclarativeAbstractAnimation::pausedChanged(bool) - ?complete@QDeclarativeAbstractAnimation@@QAEXXZ @ 1750 NONAME ; void QDeclarativeAbstractAnimation::complete(void) - ?setRunning@QDeclarativeAbstractAnimation@@QAEX_N@Z @ 1751 NONAME ; void QDeclarativeAbstractAnimation::setRunning(bool) - ?trUtf8@QDeclarativeBasePositioner@@SA?AVQString@@PBD0H@Z @ 1752 NONAME ; class QString QDeclarativeBasePositioner::trUtf8(char const *, char const *, int) - ?trUtf8@QDeclarativeBasePositioner@@SA?AVQString@@PBD0@Z @ 1753 NONAME ; class QString QDeclarativeBasePositioner::trUtf8(char const *, char const *) - ?completed@QDeclarativeAbstractAnimation@@IAEXXZ @ 1754 NONAME ; void QDeclarativeAbstractAnimation::completed(void) - ?trUtf8@QDeclarativeTimer@@SA?AVQString@@PBD0@Z @ 1755 NONAME ; class QString QDeclarativeTimer::trUtf8(char const *, char const *) - ?loopCountChanged@QDeclarativeAbstractAnimation@@IAEXH@Z @ 1756 NONAME ; void QDeclarativeAbstractAnimation::loopCountChanged(int) - ?repeatChanged@QDeclarativeTimer@@IAEXXZ @ 1757 NONAME ; void QDeclarativeTimer::repeatChanged(void) - ?setDisableUserControl@QDeclarativeAbstractAnimation@@QAEXXZ @ 1758 NONAME ; void QDeclarativeAbstractAnimation::setDisableUserControl(void) - ?componentComplete@QDeclarativeBasePositioner@@MAEXXZ @ 1759 NONAME ; void QDeclarativeBasePositioner::componentComplete(void) - ?setDefaultTarget@QDeclarativeAbstractAnimation@@QAEXABVQDeclarativeProperty@@@Z @ 1760 NONAME ; void QDeclarativeAbstractAnimation::setDefaultTarget(class QDeclarativeProperty const &) - ?staticMetaObject@QDeclarativeBasePositioner@@2UQMetaObject@@B @ 1761 NONAME ; struct QMetaObject const QDeclarativeBasePositioner::staticMetaObject - ?triggeredOnStart@QDeclarativeTimer@@QBE_NXZ @ 1762 NONAME ; bool QDeclarativeTimer::triggeredOnStart(void) const - ?notifyRunningChanged@QDeclarativeAbstractAnimation@@AAEX_N@Z @ 1763 NONAME ; void QDeclarativeAbstractAnimation::notifyRunningChanged(bool) - ?statusChanged@QDeclarativeDebugClient@@MAEXW4Status@1@@Z @ 1764 NONAME ; void QDeclarativeDebugClient::statusChanged(enum QDeclarativeDebugClient::Status) - ??0QDeclarativeBasePositioner@@IAE@AAVQDeclarativeBasePositionerPrivate@@W4PositionerType@0@PAVQDeclarativeItem@@@Z @ 1765 NONAME ; QDeclarativeBasePositioner::QDeclarativeBasePositioner(class QDeclarativeBasePositionerPrivate &, enum QDeclarativeBasePositioner::PositionerType, class QDeclarativeItem *) - ?componentComplete@QDeclarativeTimer@@MAEXXZ @ 1766 NONAME ; void QDeclarativeTimer::componentComplete(void) - ?tr@QDeclarativeAbstractAnimation@@SA?AVQString@@PBD0@Z @ 1767 NONAME ; class QString QDeclarativeAbstractAnimation::tr(char const *, char const *) - ?isRunning@QDeclarativeAbstractAnimation@@QBE_NXZ @ 1768 NONAME ; bool QDeclarativeAbstractAnimation::isRunning(void) const - ?d_func@QDeclarativeAbstractAnimation@@ABEPBVQDeclarativeAbstractAnimationPrivate@@XZ @ 1769 NONAME ; class QDeclarativeAbstractAnimationPrivate const * QDeclarativeAbstractAnimation::d_func(void) const - ??_EQDeclarativeAbstractAnimation@@UAE@I@Z @ 1770 NONAME ; QDeclarativeAbstractAnimation::~QDeclarativeAbstractAnimation(unsigned int) - ??0QDeclarativeBasePositioner@@QAE@W4PositionerType@0@PAVQDeclarativeItem@@@Z @ 1771 NONAME ; QDeclarativeBasePositioner::QDeclarativeBasePositioner(enum QDeclarativeBasePositioner::PositionerType, class QDeclarativeItem *) - ?qt_metacall@QDeclarativeBasePositioner@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1772 NONAME ; int QDeclarativeBasePositioner::qt_metacall(enum QMetaObject::Call, int, void * *) - ?status@QDeclarativeDebugClient@@QBE?AW4Status@1@XZ @ 1773 NONAME ; enum QDeclarativeDebugClient::Status QDeclarativeDebugClient::status(void) const - ?prePositioning@QDeclarativeBasePositioner@@IAEXXZ @ 1774 NONAME ; void QDeclarativeBasePositioner::prePositioning(void) - ?finishApplyTransitions@QDeclarativeBasePositioner@@IAEXXZ @ 1775 NONAME ; void QDeclarativeBasePositioner::finishApplyTransitions(void) - ?d_func@QDeclarativeAbstractAnimation@@AAEPAVQDeclarativeAbstractAnimationPrivate@@XZ @ 1776 NONAME ; class QDeclarativeAbstractAnimationPrivate * QDeclarativeAbstractAnimation::d_func(void) - ?componentFinalized@QDeclarativeAbstractAnimation@@AAEXXZ @ 1777 NONAME ; void QDeclarativeAbstractAnimation::componentFinalized(void) - ??_EQDeclarativeTimer@@UAE@I@Z @ 1778 NONAME ; QDeclarativeTimer::~QDeclarativeTimer(unsigned int) - ?pause@QDeclarativeAbstractAnimation@@QAEXXZ @ 1779 NONAME ; void QDeclarativeAbstractAnimation::pause(void) - ?stop@QDeclarativeTimer@@QAEXXZ @ 1780 NONAME ; void QDeclarativeTimer::stop(void) - ?timelineComplete@QDeclarativeAbstractAnimation@@AAEXXZ @ 1781 NONAME ; void QDeclarativeAbstractAnimation::timelineComplete(void) - ?d_func@QDeclarativeBasePositioner@@AAEPAVQDeclarativeBasePositionerPrivate@@XZ @ 1782 NONAME ; class QDeclarativeBasePositionerPrivate * QDeclarativeBasePositioner::d_func(void) - ?setAlwaysRunToEnd@QDeclarativeAbstractAnimation@@QAEX_N@Z @ 1783 NONAME ; void QDeclarativeAbstractAnimation::setAlwaysRunToEnd(bool) - ?classBegin@QDeclarativeAbstractAnimation@@UAEXXZ @ 1784 NONAME ; void QDeclarativeAbstractAnimation::classBegin(void) - ?d_func@QDeclarativeTimer@@AAEPAVQDeclarativeTimerPrivate@@XZ @ 1785 NONAME ; class QDeclarativeTimerPrivate * QDeclarativeTimer::d_func(void) - ?spacing@QDeclarativeBasePositioner@@QBEHXZ @ 1786 NONAME ; int QDeclarativeBasePositioner::spacing(void) const - ??0QDeclarativeAbstractAnimation@@QAE@PAVQObject@@@Z @ 1787 NONAME ; QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(class QObject *) - ?metaObject@QDeclarativeAbstractAnimation@@UBEPBUQMetaObject@@XZ @ 1788 NONAME ; struct QMetaObject const * QDeclarativeAbstractAnimation::metaObject(void) const - ?tr@QDeclarativeAbstractAnimation@@SA?AVQString@@PBD0H@Z @ 1789 NONAME ; class QString QDeclarativeAbstractAnimation::tr(char const *, char const *, int) - ?started@QDeclarativeAbstractAnimation@@IAEXXZ @ 1790 NONAME ; void QDeclarativeAbstractAnimation::started(void) - ?setInterval@QDeclarativeTimer@@QAEXH@Z @ 1791 NONAME ; void QDeclarativeTimer::setInterval(int) - ?statusChanged@QDeclarativeEngineDebug@@IAEXW4Status@1@@Z @ 1792 NONAME ; void QDeclarativeEngineDebug::statusChanged(enum QDeclarativeEngineDebug::Status) - ?d_func@QDeclarativeTimer@@ABEPBVQDeclarativeTimerPrivate@@XZ @ 1793 NONAME ; class QDeclarativeTimerPrivate const * QDeclarativeTimer::d_func(void) const - ?setSpacing@QDeclarativeBasePositioner@@QAEXH@Z @ 1794 NONAME ; void QDeclarativeBasePositioner::setSpacing(int) - ?staticMetaObject@QDeclarativeTimer@@2UQMetaObject@@B @ 1795 NONAME ; struct QMetaObject const QDeclarativeTimer::staticMetaObject - ?positionY@QDeclarativeBasePositioner@@IAEXHABVPositionedItem@1@@Z @ 1796 NONAME ; void QDeclarativeBasePositioner::positionY(int, class QDeclarativeBasePositioner::PositionedItem const &) - ?qt_metacast@QDeclarativeAbstractAnimation@@UAEPAXPBD@Z @ 1797 NONAME ; void * QDeclarativeAbstractAnimation::qt_metacast(char const *) - ?setAdd@QDeclarativeBasePositioner@@QAEXPAVQDeclarativeTransition@@@Z @ 1798 NONAME ; void QDeclarativeBasePositioner::setAdd(class QDeclarativeTransition *) - ?setCurrentTime@QDeclarativeAbstractAnimation@@QAEXH@Z @ 1799 NONAME ; void QDeclarativeAbstractAnimation::setCurrentTime(int) - ?attachedPropertiesId@QDeclarativeType@@QBEHXZ @ 1800 NONAME ; int QDeclarativeType::attachedPropertiesId(void) const - ?positionX@QDeclarativeBasePositioner@@IAEXHABVPositionedItem@1@@Z @ 1801 NONAME ; void QDeclarativeBasePositioner::positionX(int, class QDeclarativeBasePositioner::PositionedItem const &) - ?restart@QDeclarativeAbstractAnimation@@QAEXXZ @ 1802 NONAME ; void QDeclarativeAbstractAnimation::restart(void) - ?itemChange@QDeclarativeBasePositioner@@MAE?AVQVariant@@W4GraphicsItemChange@QGraphicsItem@@ABV2@@Z @ 1803 NONAME ; class QVariant QDeclarativeBasePositioner::itemChange(enum QGraphicsItem::GraphicsItemChange, class QVariant const &) - ??0QDeclarativeAbstractAnimation@@IAE@AAVQDeclarativeAbstractAnimationPrivate@@PAVQObject@@@Z @ 1804 NONAME ; QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(class QDeclarativeAbstractAnimationPrivate &, class QObject *) - ?resume@QDeclarativeAbstractAnimation@@QAEXXZ @ 1805 NONAME ; void QDeclarativeAbstractAnimation::resume(void) - ?runningChanged@QDeclarativeTimer@@IAEXXZ @ 1806 NONAME ; void QDeclarativeTimer::runningChanged(void) - ?ticked@QDeclarativeTimer@@AAEXXZ @ 1807 NONAME ; void QDeclarativeTimer::ticked(void) - ?graphicsWidgetGeometryChanged@QDeclarativeBasePositioner@@IAEXXZ @ 1808 NONAME ; void QDeclarativeBasePositioner::graphicsWidgetGeometryChanged(void) - ?trUtf8@QDeclarativeTimer@@SA?AVQString@@PBD0H@Z @ 1809 NONAME ; class QString QDeclarativeTimer::trUtf8(char const *, char const *, int) - ??0QDeclarativeTimer@@QAE@PAVQObject@@@Z @ 1810 NONAME ; QDeclarativeTimer::QDeclarativeTimer(class QObject *) - ?loops@QDeclarativeAbstractAnimation@@QBEHXZ @ 1811 NONAME ; int QDeclarativeAbstractAnimation::loops(void) const - ?setTarget@QDeclarativeAbstractAnimation@@EAEXABVQDeclarativeProperty@@@Z @ 1812 NONAME ; void QDeclarativeAbstractAnimation::setTarget(class QDeclarativeProperty const &) - ?alwaysRunToEnd@QDeclarativeAbstractAnimation@@QBE_NXZ @ 1813 NONAME ; bool QDeclarativeAbstractAnimation::alwaysRunToEnd(void) const - ?tr@QDeclarativeTimer@@SA?AVQString@@PBD0H@Z @ 1814 NONAME ; class QString QDeclarativeTimer::tr(char const *, char const *, int) - ?status@QDeclarativeDebugService@@QBE?AW4Status@1@XZ @ 1815 NONAME ; enum QDeclarativeDebugService::Status QDeclarativeDebugService::status(void) const - ?intervalChanged@QDeclarativeTimer@@IAEXXZ @ 1816 NONAME ; void QDeclarativeTimer::intervalChanged(void) - ?isPaused@QDeclarativeAbstractAnimation@@QBE_NXZ @ 1817 NONAME ; bool QDeclarativeAbstractAnimation::isPaused(void) const - ?getStaticMetaObject@QDeclarativeAbstractAnimation@@SAABUQMetaObject@@XZ @ 1818 NONAME ; struct QMetaObject const & QDeclarativeAbstractAnimation::getStaticMetaObject(void) - ?group@QDeclarativeAbstractAnimation@@QBEPAVQDeclarativeAnimationGroup@@XZ @ 1819 NONAME ; class QDeclarativeAnimationGroup * QDeclarativeAbstractAnimation::group(void) const - ?classBegin@QDeclarativeTimer@@MAEXXZ @ 1820 NONAME ; void QDeclarativeTimer::classBegin(void) - ?restart@QDeclarativeTimer@@QAEXXZ @ 1821 NONAME ; void QDeclarativeTimer::restart(void) - ?move@QDeclarativeBasePositioner@@QBEPAVQDeclarativeTransition@@XZ @ 1822 NONAME ; class QDeclarativeTransition * QDeclarativeBasePositioner::move(void) const - ?spacingChanged@QDeclarativeBasePositioner@@IAEXXZ @ 1823 NONAME ; void QDeclarativeBasePositioner::spacingChanged(void) - ?qt_metacast@QDeclarativeBasePositioner@@UAEPAXPBD@Z @ 1824 NONAME ; void * QDeclarativeBasePositioner::qt_metacast(char const *) - ??1QDeclarativeTimer@@UAE@XZ @ 1825 NONAME ; QDeclarativeTimer::~QDeclarativeTimer(void) - ?getStaticMetaObject@QDeclarativeTimer@@SAABUQMetaObject@@XZ @ 1826 NONAME ; struct QMetaObject const & QDeclarativeTimer::getStaticMetaObject(void) - ?tr@QDeclarativeBasePositioner@@SA?AVQString@@PBD0H@Z @ 1827 NONAME ; class QString QDeclarativeBasePositioner::tr(char const *, char const *, int) - ??1QDeclarativeBasePositioner@@UAE@XZ @ 1828 NONAME ; QDeclarativeBasePositioner::~QDeclarativeBasePositioner(void) - ?moveChanged@QDeclarativeBasePositioner@@IAEXXZ @ 1829 NONAME ; void QDeclarativeBasePositioner::moveChanged(void) - ?qt_metacast@QDeclarativeTimer@@UAEPAXPBD@Z @ 1830 NONAME ; void * QDeclarativeTimer::qt_metacast(char const *) - ?metaObject@QDeclarativeBasePositioner@@UBEPBUQMetaObject@@XZ @ 1831 NONAME ; struct QMetaObject const * QDeclarativeBasePositioner::metaObject(void) const - ?alwaysRunToEndChanged@QDeclarativeAbstractAnimation@@IAEX_N@Z @ 1832 NONAME ; void QDeclarativeAbstractAnimation::alwaysRunToEndChanged(bool) - ?triggeredOnStartChanged@QDeclarativeTimer@@IAEXXZ @ 1833 NONAME ; void QDeclarativeTimer::triggeredOnStartChanged(void) - ?isRunning@QDeclarativeTimer@@QBE_NXZ @ 1834 NONAME ; bool QDeclarativeTimer::isRunning(void) const - ?update@QDeclarativeTimer@@AAEXXZ @ 1835 NONAME ; void QDeclarativeTimer::update(void) - ?stop@QDeclarativeAbstractAnimation@@QAEXXZ @ 1836 NONAME ; void QDeclarativeAbstractAnimation::stop(void) - ?addChanged@QDeclarativeBasePositioner@@IAEXXZ @ 1837 NONAME ; void QDeclarativeBasePositioner::addChanged(void) - ?start@QDeclarativeAbstractAnimation@@QAEXXZ @ 1838 NONAME ; void QDeclarativeAbstractAnimation::start(void) - ?qt_metacall@QDeclarativeAbstractAnimation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1839 NONAME ; int QDeclarativeAbstractAnimation::qt_metacall(enum QMetaObject::Call, int, void * *) diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 9a61523..7805dae 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -12892,5 +12892,4 @@ EXPORTS ?setTimeout@QTapAndHoldGesture@@SAXH@Z @ 12891 NONAME ; void QTapAndHoldGesture::setTimeout(int) ?qmljsDebugArguments@QApplicationPrivate@@2VQString@@A @ 12892 NONAME ; class QString QApplicationPrivate::qmljsDebugArguments ?effectiveBoundingRect@QGraphicsItemPrivate@@QBE?AVQRectF@@PAVQGraphicsItem@@@Z @ 12893 NONAME ; class QRectF QGraphicsItemPrivate::effectiveBoundingRect(class QGraphicsItem *) const - ?lastResortFont@QFont@@QBE?AVQString@@XZ @ 12894 NONAME ; class QString QFont::lastResortFont(void) const diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index f496839..01679be 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3711,5 +3711,4 @@ EXPORTS _ZlsR11QDataStreamRK12QEasingCurve @ 3710 NONAME _ZltRK13QElapsedTimerS1_ @ 3711 NONAME _ZrsR11QDataStreamR12QEasingCurve @ 3712 NONAME - _Z26qt_symbian_SetupThreadHeapiR24SStdEpocThreadCreateInfo @ 3713 NONAME diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index d4084cc..11dee4d 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -673,7 +673,7 @@ EXPORTS _ZN22QDeclarativeTransitionD0Ev @ 672 NONAME _ZN22QDeclarativeTransitionD1Ev @ 673 NONAME _ZN22QDeclarativeTransitionD2Ev @ 674 NONAME - _ZN23QDeclarativeDebugClient10setEnabledEb @ 675 NONAME ABSENT + _ZN23QDeclarativeDebugClient10setEnabledEb @ 675 NONAME _ZN23QDeclarativeDebugClient11qt_metacallEN11QMetaObject4CallEiPPv @ 676 NONAME _ZN23QDeclarativeDebugClient11qt_metacastEPKc @ 677 NONAME _ZN23QDeclarativeDebugClient11sendMessageERK10QByteArray @ 678 NONAME @@ -766,7 +766,7 @@ EXPORTS _ZN24QDeclarativeDebugService11qt_metacallEN11QMetaObject4CallEiPPv @ 765 NONAME _ZN24QDeclarativeDebugService11qt_metacastEPKc @ 766 NONAME _ZN24QDeclarativeDebugService11sendMessageERK10QByteArray @ 767 NONAME - _ZN24QDeclarativeDebugService14enabledChangedEb @ 768 NONAME ABSENT + _ZN24QDeclarativeDebugService14enabledChangedEb @ 768 NONAME _ZN24QDeclarativeDebugService14objectToStringEP7QObject @ 769 NONAME _ZN24QDeclarativeDebugService15messageReceivedERK10QByteArray @ 770 NONAME _ZN24QDeclarativeDebugService16staticMetaObjectE @ 771 NONAME DATA 16 @@ -1351,7 +1351,7 @@ EXPORTS _ZNK21QDeclarativeDomObject8propertyERK10QByteArray @ 1350 NONAME _ZNK21QDeclarativeListModel10metaObjectEv @ 1351 NONAME _ZNK21QDeclarativeListModel3getEi @ 1352 NONAME - _ZNK21QDeclarativeListModel4dataEiRK5QListIiE @ 1353 NONAME ABSENT + _ZNK21QDeclarativeListModel4dataEiRK5QListIiE @ 1353 NONAME _ZNK21QDeclarativeListModel4dataEii @ 1354 NONAME _ZNK21QDeclarativeListModel5countEv @ 1355 NONAME _ZNK21QDeclarativeListModel5rolesEv @ 1356 NONAME @@ -1390,9 +1390,9 @@ EXPORTS _ZNK22QDeclarativeTransition7toStateEv @ 1389 NONAME _ZNK22QDeclarativeTransition9fromStateEv @ 1390 NONAME _ZNK23QDeclarativeDebugClient10metaObjectEv @ 1391 NONAME - _ZNK23QDeclarativeDebugClient11isConnectedEv @ 1392 NONAME ABSENT + _ZNK23QDeclarativeDebugClient11isConnectedEv @ 1392 NONAME _ZNK23QDeclarativeDebugClient4nameEv @ 1393 NONAME - _ZNK23QDeclarativeDebugClient9isEnabledEv @ 1394 NONAME ABSENT + _ZNK23QDeclarativeDebugClient9isEnabledEv @ 1394 NONAME _ZNK23QDeclarativeDomDocument10rootObjectEv @ 1395 NONAME _ZNK23QDeclarativeDomDocument6errorsEv @ 1396 NONAME _ZNK23QDeclarativeDomDocument7importsEv @ 1397 NONAME @@ -1427,7 +1427,7 @@ EXPORTS _ZNK24QDeclarativeCustomParser12evaluateEnumERK10QByteArray @ 1426 NONAME _ZNK24QDeclarativeDebugService10metaObjectEv @ 1427 NONAME _ZNK24QDeclarativeDebugService4nameEv @ 1428 NONAME - _ZNK24QDeclarativeDebugService9isEnabledEv @ 1429 NONAME ABSENT + _ZNK24QDeclarativeDebugService9isEnabledEv @ 1429 NONAME _ZNK24QDeclarativeDomComponent13componentRootEv @ 1430 NONAME _ZNK24QDeclarativeScriptString11scopeObjectEv @ 1431 NONAME _ZNK24QDeclarativeScriptString6scriptEv @ 1432 NONAME @@ -1747,140 +1747,4 @@ EXPORTS _ZN21QDeclarativeListModelC1EPKS_P32QDeclarativeListModelWorkerAgent @ 1746 NONAME _ZN21QDeclarativeListModelC2EPKS_P32QDeclarativeListModelWorkerAgent @ 1747 NONAME _ZNK21QDeclarativeListModel14inWorkerThreadEv @ 1748 NONAME - _ZN23QDeclarativeDebugHelper15getScriptEngineEP18QDeclarativeEngine @ 1749 NONAME - _ZN23QDeclarativeDebugHelper26setAnimationSlowDownFactorEf @ 1750 NONAME - _ZN17QDeclarativeTimer10classBeginEv @ 1751 NONAME - _ZN17QDeclarativeTimer10setRunningEb @ 1752 NONAME - _ZN17QDeclarativeTimer11qt_metacallEN11QMetaObject4CallEiPPv @ 1753 NONAME - _ZN17QDeclarativeTimer11qt_metacastEPKc @ 1754 NONAME - _ZN17QDeclarativeTimer11setIntervalEi @ 1755 NONAME - _ZN17QDeclarativeTimer12setRepeatingEb @ 1756 NONAME - _ZN17QDeclarativeTimer13repeatChangedEv @ 1757 NONAME - _ZN17QDeclarativeTimer14runningChangedEv @ 1758 NONAME - _ZN17QDeclarativeTimer15intervalChangedEv @ 1759 NONAME - _ZN17QDeclarativeTimer16staticMetaObjectE @ 1760 NONAME DATA 16 - _ZN17QDeclarativeTimer17componentCompleteEv @ 1761 NONAME - _ZN17QDeclarativeTimer19getStaticMetaObjectEv @ 1762 NONAME - _ZN17QDeclarativeTimer19setTriggeredOnStartEb @ 1763 NONAME - _ZN17QDeclarativeTimer23triggeredOnStartChangedEv @ 1764 NONAME - _ZN17QDeclarativeTimer4stopEv @ 1765 NONAME - _ZN17QDeclarativeTimer5startEv @ 1766 NONAME - _ZN17QDeclarativeTimer6tickedEv @ 1767 NONAME - _ZN17QDeclarativeTimer6updateEv @ 1768 NONAME - _ZN17QDeclarativeTimer7restartEv @ 1769 NONAME - _ZN17QDeclarativeTimer8finishedEv @ 1770 NONAME - _ZN17QDeclarativeTimer9triggeredEv @ 1771 NONAME - _ZN17QDeclarativeTimerC1EP7QObject @ 1772 NONAME - _ZN17QDeclarativeTimerC2EP7QObject @ 1773 NONAME - _ZN23QDeclarativeDebugClient13statusChangedENS_6StatusE @ 1774 NONAME - _ZN23QDeclarativeDebugClientD0Ev @ 1775 NONAME - _ZN23QDeclarativeDebugClientD1Ev @ 1776 NONAME - _ZN23QDeclarativeDebugClientD2Ev @ 1777 NONAME - _ZN23QDeclarativeEngineDebug13statusChangedENS_6StatusE @ 1778 NONAME - _ZN24QDeclarativeDebugService13statusChangedENS_6StatusE @ 1779 NONAME - _ZN24QDeclarativeDebugServiceD0Ev @ 1780 NONAME - _ZN24QDeclarativeDebugServiceD1Ev @ 1781 NONAME - _ZN24QDeclarativeDebugServiceD2Ev @ 1782 NONAME - _ZN26QDeclarativeBasePositioner10addChangedEv @ 1783 NONAME - _ZN26QDeclarativeBasePositioner10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 1784 NONAME - _ZN26QDeclarativeBasePositioner10setSpacingEi @ 1785 NONAME - _ZN26QDeclarativeBasePositioner11moveChangedEv @ 1786 NONAME - _ZN26QDeclarativeBasePositioner11qt_metacallEN11QMetaObject4CallEiPPv @ 1787 NONAME - _ZN26QDeclarativeBasePositioner11qt_metacastEPKc @ 1788 NONAME - _ZN26QDeclarativeBasePositioner14prePositioningEv @ 1789 NONAME - _ZN26QDeclarativeBasePositioner14spacingChangedEv @ 1790 NONAME - _ZN26QDeclarativeBasePositioner16staticMetaObjectE @ 1791 NONAME DATA 16 - _ZN26QDeclarativeBasePositioner17componentCompleteEv @ 1792 NONAME - _ZN26QDeclarativeBasePositioner19getStaticMetaObjectEv @ 1793 NONAME - _ZN26QDeclarativeBasePositioner22finishApplyTransitionsEv @ 1794 NONAME - _ZN26QDeclarativeBasePositioner29graphicsWidgetGeometryChangedEv @ 1795 NONAME - _ZN26QDeclarativeBasePositioner6setAddEP22QDeclarativeTransition @ 1796 NONAME - _ZN26QDeclarativeBasePositioner7setMoveEP22QDeclarativeTransition @ 1797 NONAME - _ZN26QDeclarativeBasePositioner9positionXEiRKNS_14PositionedItemE @ 1798 NONAME - _ZN26QDeclarativeBasePositioner9positionYEiRKNS_14PositionedItemE @ 1799 NONAME - _ZN26QDeclarativeBasePositionerC2ENS_14PositionerTypeEP16QDeclarativeItem @ 1800 NONAME - _ZN26QDeclarativeBasePositionerC2ER33QDeclarativeBasePositionerPrivateNS_14PositionerTypeEP16QDeclarativeItem @ 1801 NONAME - _ZN26QDeclarativeBasePositionerD0Ev @ 1802 NONAME - _ZN26QDeclarativeBasePositionerD1Ev @ 1803 NONAME - _ZN26QDeclarativeBasePositionerD2Ev @ 1804 NONAME - _ZN27QDeclarativeDebugConnectionD0Ev @ 1805 NONAME - _ZN27QDeclarativeDebugConnectionD1Ev @ 1806 NONAME - _ZN27QDeclarativeDebugConnectionD2Ev @ 1807 NONAME - _ZN29QDeclarativeAbstractAnimation10classBeginEv @ 1808 NONAME - _ZN29QDeclarativeAbstractAnimation10setRunningEb @ 1809 NONAME - _ZN29QDeclarativeAbstractAnimation10transitionER5QListI18QDeclarativeActionERS0_I20QDeclarativePropertyENS_19TransitionDirectionE @ 1810 NONAME - _ZN29QDeclarativeAbstractAnimation11currentTimeEv @ 1811 NONAME - _ZN29QDeclarativeAbstractAnimation11qt_metacallEN11QMetaObject4CallEiPPv @ 1812 NONAME - _ZN29QDeclarativeAbstractAnimation11qt_metacastEPKc @ 1813 NONAME - _ZN29QDeclarativeAbstractAnimation13pausedChangedEb @ 1814 NONAME - _ZN29QDeclarativeAbstractAnimation14runningChangedEb @ 1815 NONAME - _ZN29QDeclarativeAbstractAnimation14setCurrentTimeEi @ 1816 NONAME - _ZN29QDeclarativeAbstractAnimation16loopCountChangedEi @ 1817 NONAME - _ZN29QDeclarativeAbstractAnimation16setDefaultTargetERK20QDeclarativeProperty @ 1818 NONAME - _ZN29QDeclarativeAbstractAnimation16staticMetaObjectE @ 1819 NONAME DATA 16 - _ZN29QDeclarativeAbstractAnimation16timelineCompleteEv @ 1820 NONAME - _ZN29QDeclarativeAbstractAnimation17componentCompleteEv @ 1821 NONAME - _ZN29QDeclarativeAbstractAnimation17setAlwaysRunToEndEb @ 1822 NONAME - _ZN29QDeclarativeAbstractAnimation18componentFinalizedEv @ 1823 NONAME - _ZN29QDeclarativeAbstractAnimation19getStaticMetaObjectEv @ 1824 NONAME - _ZN29QDeclarativeAbstractAnimation20notifyRunningChangedEb @ 1825 NONAME - _ZN29QDeclarativeAbstractAnimation21alwaysRunToEndChangedEb @ 1826 NONAME - _ZN29QDeclarativeAbstractAnimation21setDisableUserControlEv @ 1827 NONAME - _ZN29QDeclarativeAbstractAnimation4stopEv @ 1828 NONAME - _ZN29QDeclarativeAbstractAnimation5pauseEv @ 1829 NONAME - _ZN29QDeclarativeAbstractAnimation5startEv @ 1830 NONAME - _ZN29QDeclarativeAbstractAnimation6resumeEv @ 1831 NONAME - _ZN29QDeclarativeAbstractAnimation7restartEv @ 1832 NONAME - _ZN29QDeclarativeAbstractAnimation7startedEv @ 1833 NONAME - _ZN29QDeclarativeAbstractAnimation8completeEv @ 1834 NONAME - _ZN29QDeclarativeAbstractAnimation8setGroupEP26QDeclarativeAnimationGroup @ 1835 NONAME - _ZN29QDeclarativeAbstractAnimation8setLoopsEi @ 1836 NONAME - _ZN29QDeclarativeAbstractAnimation9completedEv @ 1837 NONAME - _ZN29QDeclarativeAbstractAnimation9setPausedEb @ 1838 NONAME - _ZN29QDeclarativeAbstractAnimation9setTargetERK20QDeclarativeProperty @ 1839 NONAME - _ZN29QDeclarativeAbstractAnimationC2EP7QObject @ 1840 NONAME - _ZN29QDeclarativeAbstractAnimationC2ER36QDeclarativeAbstractAnimationPrivateP7QObject @ 1841 NONAME - _ZN29QDeclarativeAbstractAnimationD0Ev @ 1842 NONAME - _ZN29QDeclarativeAbstractAnimationD1Ev @ 1843 NONAME - _ZN29QDeclarativeAbstractAnimationD2Ev @ 1844 NONAME - _ZNK16QDeclarativeType20attachedPropertiesIdEv @ 1845 NONAME - _ZNK17QDeclarativeTimer10metaObjectEv @ 1846 NONAME - _ZNK17QDeclarativeTimer11isRepeatingEv @ 1847 NONAME - _ZNK17QDeclarativeTimer16triggeredOnStartEv @ 1848 NONAME - _ZNK17QDeclarativeTimer8intervalEv @ 1849 NONAME - _ZNK17QDeclarativeTimer9isRunningEv @ 1850 NONAME - _ZNK23QDeclarativeDebugClient6statusEv @ 1851 NONAME - _ZNK23QDeclarativeEngineDebug6statusEv @ 1852 NONAME - _ZNK24QDeclarativeDebugService6statusEv @ 1853 NONAME - _ZNK26QDeclarativeBasePositioner10metaObjectEv @ 1854 NONAME - _ZNK26QDeclarativeBasePositioner3addEv @ 1855 NONAME - _ZNK26QDeclarativeBasePositioner4moveEv @ 1856 NONAME - _ZNK26QDeclarativeBasePositioner7spacingEv @ 1857 NONAME - _ZNK29QDeclarativeAbstractAnimation10metaObjectEv @ 1858 NONAME - _ZNK29QDeclarativeAbstractAnimation14alwaysRunToEndEv @ 1859 NONAME - _ZNK29QDeclarativeAbstractAnimation5groupEv @ 1860 NONAME - _ZNK29QDeclarativeAbstractAnimation5loopsEv @ 1861 NONAME - _ZNK29QDeclarativeAbstractAnimation8isPausedEv @ 1862 NONAME - _ZNK29QDeclarativeAbstractAnimation9isRunningEv @ 1863 NONAME - _ZTI17QDeclarativeTimer @ 1864 NONAME - _ZTI26QDeclarativeBasePositioner @ 1865 NONAME - _ZTI29QDeclarativeAbstractAnimation @ 1866 NONAME - _ZTV17QDeclarativeTimer @ 1867 NONAME - _ZTV26QDeclarativeBasePositioner @ 1868 NONAME - _ZTV29QDeclarativeAbstractAnimation @ 1869 NONAME - _ZThn12_N29QDeclarativeAbstractAnimation10classBeginEv @ 1870 NONAME - _ZThn12_N29QDeclarativeAbstractAnimation17componentCompleteEv @ 1871 NONAME - _ZThn12_N29QDeclarativeAbstractAnimationD0Ev @ 1872 NONAME - _ZThn12_N29QDeclarativeAbstractAnimationD1Ev @ 1873 NONAME - _ZThn16_N26QDeclarativeBasePositioner17componentCompleteEv @ 1874 NONAME - _ZThn16_N26QDeclarativeBasePositionerD0Ev @ 1875 NONAME - _ZThn16_N26QDeclarativeBasePositionerD1Ev @ 1876 NONAME - _ZThn8_N17QDeclarativeTimer10classBeginEv @ 1877 NONAME - _ZThn8_N17QDeclarativeTimer17componentCompleteEv @ 1878 NONAME - _ZThn8_N26QDeclarativeBasePositioner10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 1879 NONAME - _ZThn8_N26QDeclarativeBasePositionerD0Ev @ 1880 NONAME - _ZThn8_N26QDeclarativeBasePositionerD1Ev @ 1881 NONAME - _ZThn8_N29QDeclarativeAbstractAnimation9setTargetERK20QDeclarativeProperty @ 1882 NONAME - _ZThn8_N29QDeclarativeAbstractAnimationD0Ev @ 1883 NONAME - _ZThn8_N29QDeclarativeAbstractAnimationD1Ev @ 1884 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 634b7af..4442d33 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12097,5 +12097,4 @@ EXPORTS _ZN19QApplicationPrivate19qmljsDebugArgumentsE @ 12096 NONAME DATA 4 _ZN20QGraphicsItemPrivate26childrenBoundingRectHelperEP10QTransformP6QRectFP13QGraphicsItem @ 12097 NONAME _ZNK20QGraphicsItemPrivate21effectiveBoundingRectEP13QGraphicsItem @ 12098 NONAME - _ZNK5QFont14lastResortFontEv @ 12099 NONAME -- cgit v0.12 From 36dff2ee879021bbb0d2f1ca8826088a1969e8f0 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 6 Oct 2010 11:43:53 +0100 Subject: Fix for tst_qdir cd(non existant) test case Reviewed-By: Thomas Zander --- src/corelib/io/qfilesystemengine_symbian.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 1e6f277..318a5fd 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -240,6 +240,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (err) { data.size_ = 0; data.modificationTime_ = TTime(0); + data.entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); } } return data.hasFlags(what); -- cgit v0.12 From 3f8476b9d7dc6bf45db5c3e959d7bc045099cd08 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 6 Oct 2010 11:45:03 +0100 Subject: Implement error reporting for QFile position and size functions Reviewed-By: Thomas Zander --- src/corelib/io/qfsfileengine_unix.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index acb58a5..f5d40f1 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -518,6 +518,7 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) qint64 QFSFileEnginePrivate::nativePos() const { #ifdef Q_OS_SYMBIAN + const Q_Q(QFSFileEngine); if (symbianFile.SubSessionHandle()) { #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API qint64 pos = 0; @@ -526,8 +527,7 @@ qint64 QFSFileEnginePrivate::nativePos() const #endif TInt err = symbianFile.Seek(ESeekCurrent, pos); if(err != KErrNone) { - //TODO: error reporting - //setSymbianError(err, QFile::PositionError, QLatin1String("seek failed")); + const_cast(q)->setError(QFile::PositionError, QFileSystemEngine::errorString(err)); return -1; } return pos; @@ -635,6 +635,7 @@ bool QFSFileEngine::link(const QString &newName) qint64 QFSFileEnginePrivate::nativeSize() const { #ifdef Q_OS_SYMBIAN + const Q_Q(QFSFileEngine); if (symbianFile.SubSessionHandle()) { #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API qint64 size; @@ -643,7 +644,7 @@ qint64 QFSFileEnginePrivate::nativeSize() const #endif TInt err = symbianFile.Size(size); if(err != KErrNone) { - //TODO: error reporting + const_cast(q)->setError(QFile::PositionError, QFileSystemEngine::errorString(err)); return 0; } return size; -- cgit v0.12 From c509f556628fa73192604869b3f1135af5e447ca Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 6 Oct 2010 11:46:16 +0100 Subject: Add test case for enumerating an empty directory Reviewed-By: Thomas Zander --- tests/auto/qdiriterator/tst_qdiriterator.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index d93e91e..3a696b5 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -155,6 +155,8 @@ tst_QDirIterator::tst_QDirIterator() createDirectory("foo/bar"); createFile("foo/bar/readme.txt"); + createDirectory("empty"); + #ifndef Q_NO_SYMLINKS # if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) // ### Sadly, this is a platform difference right now. @@ -296,6 +298,20 @@ void tst_QDirIterator::iterateRelativeDirectory_data() #endif "entrylist/directory/dummy," "entrylist/writable").split(','); + + QTest::newRow("empty, default") + << QString("empty") << QDirIterator::IteratorFlags(0) + << QDir::Filters(QDir::NoFilter) << QStringList("*") +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE) + << QStringList(); +#else + << QString("empty/.,empty/..").split(','); +#endif + + QTest::newRow("empty, QDir::NoDotAndDotDot") + << QString("empty") << QDirIterator::IteratorFlags(0) + << QDir::Filters(QDir::NoDotAndDotDot) << QStringList("*") + << QStringList(); } void tst_QDirIterator::iterateRelativeDirectory() -- cgit v0.12 From a9a7fa34f12c54df4951c7e3b3afd6b9712ea57a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 6 Oct 2010 12:23:14 +0100 Subject: Fix RVCT compile error in tst_collections Reviewed-By: Olivier Goffart --- tests/auto/collections/tst_collections.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp index 0adceee..82ec0fa 100644 --- a/tests/auto/collections/tst_collections.cpp +++ b/tests/auto/collections/tst_collections.cpp @@ -3632,7 +3632,7 @@ template class C> void QTBUG13079_collectionInsideCollect } -static quint32 qHash(const QTBUG13079_Node &) +quint32 qHash(const QTBUG13079_Node &) { return 0; } -- cgit v0.12 From b5e87cbc927bbc5e58574c510dbd967c46da4bee Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 6 Oct 2010 16:28:05 +0100 Subject: Fix tst_qtemporaryfile failures on symbian The path created by the _gettemp function is not a native path, as it contains the wrong slashes. So convert it back to a QString first. Check for symbian file handle in the isReallyOpen function so that reopening temp files works correctly. Reviewed-By: Thomas Zander --- src/corelib/io/qtemporaryfile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index 479ea20..79dfa35 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -325,6 +325,9 @@ bool QTemporaryFileEngine::isReallyOpen() Q_D(QFSFileEngine); if (!((0 == d->fh) && (-1 == d->fd) +#if defined (Q_OS_SYMBIAN) + && (0 == d->symbianFile.SubSessionHandle()) +#endif #if defined Q_OS_WIN && (INVALID_HANDLE_VALUE == d->fileHandle) #endif @@ -377,7 +380,7 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) d->closeFileHandle = true; // Restore the file names (open() resets them). - d->fileEntry = QFileSystemEntry(QByteArray(filename), QFileSystemEntry::FromNativePath()); //changed now! + d->fileEntry = QFileSystemEntry(QString::fromLocal8Bit(filename)); //note that filename is NOT a native path filePathIsTemplate = false; delete [] filename; return true; -- cgit v0.12 From f571cba1997d142e5c9a08472b4489de61471c76 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 6 Oct 2010 17:16:16 +0100 Subject: Remove setSymbianError function Qt autotests require the same error code on all platforms, and the OS specific error to be in text format in the errorString. Tests were failing due to QFile::error returning more detailed information than was wanted. Reviewed-By: Thomas Zander --- src/corelib/io/qfsfileengine_unix.cpp | 41 ++++------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index f5d40f1..a64f8dc 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -83,39 +83,6 @@ static bool isRelativePathSymbian(const QString& fileName) || (fileName.at(0) == QLatin1Char('/') && fileName.at(1) == QLatin1Char('/'))))); } -/*! - \internal - convert symbian error code to the one suitable for setError. - example usage: setSymbianError(err, QFile::CopyError, QLatin1String("copy error")) -*/ -void QFSFileEnginePrivate::setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString) -{ - Q_Q(QFSFileEngine); - switch (symbianError) { - case KErrNone: - q->setError(QFile::NoError, QLatin1String("")); - break; - case KErrAccessDenied: - q->setError(QFile::PermissionsError, QLatin1String("access denied")); - break; - case KErrPermissionDenied: - q->setError(QFile::PermissionsError, QLatin1String("permission denied")); - break; - case KErrAbort: - q->setError(QFile::AbortError, QLatin1String("aborted")); - break; - case KErrCancel: - q->setError(QFile::AbortError, QLatin1String("cancelled")); - break; - case KErrTimedOut: - q->setError(QFile::TimeOutError, QLatin1String("timed out")); - break; - default: - q->setError(defaultError, defaultString); - break; - } -} - #endif /*! @@ -272,7 +239,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) } if (r != KErrNone) { - setSymbianError(r, QFile::OpenError, QLatin1String("open error")); + q->setError(QFile::OpenError, QFileSystemEngine::errorString(r)); symbianFile.Close(); return false; } @@ -418,7 +385,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) TInt r = symbianFile.Read(ptr); if (r != KErrNone) { - setSymbianError(r, QFile::ReadError, QLatin1String("read error")); + q->setError(QFile::ReadError, QFileSystemEngine::errorString(r)); return -1; } return qint64(ptr.Length()); @@ -503,7 +470,7 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) TInt r = symbianFile.Write(ptr); if (r != KErrNone) { - setSymbianError(r, QFile::WriteError, QLatin1String("write error")); + q->setError(QFile::WriteError, QFileSystemEngine::errorString(r)); return -1; } return len; @@ -556,7 +523,7 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos) #endif if (r != KErrNone) { - setSymbianError(r, QFile::PositionError, QLatin1String("seek failed")); + q->setError(QFile::PositionError, QFileSystemEngine::errorString(r)); return false; } return true; -- cgit v0.12 From a3427f351c1cfde94c5d55c03ba1a82c56d9b53d Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Thu, 7 Oct 2010 15:45:32 +0200 Subject: Fix compile --- src/corelib/io/qfilesystemengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 7c733c4..213fdc3 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -586,7 +586,7 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst Q_UNUSED(source); Q_UNUSED(target); // # we can implement this using sendfile(2) - errorString = QLatin1String("Not implemented!") + errorString = QLatin1String("Not implemented!"); return false; } -- cgit v0.12 From a780773292c3a59e1500f5e36c3de729a8f45f1c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 8 Oct 2010 10:43:40 +0100 Subject: Create QSystemError class This class is for holding errors returned from system calls, which can be later converted to a string when a string is needed. This will eventually replace the setError(int,string) used in file engines so that strings are only created on demand. The scope of an error is used to distinguish error codes from the C standard library vs error codes from native calls. On some OS (e.g.windows) these error ranges overlap. Reviewed-By: joao --- src/corelib/kernel/kernel.pri | 118 +++++++++++----------- src/corelib/kernel/qsystemerror.cpp | 190 ++++++++++++++++++++++++++++++++++++ src/corelib/kernel/qsystemerror_p.h | 107 ++++++++++++++++++++ 3 files changed, 357 insertions(+), 58 deletions(-) create mode 100644 src/corelib/kernel/qsystemerror.cpp create mode 100644 src/corelib/kernel/qsystemerror_p.h diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri index 1851e04..bd674a5 100644 --- a/src/corelib/kernel/kernel.pri +++ b/src/corelib/kernel/kernel.pri @@ -1,81 +1,83 @@ # Qt core object module HEADERS += \ - kernel/qabstracteventdispatcher.h \ + kernel/qabstracteventdispatcher.h \ kernel/qabstractitemmodel.h \ kernel/qabstractitemmodel_p.h \ - kernel/qbasictimer.h \ - kernel/qeventloop.h\ - kernel/qpointer.h \ + kernel/qbasictimer.h \ + kernel/qeventloop.h\ + kernel/qpointer.h \ kernel/qcorecmdlineargs_p.h \ - kernel/qcoreapplication.h \ - kernel/qcoreevent.h \ - kernel/qmetaobject.h \ - kernel/qmetatype.h \ - kernel/qmimedata.h \ - kernel/qobject.h \ - kernel/qobjectdefs.h \ - kernel/qsignalmapper.h \ - kernel/qsocketnotifier.h \ - kernel/qtimer.h \ - kernel/qtranslator.h \ + kernel/qcoreapplication.h \ + kernel/qcoreevent.h \ + kernel/qmetaobject.h \ + kernel/qmetatype.h \ + kernel/qmimedata.h \ + kernel/qobject.h \ + kernel/qobjectdefs.h \ + kernel/qsignalmapper.h \ + kernel/qsocketnotifier.h \ + kernel/qtimer.h \ + kernel/qtranslator.h \ kernel/qtranslator_p.h \ kernel/qvariant.h \ - kernel/qabstracteventdispatcher_p.h \ - kernel/qcoreapplication_p.h \ - kernel/qobjectcleanuphandler.h \ + kernel/qabstracteventdispatcher_p.h \ + kernel/qcoreapplication_p.h \ + kernel/qobjectcleanuphandler.h \ kernel/qvariant_p.h \ kernel/qmetaobject_p.h \ kernel/qobject_p.h \ - kernel/qcoreglobaldata_p.h \ - kernel/qsharedmemory.h \ + kernel/qcoreglobaldata_p.h \ + kernel/qsharedmemory.h \ kernel/qsharedmemory_p.h \ kernel/qsystemsemaphore.h \ kernel/qsystemsemaphore_p.h \ kernel/qfunctions_p.h \ - kernel/qmath.h + kernel/qmath.h \ + kernel/qsystemerror_p.h SOURCES += \ - kernel/qabstracteventdispatcher.cpp \ + kernel/qabstracteventdispatcher.cpp \ kernel/qabstractitemmodel.cpp \ - kernel/qbasictimer.cpp \ - kernel/qeventloop.cpp \ - kernel/qcoreapplication.cpp \ - kernel/qcoreevent.cpp \ - kernel/qmetaobject.cpp \ - kernel/qmetatype.cpp \ - kernel/qmimedata.cpp \ - kernel/qobject.cpp \ - kernel/qobjectcleanuphandler.cpp \ - kernel/qsignalmapper.cpp \ - kernel/qsocketnotifier.cpp \ - kernel/qtimer.cpp \ - kernel/qtranslator.cpp \ - kernel/qvariant.cpp \ + kernel/qbasictimer.cpp \ + kernel/qeventloop.cpp \ + kernel/qcoreapplication.cpp \ + kernel/qcoreevent.cpp \ + kernel/qmetaobject.cpp \ + kernel/qmetatype.cpp \ + kernel/qmimedata.cpp \ + kernel/qobject.cpp \ + kernel/qobjectcleanuphandler.cpp \ + kernel/qsignalmapper.cpp \ + kernel/qsocketnotifier.cpp \ + kernel/qtimer.cpp \ + kernel/qtranslator.cpp \ + kernel/qvariant.cpp \ kernel/qcoreglobaldata.cpp \ kernel/qsharedmemory.cpp \ kernel/qsystemsemaphore.cpp \ kernel/qpointer.cpp \ - kernel/qmath.cpp + kernel/qmath.cpp \ + kernel/qsystemerror.cpp win32 { - SOURCES += \ - kernel/qeventdispatcher_win.cpp \ - kernel/qcoreapplication_win.cpp \ - kernel/qwineventnotifier_p.cpp \ + SOURCES += \ + kernel/qeventdispatcher_win.cpp \ + kernel/qcoreapplication_win.cpp \ + kernel/qwineventnotifier_p.cpp \ kernel/qsharedmemory_win.cpp \ kernel/qsystemsemaphore_win.cpp - HEADERS += \ - kernel/qeventdispatcher_win_p.h \ - kernel/qwineventnotifier_p.h + HEADERS += \ + kernel/qeventdispatcher_win_p.h \ + kernel/qwineventnotifier_p.h } wince*: { - SOURCES += \ - kernel/qfunctions_wince.cpp - HEADERS += \ - kernel/qfunctions_wince.h + SOURCES += \ + kernel/qfunctions_wince.cpp + HEADERS += \ + kernel/qfunctions_wince.h } mac:!embedded { @@ -85,18 +87,18 @@ mac:!embedded { mac { SOURCES += \ - kernel/qcore_mac.cpp + kernel/qcore_mac.cpp } unix:!symbian { - SOURCES += \ + SOURCES += \ kernel/qcore_unix.cpp \ kernel/qcrashhandler.cpp \ kernel/qsharedmemory_unix.cpp \ kernel/qsystemsemaphore_unix.cpp - HEADERS += \ + HEADERS += \ kernel/qcore_unix_p.h \ - kernel/qcrashhandler_p.h + kernel/qcrashhandler_p.h contains(QT_CONFIG, glib) { SOURCES += \ @@ -115,7 +117,7 @@ unix:!symbian { } symbian { - SOURCES += \ + SOURCES += \ kernel/qcore_unix.cpp \ kernel/qcrashhandler.cpp \ kernel/qeventdispatcher_symbian.cpp \ @@ -123,7 +125,7 @@ symbian { kernel/qsharedmemory_symbian.cpp \ kernel/qsystemsemaphore_symbian.cpp - HEADERS += \ + HEADERS += \ kernel/qcore_unix_p.h \ kernel/qcrashhandler_p.h \ kernel/qeventdispatcher_symbian_p.h \ @@ -131,9 +133,9 @@ symbian { } vxworks { - SOURCES += \ - kernel/qfunctions_vxworks.cpp - HEADERS += \ - kernel/qfunctions_vxworks.h + SOURCES += \ + kernel/qfunctions_vxworks.cpp + HEADERS += \ + kernel/qfunctions_vxworks.h } diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp new file mode 100644 index 0000000..065014a --- /dev/null +++ b/src/corelib/kernel/qsystemerror.cpp @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsystemerror_p.h" +#include + +static QString standardLibraryErrorString(int errorCode) +{ + const char *s = 0; + QString ret; + switch (errorCode) { + case 0: + break; + case EACCES: + s = QT_TRANSLATE_NOOP("QIODevice", "Permission denied"); + break; + case EMFILE: + s = QT_TRANSLATE_NOOP("QIODevice", "Too many open files"); + break; + case ENOENT: + s = QT_TRANSLATE_NOOP("QIODevice", "No such file or directory"); + break; + case ENOSPC: + s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device"); + break; + default: { + #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) + QByteArray buf(1024, '\0'); + ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf); + #else + ret = QString::fromLocal8Bit(strerror(errorCode)); + #endif + break; } + } + if (s) { + // ######## this breaks moc build currently + // ret = QCoreApplication::translate("QIODevice", s); + ret = QString::fromLatin1(s); + } + return ret.trimmed(); +} + +#ifdef Q_OS_WIN +static QString windowsErrorString(int errorCode) +{ + QString ret; + wchar_t *string = 0; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + errorCode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR)&string, + 0, + NULL); + ret = QString::fromWCharArray(string); + LocalFree((HLOCAL)string); + + if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND) + ret = QString::fromLatin1("The specified module could not be found."); + return ret; +} +#endif + +#ifdef Q_OS_SYMBIAN +static QString symbianErrorString(int errorCode) +{ + switch (errorCode) { + case KErrNotFound: + return QLatin1String("not found"); + case KErrCancel: + return QLatin1String("cancelled"); + case KErrNoMemory: + return QLatin1String("out of memory"); + case KErrNotSupported: + return QLatin1String("not supported"); + case KErrBadHandle: + return QLatin1String("bad handle"); //KERN-EXEC 0 panic is more likely + case KErrAlreadyExists: + return QLatin1String("already exists"); + case KErrPathNotFound: + return QLatin1String("path not found"); + case KErrInUse: + return QLatin1String("in use"); + case KErrNotReady: + return QLatin1String("not ready (e.g. FS dismounted, no memory card)"); + case KErrCorrupt: + return QLatin1String("corrupt"); + case KErrAccessDenied: + return QLatin1String("access denied"); + case KErrLocked: + return QLatin1String("locked"); + case KErrWrite: + return QLatin1String("incomplete write error"); + case KErrDisMounted: + return QLatin1String("file system dismounted during operation"); //i.e. a forcible dismount was done while we had files open + case KErrEof: + return QLatin1String("end of file"); + case KErrDiskFull: + return QLatin1String("no space in file system"); + case KErrBadName: + return QLatin1String("invalid filename"); + case KErrTimedOut: + return QLatin1String("timed out"); + case KErrBadDescriptor: + return QLatin1String("bad descriptor (passed address on stack to async call?)"); + case KErrAbort: + return QLatin1String("aborted"); + case KErrTooBig: + return QLatin1String("too big"); //e.g. trying to open a >2GB file with 32 bit API + case KErrBadPower: + return QLatin1String("insufficient power"); + case KErrDirFull: + return QLatin1String("no space in directory table"); + case KErrHardwareNotAvailable: + return QLatin1String("hardware not available"); + case KErrSessionClosed: + return QLatin1String("session closed"); + case KErrPermissionDenied: + return QLatin1String("permission denied"); + default: + return QString(QLatin1String("symbian error %d")).arg(errorCode); + } +} +#endif + +QString QSystemError::toString() +{ + switch(errorScope) { + case NativeError: +#if defined (Q_OS_WIN) + errorString = windowsErrorString(errorCode); + break; +#elif defined (Q_OS_SYMBIAN) + return symbianErrorString(errorCode); + break; +#else + //unix: fall through as native and standard library are the same +#endif + case StandardLibraryError: + return standardLibraryErrorString(errorCode); + break; + default: + qWarning("invalid error scope"); + //fall through + case NoError: + return QLatin1String("No error"); + break; + } +} + +QT_END_NAMESPACE + diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h new file mode 100644 index 0000000..c2a13a8 --- /dev/null +++ b/src/corelib/kernel/qsystemerror_p.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSYSTEMERROR_P_H +#define QSYSTEMERROR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_CORE_EXPORT QSystemError +{ +public: + enum ErrorScope + { + NoError, + StandardLibraryError, + NativeError + }; + + inline QSystemError(int error, ErrorScope scope); + inline QSystemError(); + + QString toString(); + inline ErrorScope scope(); + inline int error(); + + //data members + int errorCode; + ErrorScope errorScope; +}; + +QSystemError::QSystemError(int error, QSystemError::ErrorScope scope) +: errorCode(error), errorScope(scope) +{ + +} + +QSystemError::QSystemError() +: errorCode(0), errorScope(NoError) +{ + +} + +QSystemError::ErrorScope QSystemError::scope() +{ + return errorScope; +} + +int QSystemError::error() +{ + return errorCode; +} + + +QT_END_NAMESPACE + +#endif // QSYSTEMERROR_P_H -- cgit v0.12 From bb66cbc4287d17a3f368d3e46e98ca026a5332c7 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 8 Oct 2010 15:26:36 +0100 Subject: Update DEF files Reviewed-By: Trust Me --- src/s60installs/bwins/QtCoreu.def | 13 +++ src/s60installs/bwins/QtGuiu.def | 75 ++++++++++++++-- src/s60installs/bwins/QtNetworku.def | 7 ++ src/s60installs/eabi/QtCoreu.def | 56 +++++++++++- src/s60installs/eabi/QtDeclarativeu.def | 149 ++++++++++++++++++++++++++++++-- src/s60installs/eabi/QtGuiu.def | 68 +++++++++++++-- src/s60installs/eabi/QtNetworku.def | 7 ++ 7 files changed, 353 insertions(+), 22 deletions(-) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 052ec9a..4ad9fbb 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4526,4 +4526,17 @@ EXPORTS ?unlockInternal@QMutex@@AAEXXZ @ 4525 NONAME ; void QMutex::unlockInternal(void) ?waitForDone@QThreadPool@@QAE_NH@Z @ 4526 NONAME ; bool QThreadPool::waitForDone(int) ?app_compile_version@QCoreApplicationPrivate@@2HA @ 4527 NONAME ; int QCoreApplicationPrivate::app_compile_version + ??0QFileInfo@@QAE@PAVQFileInfoPrivate@@@Z @ 4528 NONAME ; QFileInfo::QFileInfo(class QFileInfoPrivate *) + ??0QSystemError@@QAE@HW4ErrorScope@0@@Z @ 4529 NONAME ; QSystemError::QSystemError(int, enum QSystemError::ErrorScope) + ??0QSystemError@@QAE@XZ @ 4530 NONAME ; QSystemError::QSystemError(void) + ?cast@QMetaObject@@QBEPBVQObject@@PBV2@@Z @ 4531 NONAME ; class QObject const * QMetaObject::cast(class QObject const *) const + ?error@QSystemError@@QAEHXZ @ 4532 NONAME ; int QSystemError::error(void) + ?qt_symbian_SetupThreadHeap@@YAHHAAUSStdEpocThreadCreateInfo@@@Z @ 4533 NONAME ; int qt_symbian_SetupThreadHeap(int, struct SStdEpocThreadCreateInfo &) + ?scope@QSystemError@@QAE?AW4ErrorScope@1@XZ @ 4534 NONAME ; enum QSystemError::ErrorScope QSystemError::scope(void) + ?toAscii@QStringRef@@QBE?AVQByteArray@@XZ @ 4535 NONAME ; class QByteArray QStringRef::toAscii(void) const + ?toLatin1@QStringRef@@QBE?AVQByteArray@@XZ @ 4536 NONAME ; class QByteArray QStringRef::toLatin1(void) const + ?toLocal8Bit@QStringRef@@QBE?AVQByteArray@@XZ @ 4537 NONAME ; class QByteArray QStringRef::toLocal8Bit(void) const + ?toString@QSystemError@@QAE?AVQString@@XZ @ 4538 NONAME ; class QString QSystemError::toString(void) + ?toUcs4@QStringRef@@QBE?AV?$QVector@I@@XZ @ 4539 NONAME ; class QVector QStringRef::toUcs4(void) const + ?toUtf8@QStringRef@@QBE?AVQByteArray@@XZ @ 4540 NONAME ; class QByteArray QStringRef::toUtf8(void) const diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index 9a61523..305952c 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -35,7 +35,7 @@ EXPORTS ??0QApplication@@QAE@AAHPAPADW4Type@0@H@Z @ 34 NONAME ; QApplication::QApplication(int &, char * *, enum QApplication::Type, int) ??0QApplication@@QAE@AAHPAPAD_NH@Z @ 35 NONAME ; QApplication::QApplication(int &, char * *, bool, int) ??0QApplication@@QAE@P6APAVCApaApplication@@XZAAHPAPADH@Z @ 36 NONAME ; QApplication::QApplication(class CApaApplication * (*)(void), int &, char * *, int) - ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@@Z @ 37 NONAME ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type) + ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@@Z @ 37 NONAME ABSENT ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type) ??0QBitmap@@QAE@ABVQPixmap@@@Z @ 38 NONAME ; QBitmap::QBitmap(class QPixmap const &) ??0QBitmap@@QAE@ABVQSize@@@Z @ 39 NONAME ; QBitmap::QBitmap(class QSize const &) ??0QBitmap@@QAE@ABVQString@@PBD@Z @ 40 NONAME ; QBitmap::QBitmap(class QString const &, char const *) @@ -2195,7 +2195,7 @@ EXPORTS ?alphaF@QColor@@QBEMXZ @ 2194 NONAME ; float QColor::alphaF(void) const ?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@I@Z @ 2195 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int) ?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@IABVQTransform@@@Z @ 2196 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int, class QTransform const &) - ?alphaRGBMapForGlyph@QFontEngine@@UAE?AVQImage@@IHABVQTransform@@@Z @ 2197 NONAME ; class QImage QFontEngine::alphaRGBMapForGlyph(unsigned int, int, class QTransform const &) + ?alphaRGBMapForGlyph@QFontEngine@@UAE?AVQImage@@IHABVQTransform@@@Z @ 2197 NONAME ABSENT ; class QImage QFontEngine::alphaRGBMapForGlyph(unsigned int, int, class QTransform const &) ?alterCharForCapitalization@QFontPrivate@@QBEXAAVQChar@@@Z @ 2198 NONAME ; void QFontPrivate::alterCharForCapitalization(class QChar &) const ?alternateBase@QPalette@@QBEABVQBrush@@XZ @ 2199 NONAME ; class QBrush const & QPalette::alternateBase(void) const ?alternatingRowColors@QAbstractItemView@@QBE_NXZ @ 2200 NONAME ; bool QAbstractItemView::alternatingRowColors(void) const @@ -10909,7 +10909,7 @@ EXPORTS ?textWidth@QTextDocument@@QBEMXZ @ 10908 NONAME ; float QTextDocument::textWidth(void) const ?texture@QBrush@@QBE?AVQPixmap@@XZ @ 10909 NONAME ; class QPixmap QBrush::texture(void) const ?textureImage@QBrush@@QBE?AVQImage@@XZ @ 10910 NONAME ; class QImage QBrush::textureImage(void) const - ?textureMapForGlyph@QTextureGlyphCache@@QBE?AVQImage@@I@Z @ 10911 NONAME ; class QImage QTextureGlyphCache::textureMapForGlyph(unsigned int) const + ?textureMapForGlyph@QTextureGlyphCache@@QBE?AVQImage@@I@Z @ 10911 NONAME ABSENT ; class QImage QTextureGlyphCache::textureMapForGlyph(unsigned int) const ?themeName@QIcon@@SA?AVQString@@XZ @ 10912 NONAME ; class QString QIcon::themeName(void) ?themeSearchPaths@QIcon@@SA?AVQStringList@@XZ @ 10913 NONAME ; class QStringList QIcon::themeSearchPaths(void) ?tickInterval@QSlider@@QBEHXZ @ 10914 NONAME ; int QSlider::tickInterval(void) const @@ -12511,7 +12511,7 @@ EXPORTS ?staticMetaObject@QFileSystemModel@@2UQMetaObject@@B @ 12510 NONAME ; struct QMetaObject const QFileSystemModel::staticMetaObject ?staticMetaObject@QKeyEventTransition@@2UQMetaObject@@B @ 12511 NONAME ; struct QMetaObject const QKeyEventTransition::staticMetaObject ?staticMetaObject@QLayout@@2UQMetaObject@@B @ 12512 NONAME ; struct QMetaObject const QLayout::staticMetaObject - ?app_compile_version@QApplicationPrivate@@2HA @ 12513 NONAME ; int QApplicationPrivate::app_compile_version + ?app_compile_version@QApplicationPrivate@@2HA @ 12513 NONAME ABSENT ; int QApplicationPrivate::app_compile_version ?spacerItemFactoryMethod@QLayoutPrivate@@2P6APAVQSpacerItem@@PBVQLayout@@HHW4Policy@QSizePolicy@@1@ZA @ 12514 NONAME ; class QSpacerItem * (*QLayoutPrivate::spacerItemFactoryMethod)(class QLayout const *, int, int, enum QSizePolicy::Policy, enum QSizePolicy::Policy) ?allWidgets@QWidgetPrivate@@2PAV?$QSet@PAVQWidget@@@@A @ 12515 NONAME ; class QSet * QWidgetPrivate::allWidgets ?effectiveFocusWidget@QWidgetPrivate@@QAEPAVQWidget@@XZ @ 12516 NONAME ; class QWidget * QWidgetPrivate::effectiveFocusWidget(void) @@ -12522,7 +12522,7 @@ EXPORTS ?addCacheData@QVectorPath@@QBEPAUCacheEntry@1@PAVQPaintEngineEx@@PAXP6AX01@Z@Z @ 12521 NONAME ; struct QVectorPath::CacheEntry * QVectorPath::addCacheData(class QPaintEngineEx *, void *, void (*)(class QPaintEngineEx *, void *)) const ?discardUpdateRequest@QGraphicsItemPrivate@@QBE_N_N00@Z @ 12522 NONAME ; bool QGraphicsItemPrivate::discardUpdateRequest(bool, bool, bool) const ?makeCacheable@QVectorPath@@QBEXXZ @ 12523 NONAME ; void QVectorPath::makeCacheable(void) const - ??0Tab@QTextOption@@QAE@ABU01@@Z @ 12524 NONAME ; QTextOption::Tab::Tab(struct QTextOption::Tab const &) + ??0Tab@QTextOption@@QAE@ABU01@@Z @ 12524 NONAME ABSENT ; QTextOption::Tab::Tab(struct QTextOption::Tab const &) ?effectiveBoundingRect@QGraphicsItemPrivate@@QBE?AVQRectF@@ABV2@@Z @ 12525 NONAME ; class QRectF QGraphicsItemPrivate::effectiveBoundingRect(class QRectF const &) const ?glyphCache@QFontEngine@@QBEPAVQFontEngineGlyphCache@@PAXW4Type@2@ABVQTransform@@@Z @ 12526 NONAME ; class QFontEngineGlyphCache * QFontEngine::glyphCache(void *, enum QFontEngineGlyphCache::Type, class QTransform const &) const ?qt_blurImage@@YAXAAVQImage@@M_NH@Z @ 12527 NONAME ; void qt_blurImage(class QImage &, float, bool, int) @@ -12824,7 +12824,7 @@ EXPORTS ?fromImageReader@QPixmapData@@UAEXPAVQImageReader@@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 12823 NONAME ; void QPixmapData::fromImageReader(class QImageReader *, class QFlags) ?toPolygon@QBezier@@QBE?AVQPolygonF@@M@Z @ 12824 NONAME ; class QPolygonF QBezier::toPolygon(float) const ?prepare@QStaticText@@QAEXABVQTransform@@ABVQFont@@@Z @ 12825 NONAME ; void QStaticText::prepare(class QTransform const &, class QFont const &) - ?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@I@Z @ 12826 NONAME ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int) + ?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@I@Z @ 12826 NONAME ABSENT ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int) ?OpenFileL@QS60MainDocument@@UAEXAAPAVCFileStore@@AAVRFile@@@Z @ 12827 NONAME ; void QS60MainDocument::OpenFileL(class CFileStore * &, class RFile &) ?fixup@QIntValidator@@UBEXAAVQString@@@Z @ 12828 NONAME ; void QIntValidator::fixup(class QString &) const ?resetHeight@QGraphicsItemPrivate@@UAEXXZ @ 12829 NONAME ; void QGraphicsItemPrivate::resetHeight(void) @@ -12893,4 +12893,67 @@ EXPORTS ?qmljsDebugArguments@QApplicationPrivate@@2VQString@@A @ 12892 NONAME ; class QString QApplicationPrivate::qmljsDebugArguments ?effectiveBoundingRect@QGraphicsItemPrivate@@QBE?AVQRectF@@PAVQGraphicsItem@@@Z @ 12893 NONAME ; class QRectF QGraphicsItemPrivate::effectiveBoundingRect(class QGraphicsItem *) const ?lastResortFont@QFont@@QBE?AVQString@@XZ @ 12894 NONAME ; class QString QFont::lastResortFont(void) const + ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@H@Z @ 12895 NONAME ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type, int) + ??0QGlyphs@@QAE@ABV0@@Z @ 12896 NONAME ; QGlyphs::QGlyphs(class QGlyphs const &) + ??0QGlyphs@@QAE@XZ @ 12897 NONAME ; QGlyphs::QGlyphs(void) + ??1QGlyphs@@QAE@XZ @ 12898 NONAME ; QGlyphs::~QGlyphs(void) + ??4QGlyphs@@QAEAAV0@ABV0@@Z @ 12899 NONAME ; class QGlyphs & QGlyphs::operator=(class QGlyphs const &) + ??6@YA?AVQDebug@@V0@PBVQSymbianEvent@@@Z @ 12900 NONAME ; class QDebug operator<<(class QDebug, class QSymbianEvent const *) + ??8QGlyphs@@QBE_NABV0@@Z @ 12901 NONAME ; bool QGlyphs::operator==(class QGlyphs const &) const + ??9QGlyphs@@QBE_NABV0@@Z @ 12902 NONAME ; bool QGlyphs::operator!=(class QGlyphs const &) const + ??HQGlyphs@@ABE?AV0@ABV0@@Z @ 12903 NONAME ; class QGlyphs QGlyphs::operator+(class QGlyphs const &) const + ??MQItemSelectionRange@@QBE_NABV0@@Z @ 12904 NONAME ; bool QItemSelectionRange::operator<(class QItemSelectionRange const &) const + ??YQGlyphs@@AAEAAV0@ABV0@@Z @ 12905 NONAME ; class QGlyphs & QGlyphs::operator+=(class QGlyphs const &) + ?alphaRGBMapForGlyph@QFontEngine@@UAE?AVQImage@@IUQFixed@@HABVQTransform@@@Z @ 12906 NONAME ; class QImage QFontEngine::alphaRGBMapForGlyph(unsigned int, struct QFixed, int, class QTransform const &) + ?buddy@QAbstractProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 12907 NONAME ; class QModelIndex QAbstractProxyModel::buddy(class QModelIndex const &) const + ?calculateSubPixelPositionCount@QTextureGlyphCache@@IBEHI@Z @ 12908 NONAME ; int QTextureGlyphCache::calculateSubPixelPositionCount(unsigned int) const + ?canFetchMore@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 12909 NONAME ; bool QAbstractProxyModel::canFetchMore(class QModelIndex const &) const + ?clear@QGlyphs@@QAEXXZ @ 12910 NONAME ; void QGlyphs::clear(void) + ?clipBoundingRect@QPainter@@QBE?AVQRectF@@XZ @ 12911 NONAME ; class QRectF QPainter::clipBoundingRect(void) const + ?convertToPostscriptFontFamilyName@QFontEngine@@SA?AVQByteArray@@ABV2@@Z @ 12912 NONAME ; class QByteArray QFontEngine::convertToPostscriptFontFamilyName(class QByteArray const &) + ?createExplicitFont@QFontEngine@@UBE?AVQFont@@XZ @ 12913 NONAME ; class QFont QFontEngine::createExplicitFont(void) const + ?createExplicitFontWithName@QFontEngine@@IBE?AVQFont@@ABVQString@@@Z @ 12914 NONAME ; class QFont QFontEngine::createExplicitFontWithName(class QString const &) const + ?detach@QGlyphs@@AAEXXZ @ 12915 NONAME ; void QGlyphs::detach(void) + ?drawGlyphs@QPainter@@QAEXABVQPointF@@ABVQGlyphs@@@Z @ 12916 NONAME ; void QPainter::drawGlyphs(class QPointF const &, class QGlyphs const &) + ?fetchMore@QAbstractProxyModel@@UAEXABVQModelIndex@@@Z @ 12917 NONAME ; void QAbstractProxyModel::fetchMore(class QModelIndex const &) + ?fill@QImage@@QAEXABVQColor@@@Z @ 12918 NONAME ; void QImage::fill(class QColor const &) + ?fill@QImage@@QAEXW4GlobalColor@Qt@@@Z @ 12919 NONAME ; void QImage::fill(enum Qt::GlobalColor) + ?fillInPendingGlyphs@QTextureGlyphCache@@QAEXXZ @ 12920 NONAME ; void QTextureGlyphCache::fillInPendingGlyphs(void) + ?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@IUQFixed@@@Z @ 12921 NONAME ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int, struct QFixed) + ?font@QGlyphs@@QBE?AVQFont@@XZ @ 12922 NONAME ; class QFont QGlyphs::font(void) const + ?get@QFontPrivate@@SAPAV1@ABVQFont@@@Z @ 12923 NONAME ; class QFontPrivate * QFontPrivate::get(class QFont const &) + ?glyphIndexes@QGlyphs@@QBE?AV?$QVector@I@@XZ @ 12924 NONAME ; class QVector QGlyphs::glyphIndexes(void) const + ?glyphs@QTextFragment@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 12925 NONAME ; class QList QTextFragment::glyphs(void) const + ?glyphs@QTextLayout@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 12926 NONAME ; class QList QTextLayout::glyphs(void) const + ?glyphs@QTextLine@@ABE?AV?$QList@VQGlyphs@@@@HH@Z @ 12927 NONAME ; class QList QTextLine::glyphs(int, int) const + ?hasChildren@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 12928 NONAME ; bool QAbstractProxyModel::hasChildren(class QModelIndex const &) const + ?hasHeightForWidth@QWidgetPrivate@@UBE_NXZ @ 12929 NONAME ; bool QWidgetPrivate::hasHeightForWidth(void) const + ?hasWidthForHeight@QSizePolicy@@QBE_NXZ @ 12930 NONAME ; bool QSizePolicy::hasWidthForHeight(void) const + ?heightForWidth@QTabWidget@@UBEHH@Z @ 12931 NONAME ; int QTabWidget::heightForWidth(int) const + ?inFontUcs4@QFontMetrics@@QBE_NI@Z @ 12932 NONAME ; bool QFontMetrics::inFontUcs4(unsigned int) const + ?inFontUcs4@QFontMetricsF@@QBE_NI@Z @ 12933 NONAME ; bool QFontMetricsF::inFontUcs4(unsigned int) const + ?maxTextureHeight@QTextureGlyphCache@@UBEHXZ @ 12934 NONAME ; int QTextureGlyphCache::maxTextureHeight(void) const + ?maxTextureWidth@QTextureGlyphCache@@UBEHXZ @ 12935 NONAME ; int QTextureGlyphCache::maxTextureWidth(void) const + ?mimeData@QAbstractProxyModel@@UBEPAVQMimeData@@ABV?$QList@VQModelIndex@@@@@Z @ 12936 NONAME ; class QMimeData * QAbstractProxyModel::mimeData(class QList const &) const + ?mimeTypes@QAbstractProxyModel@@UBE?AVQStringList@@XZ @ 12937 NONAME ; class QStringList QAbstractProxyModel::mimeTypes(void) const + ?minimumSizeHint@QCheckBox@@UBE?AVQSize@@XZ @ 12938 NONAME ; class QSize QCheckBox::minimumSizeHint(void) const + ?minimumSizeHint@QRadioButton@@UBE?AVQSize@@XZ @ 12939 NONAME ; class QSize QRadioButton::minimumSizeHint(void) const + ?numberPrefix@QTextListFormat@@QBE?AVQString@@XZ @ 12940 NONAME ; class QString QTextListFormat::numberPrefix(void) const + ?numberSuffix@QTextListFormat@@QBE?AVQString@@XZ @ 12941 NONAME ; class QString QTextListFormat::numberSuffix(void) const + ?positions@QGlyphs@@QBE?AV?$QVector@VQPointF@@@@XZ @ 12942 NONAME ; class QVector QGlyphs::positions(void) const + ?removeItem@QGraphicsGridLayout@@QAEXPAVQGraphicsLayoutItem@@@Z @ 12943 NONAME ; void QGraphicsGridLayout::removeItem(class QGraphicsLayoutItem *) + ?resizeCache@QTextureGlyphCache@@QAEXHH@Z @ 12944 NONAME ; void QTextureGlyphCache::resizeCache(int, int) + ?setFont@QGlyphs@@QAEXABVQFont@@@Z @ 12945 NONAME ; void QGlyphs::setFont(class QFont const &) + ?setGlyphIndexes@QGlyphs@@QAEXABV?$QVector@I@@@Z @ 12946 NONAME ; void QGlyphs::setGlyphIndexes(class QVector const &) + ?setItemData@QAbstractProxyModel@@UAE_NABVQModelIndex@@ABV?$QMap@HVQVariant@@@@@Z @ 12947 NONAME ; bool QAbstractProxyModel::setItemData(class QModelIndex const &, class QMap const &) + ?setNumberPrefix@QTextListFormat@@QAEXABVQString@@@Z @ 12948 NONAME ; void QTextListFormat::setNumberPrefix(class QString const &) + ?setNumberSuffix@QTextListFormat@@QAEXABVQString@@@Z @ 12949 NONAME ; void QTextListFormat::setNumberSuffix(class QString const &) + ?setPositions@QGlyphs@@QAEXABV?$QVector@VQPointF@@@@@Z @ 12950 NONAME ; void QGlyphs::setPositions(class QVector const &) + ?setWidthForHeight@QSizePolicy@@QAEX_N@Z @ 12951 NONAME ; void QSizePolicy::setWidthForHeight(bool) + ?sort@QAbstractProxyModel@@UAEXHW4SortOrder@Qt@@@Z @ 12952 NONAME ; void QAbstractProxyModel::sort(int, enum Qt::SortOrder) + ?span@QAbstractProxyModel@@UBE?AVQSize@@ABVQModelIndex@@@Z @ 12953 NONAME ; class QSize QAbstractProxyModel::span(class QModelIndex const &) const + ?subPixelPositionForX@QTextureGlyphCache@@QBE?AUQFixed@@U2@@Z @ 12954 NONAME ; struct QFixed QTextureGlyphCache::subPixelPositionForX(struct QFixed) const + ?supportedDropActions@QAbstractProxyModel@@UBE?AV?$QFlags@W4DropAction@Qt@@@@XZ @ 12955 NONAME ; class QFlags QAbstractProxyModel::supportedDropActions(void) const + ?supportsSubPixelPositions@QFontEngine@@UBE_NXZ @ 12956 NONAME ; bool QFontEngine::supportsSubPixelPositions(void) const + ?textureMapForGlyph@QTextureGlyphCache@@QBE?AVQImage@@IUQFixed@@@Z @ 12957 NONAME ; class QImage QTextureGlyphCache::textureMapForGlyph(unsigned int, struct QFixed) const diff --git a/src/s60installs/bwins/QtNetworku.def b/src/s60installs/bwins/QtNetworku.def index 21718d3..ef43370 100644 --- a/src/s60installs/bwins/QtNetworku.def +++ b/src/s60installs/bwins/QtNetworku.def @@ -1145,4 +1145,11 @@ EXPORTS ?setNetworkAccessible@QNetworkAccessManager@@QAEXW4NetworkAccessibility@1@@Z @ 1144 NONAME ; void QNetworkAccessManager::setNetworkAccessible(enum QNetworkAccessManager::NetworkAccessibility) ??_EQBearerEngineFactoryInterface@@UAE@I@Z @ 1145 NONAME ; QBearerEngineFactoryInterface::~QBearerEngineFactoryInterface(unsigned int) ?enablePolling@QNetworkConfigurationManagerPrivate@@QAEXXZ @ 1146 NONAME ; void QNetworkConfigurationManagerPrivate::enablePolling(void) + ?joinMulticastGroup@QUdpSocket@@QAE_NABVQHostAddress@@@Z @ 1147 NONAME ; bool QUdpSocket::joinMulticastGroup(class QHostAddress const &) + ?joinMulticastGroup@QUdpSocket@@QAE_NABVQHostAddress@@ABVQNetworkInterface@@@Z @ 1148 NONAME ; bool QUdpSocket::joinMulticastGroup(class QHostAddress const &, class QNetworkInterface const &) + ?leaveMulticastGroup@QUdpSocket@@QAE_NABVQHostAddress@@@Z @ 1149 NONAME ; bool QUdpSocket::leaveMulticastGroup(class QHostAddress const &) + ?leaveMulticastGroup@QUdpSocket@@QAE_NABVQHostAddress@@ABVQNetworkInterface@@@Z @ 1150 NONAME ; bool QUdpSocket::leaveMulticastGroup(class QHostAddress const &, class QNetworkInterface const &) + ?multicastInterface@QUdpSocket@@QBE?AVQNetworkInterface@@XZ @ 1151 NONAME ; class QNetworkInterface QUdpSocket::multicastInterface(void) const + ?setFinished@QNetworkReply@@IAEX_N@Z @ 1152 NONAME ; void QNetworkReply::setFinished(bool) + ?setMulticastInterface@QUdpSocket@@QAEXABVQNetworkInterface@@@Z @ 1153 NONAME ; void QUdpSocket::setMulticastInterface(class QNetworkInterface const &) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 01679be..ab2c5e5 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -620,8 +620,8 @@ EXPORTS _ZN14QObjectPrivate11clearGuardsEP7QObject @ 619 NONAME _ZN14QObjectPrivate13addConnectionEiPNS_10ConnectionE @ 620 NONAME _ZN14QObjectPrivate14deleteChildrenEv @ 621 NONAME - _ZN14QObjectPrivate14setDeleteWatchEPS_Pi @ 622 NONAME - _ZN14QObjectPrivate16resetDeleteWatchEPS_Pii @ 623 NONAME + _ZN14QObjectPrivate14setDeleteWatchEPS_Pi @ 622 NONAME ABSENT + _ZN14QObjectPrivate16resetDeleteWatchEPS_Pii @ 623 NONAME ABSENT _ZN14QObjectPrivate16setCurrentSenderEP7QObjectPNS_6SenderE @ 624 NONAME ABSENT _ZN14QObjectPrivate16setParent_helperEP7QObject @ 625 NONAME _ZN14QObjectPrivate18resetCurrentSenderEP7QObjectPNS_6SenderES3_ @ 626 NONAME ABSENT @@ -1274,8 +1274,8 @@ EXPORTS _ZN23QCoreApplicationPrivate34sendThroughApplicationEventFiltersEP7QObjectP6QEvent @ 1273 NONAME _ZN23QCoreApplicationPrivate35appendApplicationPathToLibraryPathsEv @ 1274 NONAME _ZN23QCoreApplicationPrivate7attribsE @ 1275 NONAME DATA 4 - _ZN23QCoreApplicationPrivateC1ERiPPc @ 1276 NONAME - _ZN23QCoreApplicationPrivateC2ERiPPc @ 1277 NONAME + _ZN23QCoreApplicationPrivateC1ERiPPc @ 1276 NONAME ABSENT + _ZN23QCoreApplicationPrivateC2ERiPPc @ 1277 NONAME ABSENT _ZN23QCoreApplicationPrivateD0Ev @ 1278 NONAME _ZN23QCoreApplicationPrivateD1Ev @ 1279 NONAME _ZN23QCoreApplicationPrivateD2Ev @ 1280 NONAME @@ -3711,4 +3711,52 @@ EXPORTS _ZlsR11QDataStreamRK12QEasingCurve @ 3710 NONAME _ZltRK13QElapsedTimerS1_ @ 3711 NONAME _ZrsR11QDataStreamR12QEasingCurve @ 3712 NONAME + _Z26qt_symbian_SetupThreadHeapiR24SStdEpocThreadCreateInfo @ 3713 NONAME + _ZN11QThreadPool11waitForDoneEi @ 3714 NONAME + _ZN12QSystemError8toStringEv @ 3715 NONAME + _ZN13QSharedMemory12setNativeKeyERK7QString @ 3716 NONAME + _ZN16QCoreApplicationC1ERiPPci @ 3717 NONAME + _ZN16QCoreApplicationC2ERiPPci @ 3718 NONAME + _ZN23QCoreApplicationPrivate19app_compile_versionE @ 3719 NONAME DATA 4 + _ZN23QCoreApplicationPrivateC1ERiPPcj @ 3720 NONAME + _ZN23QCoreApplicationPrivateC2ERiPPcj @ 3721 NONAME + _ZN6QMutex12lockInternalEv @ 3722 NONAME + _ZN6QMutex14unlockInternalEv @ 3723 NONAME + _ZN7QObject10disconnectEPKS_RK11QMetaMethodS1_S4_ @ 3724 NONAME + _ZN7QObject7connectEPKS_RK11QMetaMethodS1_S4_N2Qt14ConnectionTypeE @ 3725 NONAME + _ZN9QFileInfoC1EP16QFileInfoPrivate @ 3726 NONAME + _ZN9QFileInfoC2EP16QFileInfoPrivate @ 3727 NONAME + _ZNK10QStringRef10startsWithE13QLatin1StringN2Qt15CaseSensitivityE @ 3728 NONAME + _ZNK10QStringRef10startsWithE5QCharN2Qt15CaseSensitivityE @ 3729 NONAME + _ZNK10QStringRef10startsWithERK7QStringN2Qt15CaseSensitivityE @ 3730 NONAME + _ZNK10QStringRef10startsWithERKS_N2Qt15CaseSensitivityE @ 3731 NONAME + _ZNK10QStringRef11lastIndexOfE13QLatin1StringiN2Qt15CaseSensitivityE @ 3732 NONAME + _ZNK10QStringRef11lastIndexOfE5QChariN2Qt15CaseSensitivityE @ 3733 NONAME + _ZNK10QStringRef11lastIndexOfERK7QStringiN2Qt15CaseSensitivityE @ 3734 NONAME + _ZNK10QStringRef11lastIndexOfERKS_iN2Qt15CaseSensitivityE @ 3735 NONAME + _ZNK10QStringRef11toLocal8BitEv @ 3736 NONAME + _ZNK10QStringRef5countE5QCharN2Qt15CaseSensitivityE @ 3737 NONAME + _ZNK10QStringRef5countERK7QStringN2Qt15CaseSensitivityE @ 3738 NONAME + _ZNK10QStringRef5countERKS_N2Qt15CaseSensitivityE @ 3739 NONAME + _ZNK10QStringRef6toUcs4Ev @ 3740 NONAME + _ZNK10QStringRef6toUtf8Ev @ 3741 NONAME + _ZNK10QStringRef7indexOfE13QLatin1StringiN2Qt15CaseSensitivityE @ 3742 NONAME + _ZNK10QStringRef7indexOfE5QChariN2Qt15CaseSensitivityE @ 3743 NONAME + _ZNK10QStringRef7indexOfERK7QStringiN2Qt15CaseSensitivityE @ 3744 NONAME + _ZNK10QStringRef7indexOfERKS_iN2Qt15CaseSensitivityE @ 3745 NONAME + _ZNK10QStringRef7toAsciiEv @ 3746 NONAME + _ZNK10QStringRef8endsWithE13QLatin1StringN2Qt15CaseSensitivityE @ 3747 NONAME + _ZNK10QStringRef8endsWithE5QCharN2Qt15CaseSensitivityE @ 3748 NONAME + _ZNK10QStringRef8endsWithERK7QStringN2Qt15CaseSensitivityE @ 3749 NONAME + _ZNK10QStringRef8endsWithERKS_N2Qt15CaseSensitivityE @ 3750 NONAME + _ZNK10QStringRef8toLatin1Ev @ 3751 NONAME + _ZNK11QMetaObject4castEPK7QObject @ 3752 NONAME + _ZNK13QSharedMemory9nativeKeyEv @ 3753 NONAME + _ZNK4QUrl11isLocalFileEv @ 3754 NONAME + _ZNK7QObject17senderSignalIndexEv @ 3755 NONAME + _ZNK7QString10startsWithERK10QStringRefN2Qt15CaseSensitivityE @ 3756 NONAME + _ZNK7QString11lastIndexOfERK10QStringRefiN2Qt15CaseSensitivityE @ 3757 NONAME + _ZNK7QString5countERK10QStringRefN2Qt15CaseSensitivityE @ 3758 NONAME + _ZNK7QString7indexOfERK10QStringRefiN2Qt15CaseSensitivityE @ 3759 NONAME + _ZNK7QString8endsWithERK10QStringRefN2Qt15CaseSensitivityE @ 3760 NONAME diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index 11dee4d..c0b43ac 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -673,7 +673,7 @@ EXPORTS _ZN22QDeclarativeTransitionD0Ev @ 672 NONAME _ZN22QDeclarativeTransitionD1Ev @ 673 NONAME _ZN22QDeclarativeTransitionD2Ev @ 674 NONAME - _ZN23QDeclarativeDebugClient10setEnabledEb @ 675 NONAME + _ZN23QDeclarativeDebugClient10setEnabledEb @ 675 NONAME ABSENT _ZN23QDeclarativeDebugClient11qt_metacallEN11QMetaObject4CallEiPPv @ 676 NONAME _ZN23QDeclarativeDebugClient11qt_metacastEPKc @ 677 NONAME _ZN23QDeclarativeDebugClient11sendMessageERK10QByteArray @ 678 NONAME @@ -766,7 +766,7 @@ EXPORTS _ZN24QDeclarativeDebugService11qt_metacallEN11QMetaObject4CallEiPPv @ 765 NONAME _ZN24QDeclarativeDebugService11qt_metacastEPKc @ 766 NONAME _ZN24QDeclarativeDebugService11sendMessageERK10QByteArray @ 767 NONAME - _ZN24QDeclarativeDebugService14enabledChangedEb @ 768 NONAME + _ZN24QDeclarativeDebugService14enabledChangedEb @ 768 NONAME ABSENT _ZN24QDeclarativeDebugService14objectToStringEP7QObject @ 769 NONAME _ZN24QDeclarativeDebugService15messageReceivedERK10QByteArray @ 770 NONAME _ZN24QDeclarativeDebugService16staticMetaObjectE @ 771 NONAME DATA 16 @@ -1351,7 +1351,7 @@ EXPORTS _ZNK21QDeclarativeDomObject8propertyERK10QByteArray @ 1350 NONAME _ZNK21QDeclarativeListModel10metaObjectEv @ 1351 NONAME _ZNK21QDeclarativeListModel3getEi @ 1352 NONAME - _ZNK21QDeclarativeListModel4dataEiRK5QListIiE @ 1353 NONAME + _ZNK21QDeclarativeListModel4dataEiRK5QListIiE @ 1353 NONAME ABSENT _ZNK21QDeclarativeListModel4dataEii @ 1354 NONAME _ZNK21QDeclarativeListModel5countEv @ 1355 NONAME _ZNK21QDeclarativeListModel5rolesEv @ 1356 NONAME @@ -1390,9 +1390,9 @@ EXPORTS _ZNK22QDeclarativeTransition7toStateEv @ 1389 NONAME _ZNK22QDeclarativeTransition9fromStateEv @ 1390 NONAME _ZNK23QDeclarativeDebugClient10metaObjectEv @ 1391 NONAME - _ZNK23QDeclarativeDebugClient11isConnectedEv @ 1392 NONAME + _ZNK23QDeclarativeDebugClient11isConnectedEv @ 1392 NONAME ABSENT _ZNK23QDeclarativeDebugClient4nameEv @ 1393 NONAME - _ZNK23QDeclarativeDebugClient9isEnabledEv @ 1394 NONAME + _ZNK23QDeclarativeDebugClient9isEnabledEv @ 1394 NONAME ABSENT _ZNK23QDeclarativeDomDocument10rootObjectEv @ 1395 NONAME _ZNK23QDeclarativeDomDocument6errorsEv @ 1396 NONAME _ZNK23QDeclarativeDomDocument7importsEv @ 1397 NONAME @@ -1427,7 +1427,7 @@ EXPORTS _ZNK24QDeclarativeCustomParser12evaluateEnumERK10QByteArray @ 1426 NONAME _ZNK24QDeclarativeDebugService10metaObjectEv @ 1427 NONAME _ZNK24QDeclarativeDebugService4nameEv @ 1428 NONAME - _ZNK24QDeclarativeDebugService9isEnabledEv @ 1429 NONAME + _ZNK24QDeclarativeDebugService9isEnabledEv @ 1429 NONAME ABSENT _ZNK24QDeclarativeDomComponent13componentRootEv @ 1430 NONAME _ZNK24QDeclarativeScriptString11scopeObjectEv @ 1431 NONAME _ZNK24QDeclarativeScriptString6scriptEv @ 1432 NONAME @@ -1747,4 +1747,141 @@ EXPORTS _ZN21QDeclarativeListModelC1EPKS_P32QDeclarativeListModelWorkerAgent @ 1746 NONAME _ZN21QDeclarativeListModelC2EPKS_P32QDeclarativeListModelWorkerAgent @ 1747 NONAME _ZNK21QDeclarativeListModel14inWorkerThreadEv @ 1748 NONAME + _ZN17QDeclarativeTimer10classBeginEv @ 1749 NONAME + _ZN17QDeclarativeTimer10setRunningEb @ 1750 NONAME + _ZN17QDeclarativeTimer11qt_metacallEN11QMetaObject4CallEiPPv @ 1751 NONAME + _ZN17QDeclarativeTimer11qt_metacastEPKc @ 1752 NONAME + _ZN17QDeclarativeTimer11setIntervalEi @ 1753 NONAME + _ZN17QDeclarativeTimer12setRepeatingEb @ 1754 NONAME + _ZN17QDeclarativeTimer13repeatChangedEv @ 1755 NONAME + _ZN17QDeclarativeTimer14runningChangedEv @ 1756 NONAME + _ZN17QDeclarativeTimer15intervalChangedEv @ 1757 NONAME + _ZN17QDeclarativeTimer16staticMetaObjectE @ 1758 NONAME DATA 16 + _ZN17QDeclarativeTimer17componentCompleteEv @ 1759 NONAME + _ZN17QDeclarativeTimer19getStaticMetaObjectEv @ 1760 NONAME + _ZN17QDeclarativeTimer19setTriggeredOnStartEb @ 1761 NONAME + _ZN17QDeclarativeTimer23triggeredOnStartChangedEv @ 1762 NONAME + _ZN17QDeclarativeTimer4stopEv @ 1763 NONAME + _ZN17QDeclarativeTimer5startEv @ 1764 NONAME + _ZN17QDeclarativeTimer6tickedEv @ 1765 NONAME + _ZN17QDeclarativeTimer6updateEv @ 1766 NONAME + _ZN17QDeclarativeTimer7restartEv @ 1767 NONAME + _ZN17QDeclarativeTimer8finishedEv @ 1768 NONAME + _ZN17QDeclarativeTimer9triggeredEv @ 1769 NONAME + _ZN17QDeclarativeTimerC1EP7QObject @ 1770 NONAME + _ZN17QDeclarativeTimerC2EP7QObject @ 1771 NONAME + _ZN23QDeclarativeDebugClient13statusChangedENS_6StatusE @ 1772 NONAME + _ZN23QDeclarativeDebugClientD0Ev @ 1773 NONAME + _ZN23QDeclarativeDebugClientD1Ev @ 1774 NONAME + _ZN23QDeclarativeDebugClientD2Ev @ 1775 NONAME + _ZN23QDeclarativeDebugHelper15getScriptEngineEP18QDeclarativeEngine @ 1776 NONAME + _ZN23QDeclarativeDebugHelper26setAnimationSlowDownFactorEf @ 1777 NONAME + _ZN23QDeclarativeEngineDebug13statusChangedENS_6StatusE @ 1778 NONAME + _ZN24QDeclarativeDebugService13statusChangedENS_6StatusE @ 1779 NONAME + _ZN24QDeclarativeDebugServiceD0Ev @ 1780 NONAME + _ZN24QDeclarativeDebugServiceD1Ev @ 1781 NONAME + _ZN24QDeclarativeDebugServiceD2Ev @ 1782 NONAME + _ZN26QDeclarativeBasePositioner10addChangedEv @ 1783 NONAME + _ZN26QDeclarativeBasePositioner10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 1784 NONAME + _ZN26QDeclarativeBasePositioner10setSpacingEi @ 1785 NONAME + _ZN26QDeclarativeBasePositioner11moveChangedEv @ 1786 NONAME + _ZN26QDeclarativeBasePositioner11qt_metacallEN11QMetaObject4CallEiPPv @ 1787 NONAME + _ZN26QDeclarativeBasePositioner11qt_metacastEPKc @ 1788 NONAME + _ZN26QDeclarativeBasePositioner14prePositioningEv @ 1789 NONAME + _ZN26QDeclarativeBasePositioner14spacingChangedEv @ 1790 NONAME + _ZN26QDeclarativeBasePositioner16staticMetaObjectE @ 1791 NONAME DATA 16 + _ZN26QDeclarativeBasePositioner17componentCompleteEv @ 1792 NONAME + _ZN26QDeclarativeBasePositioner19getStaticMetaObjectEv @ 1793 NONAME + _ZN26QDeclarativeBasePositioner22finishApplyTransitionsEv @ 1794 NONAME + _ZN26QDeclarativeBasePositioner29graphicsWidgetGeometryChangedEv @ 1795 NONAME + _ZN26QDeclarativeBasePositioner6setAddEP22QDeclarativeTransition @ 1796 NONAME + _ZN26QDeclarativeBasePositioner7setMoveEP22QDeclarativeTransition @ 1797 NONAME + _ZN26QDeclarativeBasePositioner9positionXEiRKNS_14PositionedItemE @ 1798 NONAME + _ZN26QDeclarativeBasePositioner9positionYEiRKNS_14PositionedItemE @ 1799 NONAME + _ZN26QDeclarativeBasePositionerC2ENS_14PositionerTypeEP16QDeclarativeItem @ 1800 NONAME + _ZN26QDeclarativeBasePositionerC2ER33QDeclarativeBasePositionerPrivateNS_14PositionerTypeEP16QDeclarativeItem @ 1801 NONAME + _ZN26QDeclarativeBasePositionerD0Ev @ 1802 NONAME + _ZN26QDeclarativeBasePositionerD1Ev @ 1803 NONAME + _ZN26QDeclarativeBasePositionerD2Ev @ 1804 NONAME + _ZN27QDeclarativeDebugConnectionD0Ev @ 1805 NONAME + _ZN27QDeclarativeDebugConnectionD1Ev @ 1806 NONAME + _ZN27QDeclarativeDebugConnectionD2Ev @ 1807 NONAME + _ZN27QDeclarativePropertyPrivate7connectEPK7QObjectiS2_iiPi @ 1808 NONAME + _ZN29QDeclarativeAbstractAnimation10classBeginEv @ 1809 NONAME + _ZN29QDeclarativeAbstractAnimation10setRunningEb @ 1810 NONAME + _ZN29QDeclarativeAbstractAnimation10transitionER5QListI18QDeclarativeActionERS0_I20QDeclarativePropertyENS_19TransitionDirectionE @ 1811 NONAME + _ZN29QDeclarativeAbstractAnimation11currentTimeEv @ 1812 NONAME + _ZN29QDeclarativeAbstractAnimation11qt_metacallEN11QMetaObject4CallEiPPv @ 1813 NONAME + _ZN29QDeclarativeAbstractAnimation11qt_metacastEPKc @ 1814 NONAME + _ZN29QDeclarativeAbstractAnimation13pausedChangedEb @ 1815 NONAME + _ZN29QDeclarativeAbstractAnimation14runningChangedEb @ 1816 NONAME + _ZN29QDeclarativeAbstractAnimation14setCurrentTimeEi @ 1817 NONAME + _ZN29QDeclarativeAbstractAnimation16loopCountChangedEi @ 1818 NONAME + _ZN29QDeclarativeAbstractAnimation16setDefaultTargetERK20QDeclarativeProperty @ 1819 NONAME + _ZN29QDeclarativeAbstractAnimation16staticMetaObjectE @ 1820 NONAME DATA 16 + _ZN29QDeclarativeAbstractAnimation16timelineCompleteEv @ 1821 NONAME + _ZN29QDeclarativeAbstractAnimation17componentCompleteEv @ 1822 NONAME + _ZN29QDeclarativeAbstractAnimation17setAlwaysRunToEndEb @ 1823 NONAME + _ZN29QDeclarativeAbstractAnimation18componentFinalizedEv @ 1824 NONAME + _ZN29QDeclarativeAbstractAnimation19getStaticMetaObjectEv @ 1825 NONAME + _ZN29QDeclarativeAbstractAnimation20notifyRunningChangedEb @ 1826 NONAME + _ZN29QDeclarativeAbstractAnimation21alwaysRunToEndChangedEb @ 1827 NONAME + _ZN29QDeclarativeAbstractAnimation21setDisableUserControlEv @ 1828 NONAME + _ZN29QDeclarativeAbstractAnimation4stopEv @ 1829 NONAME + _ZN29QDeclarativeAbstractAnimation5pauseEv @ 1830 NONAME + _ZN29QDeclarativeAbstractAnimation5startEv @ 1831 NONAME + _ZN29QDeclarativeAbstractAnimation6resumeEv @ 1832 NONAME + _ZN29QDeclarativeAbstractAnimation7restartEv @ 1833 NONAME + _ZN29QDeclarativeAbstractAnimation7startedEv @ 1834 NONAME + _ZN29QDeclarativeAbstractAnimation8completeEv @ 1835 NONAME + _ZN29QDeclarativeAbstractAnimation8setGroupEP26QDeclarativeAnimationGroup @ 1836 NONAME + _ZN29QDeclarativeAbstractAnimation8setLoopsEi @ 1837 NONAME + _ZN29QDeclarativeAbstractAnimation9completedEv @ 1838 NONAME + _ZN29QDeclarativeAbstractAnimation9setPausedEb @ 1839 NONAME + _ZN29QDeclarativeAbstractAnimation9setTargetERK20QDeclarativeProperty @ 1840 NONAME + _ZN29QDeclarativeAbstractAnimationC2EP7QObject @ 1841 NONAME + _ZN29QDeclarativeAbstractAnimationC2ER36QDeclarativeAbstractAnimationPrivateP7QObject @ 1842 NONAME + _ZN29QDeclarativeAbstractAnimationD0Ev @ 1843 NONAME + _ZN29QDeclarativeAbstractAnimationD1Ev @ 1844 NONAME + _ZN29QDeclarativeAbstractAnimationD2Ev @ 1845 NONAME + _ZNK16QDeclarativeType20attachedPropertiesIdEv @ 1846 NONAME + _ZNK17QDeclarativeTimer10metaObjectEv @ 1847 NONAME + _ZNK17QDeclarativeTimer11isRepeatingEv @ 1848 NONAME + _ZNK17QDeclarativeTimer16triggeredOnStartEv @ 1849 NONAME + _ZNK17QDeclarativeTimer8intervalEv @ 1850 NONAME + _ZNK17QDeclarativeTimer9isRunningEv @ 1851 NONAME + _ZNK23QDeclarativeDebugClient6statusEv @ 1852 NONAME + _ZNK23QDeclarativeEngineDebug6statusEv @ 1853 NONAME + _ZNK24QDeclarativeDebugService6statusEv @ 1854 NONAME + _ZNK26QDeclarativeBasePositioner10metaObjectEv @ 1855 NONAME + _ZNK26QDeclarativeBasePositioner3addEv @ 1856 NONAME + _ZNK26QDeclarativeBasePositioner4moveEv @ 1857 NONAME + _ZNK26QDeclarativeBasePositioner7spacingEv @ 1858 NONAME + _ZNK29QDeclarativeAbstractAnimation10metaObjectEv @ 1859 NONAME + _ZNK29QDeclarativeAbstractAnimation14alwaysRunToEndEv @ 1860 NONAME + _ZNK29QDeclarativeAbstractAnimation5groupEv @ 1861 NONAME + _ZNK29QDeclarativeAbstractAnimation5loopsEv @ 1862 NONAME + _ZNK29QDeclarativeAbstractAnimation8isPausedEv @ 1863 NONAME + _ZNK29QDeclarativeAbstractAnimation9isRunningEv @ 1864 NONAME + _ZTI17QDeclarativeTimer @ 1865 NONAME + _ZTI26QDeclarativeBasePositioner @ 1866 NONAME + _ZTI29QDeclarativeAbstractAnimation @ 1867 NONAME + _ZTV17QDeclarativeTimer @ 1868 NONAME + _ZTV26QDeclarativeBasePositioner @ 1869 NONAME + _ZTV29QDeclarativeAbstractAnimation @ 1870 NONAME + _ZThn12_N29QDeclarativeAbstractAnimation10classBeginEv @ 1871 NONAME + _ZThn12_N29QDeclarativeAbstractAnimation17componentCompleteEv @ 1872 NONAME + _ZThn12_N29QDeclarativeAbstractAnimationD0Ev @ 1873 NONAME + _ZThn12_N29QDeclarativeAbstractAnimationD1Ev @ 1874 NONAME + _ZThn16_N26QDeclarativeBasePositioner17componentCompleteEv @ 1875 NONAME + _ZThn16_N26QDeclarativeBasePositionerD0Ev @ 1876 NONAME + _ZThn16_N26QDeclarativeBasePositionerD1Ev @ 1877 NONAME + _ZThn8_N17QDeclarativeTimer10classBeginEv @ 1878 NONAME + _ZThn8_N17QDeclarativeTimer17componentCompleteEv @ 1879 NONAME + _ZThn8_N26QDeclarativeBasePositioner10itemChangeEN13QGraphicsItem18GraphicsItemChangeERK8QVariant @ 1880 NONAME + _ZThn8_N26QDeclarativeBasePositionerD0Ev @ 1881 NONAME + _ZThn8_N26QDeclarativeBasePositionerD1Ev @ 1882 NONAME + _ZThn8_N29QDeclarativeAbstractAnimation9setTargetERK20QDeclarativeProperty @ 1883 NONAME + _ZThn8_N29QDeclarativeAbstractAnimationD0Ev @ 1884 NONAME + _ZThn8_N29QDeclarativeAbstractAnimationD1Ev @ 1885 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 634b7af..681649c 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -711,7 +711,7 @@ EXPORTS _ZN11QFontEngine17getGlyphPositionsERK12QGlyphLayoutRK10QTransform6QFlagsIN9QTextItem10RenderFlagEER15QVarLengthArrayIjLi256EERSA_I11QFixedPointLi256EE @ 710 NONAME _ZN11QFontEngine17getPointInOutlineEjijPiS0_Pj @ 711 NONAME _ZN11QFontEngine19addBitmapFontToPathEffRK12QGlyphLayoutP12QPainterPath6QFlagsIN9QTextItem10RenderFlagEE @ 712 NONAME - _ZN11QFontEngine19alphaRGBMapForGlyphEjiRK10QTransform @ 713 NONAME + _ZN11QFontEngine19alphaRGBMapForGlyphEjiRK10QTransform @ 713 NONAME ABSENT _ZN11QFontEngine20removeGlyphFromCacheEj @ 714 NONAME _ZN11QFontEngine21getTrueTypeGlyphIndexEPKhj @ 715 NONAME _ZN11QFontEngine7getCMapEPKhjPbPi @ 716 NONAME @@ -4324,7 +4324,7 @@ EXPORTS _ZN19QApplicationPrivate18dispatchEnterLeaveEP7QWidgetS1_ @ 4323 NONAME _ZN19QApplicationPrivate18resolveS60ScanCodeEij @ 4324 NONAME _ZN19QApplicationPrivate18wheel_scroll_linesE @ 4325 NONAME DATA 4 - _ZN19QApplicationPrivate19app_compile_versionE @ 4326 NONAME DATA 4 + _ZN19QApplicationPrivate19app_compile_versionE @ 4326 NONAME DATA 4 ABSENT _ZN19QApplicationPrivate19hidden_focus_widgetE @ 4327 NONAME DATA 4 _ZN19QApplicationPrivate19keyboard_input_timeE @ 4328 NONAME DATA 4 _ZN19QApplicationPrivate20emitLastWindowClosedEv @ 4329 NONAME @@ -4356,8 +4356,8 @@ EXPORTS _ZN19QApplicationPrivate9constructEv @ 4355 NONAME _ZN19QApplicationPrivate9fade_menuE @ 4356 NONAME DATA 1 _ZN19QApplicationPrivate9openPopupEP7QWidget @ 4357 NONAME - _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeE @ 4358 NONAME - _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeE @ 4359 NONAME + _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeE @ 4358 NONAME ABSENT + _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeE @ 4359 NONAME ABSENT _ZN19QApplicationPrivateD0Ev @ 4360 NONAME _ZN19QApplicationPrivateD1Ev @ 4361 NONAME _ZN19QApplicationPrivateD2Ev @ 4362 NONAME @@ -9242,7 +9242,7 @@ EXPORTS _ZNK18QSyntaxHighlighter20currentBlockUserDataEv @ 9241 NONAME _ZNK18QSyntaxHighlighter6formatEi @ 9242 NONAME _ZNK18QSyntaxHighlighter8documentEv @ 9243 NONAME - _ZNK18QTextureGlyphCache18textureMapForGlyphEj @ 9244 NONAME + _ZNK18QTextureGlyphCache18textureMapForGlyphEj @ 9244 NONAME ABSENT _ZNK19QAbstractProxyModel10headerDataEiN2Qt11OrientationEi @ 9245 NONAME _ZNK19QAbstractProxyModel10metaObjectEv @ 9246 NONAME _ZNK19QAbstractProxyModel11sourceModelEv @ 9247 NONAME @@ -11961,7 +11961,7 @@ EXPORTS _ZN20QGraphicsViewPrivate28updateInputMethodSensitivityEv @ 11960 NONAME _ZN20QGraphicsViewPrivateC1Ev @ 11961 NONAME _ZN20QGraphicsViewPrivateC2Ev @ 11962 NONAME - _ZN23QImageTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 11963 NONAME + _ZN23QImageTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj @ 11963 NONAME ABSENT _ZN23QImageTextureGlyphCache17createTextureDataEii @ 11964 NONAME _ZN23QImageTextureGlyphCache17resizeTextureDataEii @ 11965 NONAME _ZN26QAbstractScrollAreaPrivate14layoutChildrenEv @ 11966 NONAME @@ -12098,4 +12098,60 @@ EXPORTS _ZN20QGraphicsItemPrivate26childrenBoundingRectHelperEP10QTransformP6QRectFP13QGraphicsItem @ 12097 NONAME _ZNK20QGraphicsItemPrivate21effectiveBoundingRectEP13QGraphicsItem @ 12098 NONAME _ZNK5QFont14lastResortFontEv @ 12099 NONAME + _ZN11QFontEngine19alphaRGBMapForGlyphEj6QFixediRK10QTransform @ 12100 NONAME + _ZN11QFontEngine33convertToPostscriptFontFamilyNameERK10QByteArray @ 12101 NONAME + _ZN18QTextureGlyphCache19fillInPendingGlyphsEv @ 12102 NONAME + _ZN19QAbstractProxyModel11setItemDataERK11QModelIndexRK4QMapIi8QVariantE @ 12103 NONAME + _ZN19QAbstractProxyModel4sortEiN2Qt9SortOrderE @ 12104 NONAME + _ZN19QAbstractProxyModel9fetchMoreERK11QModelIndex @ 12105 NONAME + _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeEi @ 12106 NONAME + _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeEi @ 12107 NONAME + _ZN19QGraphicsGridLayout10removeItemEP19QGraphicsLayoutItem @ 12108 NONAME + _ZN23QImageTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj6QFixed @ 12109 NONAME + _ZN6QImage4fillEN2Qt11GlobalColorE @ 12110 NONAME + _ZN6QImage4fillERK6QColor @ 12111 NONAME + _ZN7QGlyphs12setPositionsERK7QVectorI7QPointFE @ 12112 NONAME + _ZN7QGlyphs15setGlyphIndexesERK7QVectorIjE @ 12113 NONAME + _ZN7QGlyphs5clearEv @ 12114 NONAME + _ZN7QGlyphs6detachEv @ 12115 NONAME + _ZN7QGlyphs7setFontERK5QFont @ 12116 NONAME + _ZN7QGlyphsC1ERKS_ @ 12117 NONAME + _ZN7QGlyphsC1Ev @ 12118 NONAME + _ZN7QGlyphsC2ERKS_ @ 12119 NONAME + _ZN7QGlyphsC2Ev @ 12120 NONAME + _ZN7QGlyphsD1Ev @ 12121 NONAME + _ZN7QGlyphsD2Ev @ 12122 NONAME + _ZN7QGlyphsaSERKS_ @ 12123 NONAME + _ZN7QGlyphspLERKS_ @ 12124 NONAME + _ZN8QPainter10drawGlyphsERK7QPointFRK7QGlyphs @ 12125 NONAME + _ZNK10QTabWidget14heightForWidthEi @ 12126 NONAME + _ZNK11QFontEngine18createExplicitFontEv @ 12127 NONAME + _ZNK11QFontEngine26createExplicitFontWithNameERK7QString @ 12128 NONAME + _ZNK11QTextLayout6glyphsEv @ 12129 NONAME + _ZNK12QFontMetrics10inFontUcs4Ej @ 12130 NONAME + _ZNK12QRadioButton15minimumSizeHintEv @ 12131 NONAME + _ZNK13QFontMetricsF10inFontUcs4Ej @ 12132 NONAME + _ZNK13QTextFragment6glyphsEv @ 12133 NONAME + _ZNK14QWidgetPrivate17hasHeightForWidthEv @ 12134 NONAME + _ZNK16QFileSystemModel5rmdirERK11QModelIndex @ 12135 NONAME + _ZNK18QTextureGlyphCache18textureMapForGlyphEj6QFixed @ 12136 NONAME + _ZNK18QTextureGlyphCache20subPixelPositionForXE6QFixed @ 12137 NONAME + _ZNK18QTextureGlyphCache30calculateSubPixelPositionCountEj @ 12138 NONAME + _ZNK19QAbstractProxyModel11hasChildrenERK11QModelIndex @ 12139 NONAME + _ZNK19QAbstractProxyModel12canFetchMoreERK11QModelIndex @ 12140 NONAME + _ZNK19QAbstractProxyModel20supportedDropActionsEv @ 12141 NONAME + _ZNK19QAbstractProxyModel4spanERK11QModelIndex @ 12142 NONAME + _ZNK19QAbstractProxyModel5buddyERK11QModelIndex @ 12143 NONAME + _ZNK19QAbstractProxyModel8mimeDataERK5QListI11QModelIndexE @ 12144 NONAME + _ZNK19QAbstractProxyModel9mimeTypesEv @ 12145 NONAME + _ZNK7QGlyphs12glyphIndexesEv @ 12146 NONAME + _ZNK7QGlyphs4fontEv @ 12147 NONAME + _ZNK7QGlyphs9positionsEv @ 12148 NONAME + _ZNK7QGlyphseqERKS_ @ 12149 NONAME + _ZNK7QGlyphsneERKS_ @ 12150 NONAME + _ZNK7QGlyphsplERKS_ @ 12151 NONAME + _ZNK8QPainter16clipBoundingRectEv @ 12152 NONAME + _ZNK9QCheckBox15minimumSizeHintEv @ 12153 NONAME + _ZNK9QTextLine6glyphsEii @ 12154 NONAME + _Zls6QDebugPK13QSymbianEvent @ 12155 NONAME diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def index f13fab3..21f3e73 100644 --- a/src/s60installs/eabi/QtNetworku.def +++ b/src/s60installs/eabi/QtNetworku.def @@ -1168,4 +1168,11 @@ EXPORTS _ZTV35QNetworkConfigurationManagerPrivate @ 1167 NONAME _ZThn8_N19QBearerEnginePluginD0Ev @ 1168 NONAME _ZThn8_N19QBearerEnginePluginD1Ev @ 1169 NONAME + _ZN10QUdpSocket18joinMulticastGroupERK12QHostAddress @ 1170 NONAME + _ZN10QUdpSocket18joinMulticastGroupERK12QHostAddressRK17QNetworkInterface @ 1171 NONAME + _ZN10QUdpSocket19leaveMulticastGroupERK12QHostAddress @ 1172 NONAME + _ZN10QUdpSocket19leaveMulticastGroupERK12QHostAddressRK17QNetworkInterface @ 1173 NONAME + _ZN10QUdpSocket21setMulticastInterfaceERK17QNetworkInterface @ 1174 NONAME + _ZN13QNetworkReply11setFinishedEb @ 1175 NONAME + _ZNK10QUdpSocket18multicastInterfaceEv @ 1176 NONAME -- cgit v0.12 From 7f8af7a2030c0f4ae7ad79eee93bd68a29f285d3 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 11 Oct 2010 16:35:58 +0200 Subject: Add test to test QDir caching behavior. Also fix the qfileenginemodel test to be less fragile Reviewed-by: Prasanth Ullattil --- tests/auto/qdir/tst_qdir.cpp | 13 +++++++++++++ tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 2bb0a3e..d540f29 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -175,6 +175,8 @@ private slots: void detachingOperations(); + void testCaching(); + #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void isRoot_data(); void isRoot(); @@ -1663,6 +1665,17 @@ void tst_QDir::detachingOperations() QCOMPARE(dir1.sorting(), sorting); } +void tst_QDir::testCaching() +{ + QString dirName = QString::fromLatin1("testCaching"); + QDir::current().rmdir(dirName); // cleanup a previous run. + QDir dir(dirName); + QVERIFY(!dir.exists()); + QDir::current().mkdir(dirName); + QVERIFY(QDir(dirName).exists()); // dir exists + QVERIFY(dir.exists()); // QDir doesn't cache the 'exist' between calls. +} + #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void tst_QDir::isRoot_data() { diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index c234c96..aa632c7 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -992,8 +992,8 @@ void tst_QFileSystemModel::dirsBeforeFiles() } dir.rmdir(dirPath); } - dir.mkpath(dirPath); - QVERIFY(dir.exists()); + QVERIFY(dir.mkpath(dirPath)); + QVERIFY(QDir(dirPath).exists()); for (int i = 0; i < 3; ++i) { QLatin1Char c('a' + i); -- cgit v0.12 From 69d1025d7c506350dd90b5fb35510b1036847db7 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 11 Oct 2010 16:50:09 +0200 Subject: Fix caching of metadata in QDir to not change behavior In 4.7 and before a QDir::exists() always stats and a refresh() call would flush metadata, restore this behavior again. Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index bbe9226..827294c 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -131,9 +131,8 @@ QDirPrivate::QDirPrivate(const QDirPrivate ©) bool QDirPrivate::exists() const { if (fileEngine.isNull()) { - if (!metaData.hasFlags(QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType)) - QFileSystemEngine::fillMetaData(dirEntry, metaData, - QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); + QFileSystemEngine::fillMetaData(dirEntry, metaData, + QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); // always stat return metaData.exists() && metaData.isDirectory(); } const QAbstractFileEngine::FileFlags info = @@ -2094,6 +2093,7 @@ bool QDir::isRelativePath(const QString &path) void QDir::refresh() const { QDirPrivate *d = const_cast(this)->d_ptr.data(); + d->metaData.clear(); d->initFileEngine(); d->clearFileLists(); } -- cgit v0.12 From a3550bce43bcf70f3c763f6fcae28ba5d1a31305 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 11 Oct 2010 17:43:04 +0200 Subject: Test QDir::mkdir/mkpath return codes --- tests/auto/qdir/tst_qdir.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index d540f29..9521921 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -103,6 +103,8 @@ private slots: void mkdir_data(); void mkdir(); + void makedirReturnCode(); + void rmdir_data(); void rmdir(); @@ -295,6 +297,17 @@ void tst_QDir::mkdir() QVERIFY(fi.exists() && fi.isDir()); } +void tst_QDir::makedirReturnCode() +{ + QString dirName = QString::fromLatin1("makedirReturnCode"); + QDir::current().rmdir(dirName); // cleanup a previous run. + QDir dir(dirName); + QVERIFY(!dir.exists()); + QVERIFY(QDir::current().mkdir(dirName)); + QVERIFY(!QDir::current().mkdir(dirName)); // calling mkdir on an existing dir will fail. + QVERIFY(QDir::current().mkpath(dirName)); // calling mkpath on an existing dir will pass +} + void tst_QDir::rmdir_data() { QTest::addColumn("path"); -- cgit v0.12 From 8ee99ee22729b4d9603fe83929116259956b81ce Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 8 Oct 2010 16:23:55 +0100 Subject: Use QSystemError to return errors from QFileSystemEngine Testing done: win32-msvc2008 and Mac OS X - qfile, qfileinfo, qdir, qdiriterator, qtemporaryfile autotests symbian-sbsv2 - qtcore, qtgui, qtxml autotests win32-g++ - compilation test for qmake Reviewed-By: Thomas Zander --- qmake/Makefile.unix | 6 +- qmake/Makefile.win32 | 1 + qmake/Makefile.win32-g++ | 4 ++ qmake/Makefile.win32-g++-sh | 4 ++ qmake/qmake.pri | 2 + src/corelib/io/qfilesystemengine_p.h | 14 ++--- src/corelib/io/qfilesystemengine_symbian.cpp | 83 ++++------------------------ src/corelib/io/qfilesystemengine_unix.cpp | 20 +++---- src/corelib/io/qfilesystemengine_win.cpp | 22 ++++---- src/corelib/io/qfsfileengine_p.h | 4 -- src/corelib/io/qfsfileengine_unix.cpp | 40 +++++++------- src/corelib/io/qfsfileengine_win.cpp | 16 +++--- src/corelib/kernel/qsystemerror.cpp | 40 ++++++++++++-- src/tools/bootstrap/bootstrap.pro | 3 +- 14 files changed, 120 insertions(+), 139 deletions(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index f03b300..7d61cf8 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -20,7 +20,7 @@ QOBJS=qtextcodec.o qutfcodec.o qstring.o qtextstream.o qiodevice.o qmalloc.o qgl qfsfileengine_unix.o qfsfileengine.o \ qfsfileengine_iterator.o qregexp.o qvector.o qbitarray.o qdir.o qdiriterator.o quuid.o qhash.o \ qfileinfo.o qdatetime.o qstringlist.o qabstractfileengine.o qtemporaryfile.o \ - qmap.o qmetatype.o qsettings.o qlibraryinfo.o qvariant.o qvsnprintf.o \ + qmap.o qmetatype.o qsettings.o qsystemerror.o qlibraryinfo.o qvariant.o qvsnprintf.o \ qlocale.o qlinkedlist.o qurl.o qnumeric.o qcryptographichash.o qxmlstream.o qxmlutils.o \ $(QTOBJS) @@ -65,6 +65,7 @@ DEPEND_SRC=project.cpp property.cpp meta.cpp main.cpp generators/makefile.cpp ge $(SOURCE_PATH)/src/corelib/tools/qvsnprintf.cpp $(SOURCE_PATH)/src/corelib/global/qnumeric.cpp \ $(SOURCE_PATH)/src/corelib/xml/qxmlstream.cpp \ $(SOURCE_PATH)/src/corelib/xml/qxmlutils.cpp \ + $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp \ $(QTSRCS) CPPFLAGS = -I. -Igenerators -Igenerators/unix -Igenerators/win32 -Igenerators/mac -Igenerators/symbian \ @@ -104,6 +105,9 @@ qvariant.o: $(SOURCE_PATH)/src/corelib/kernel/qvariant.cpp qsettings.o: $(SOURCE_PATH)/src/corelib/io/qsettings.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qsettings.cpp +qsystemerror.o: $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp + qlibraryinfo.o: $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 4333d45..c9e623d 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -103,6 +103,7 @@ QTOBJS= \ qutfcodec.obj \ qstring.obj \ qstringlist.obj \ + qsystemerror.obj \ qtextstream.obj \ qdatastream.obj \ quuid.obj \ diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index da911e7..1a20d71 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -82,6 +82,7 @@ QTOBJS= \ qutfcodec.o \ qstring.o \ qstringlist.o \ + qsystemerror.o \ qsystemlibrary.o \ qtextstream.o \ quuid.o \ @@ -247,6 +248,9 @@ qdatetime.o: $(SOURCE_PATH)/src/corelib/tools/qdatetime.cpp qstringlist.o: $(SOURCE_PATH)/src/corelib/tools/qstringlist.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qstringlist.cpp +qsystemerror.o: $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp + qsystemlibrary.o: $(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index 2530fe8..aad4a9e 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -83,6 +83,7 @@ QTOBJS= \ qstring.o \ qstringlist.o \ qsystemlibrary.o \ + qsystemerror.o \ qtextstream.o \ quuid.o \ qvector.o \ @@ -246,6 +247,9 @@ qdatetime.o: $(SOURCE_PATH)/src/corelib/tools/qdatetime.cpp qstringlist.o: $(SOURCE_PATH)/src/corelib/tools/qstringlist.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/tools/qstringlist.cpp +qsystemerror.o: $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp + $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp + qsystemlibrary.o: $(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp diff --git a/qmake/qmake.pri b/qmake/qmake.pri index 274cb70..83a5356 100644 --- a/qmake/qmake.pri +++ b/qmake/qmake.pri @@ -82,6 +82,7 @@ bootstrap { #Qt code quuid.cpp \ qsettings.cpp \ qlibraryinfo.cpp \ + qsystemerror.cpp \ qvariant.cpp \ qvector.cpp \ qvsnprintf.cpp \ @@ -119,6 +120,7 @@ bootstrap { #Qt code qstring.h \ qstringlist.h \ qstringmatcher.h \ + qsystemerror_p.h \ qtemporaryfile.h \ qtextstream.h \ qurl.h \ diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index f4d942a..1f4aad0 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -56,6 +56,7 @@ #include "qfile.h" #include "qfilesystementry_p.h" #include "qfilesystemmetadata_p.h" +#include QT_BEGIN_NAMESPACE @@ -91,9 +92,6 @@ public: static QString owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own); static QString nativeAbsoluteFilePath(const QString &path); #endif -#ifdef Q_OS_SYMBIAN - static QString errorString(int errorcode); -#endif //homePath, rootPath and tempPath shall return clean paths static QString homePath(); static QString rootPath(); @@ -102,13 +100,13 @@ public: static bool createDirectory(const QFileSystemEntry &entry, bool createParents); static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents); - static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString); + static bool createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error); - static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString); - static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString); - static bool removeFile(const QFileSystemEntry &entry, QString &errorString); + static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error); + static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error); + static bool removeFile(const QFileSystemEntry &entry, QSystemError &error); - static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QString &errorString, + static bool setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data = 0); static bool setCurrentPath(const QFileSystemEntry &entry); diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 318a5fd..877ea7a 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -88,7 +88,8 @@ static QString symbianCleanAbsolutePath(const QString& path) //static QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, QFileSystemMetaData &data) { - return link; // TODO implement + Q_UNUSED(data); + return link; } //static @@ -283,16 +284,16 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } //static -bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { Q_UNUSED(source) Q_UNUSED(target) - errorString = QLatin1String("not supported"); + error = QSystemError(KErrNotSupported, QSystemError::NativeError); return false; } //static -bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { //CFileMan is allocated each time because it is not thread-safe CFileMan *fm = 0; @@ -302,12 +303,12 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst delete fm; return true; } - errorString = QFileSystemEngine::errorString(err); + error = QSystemError(err, QSystemError::NativeError); return false; } //static -bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { QString sourcepath = absoluteName(source).nativeFilePath(); QString targetpath = absoluteName(target).nativeFilePath(); @@ -315,24 +316,24 @@ bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSy TInt err = fs.Rename(qt_QString2TPtrC(sourcepath), qt_QString2TPtrC(targetpath)); if (err == KErrNone) return true; - errorString = QFileSystemEngine::errorString(err); + error = QSystemError(err, QSystemError::NativeError); return false; } //static -bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QString &errorString) +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error) { QString targetpath = absoluteName(entry).nativeFilePath(); RFs& fs(qt_s60GetRFs()); TInt err = fs.Delete(qt_QString2TPtrC(targetpath)); if (err == KErrNone) return true; - errorString = QFileSystemEngine::errorString(err); + error = QSystemError(err, QSystemError::NativeError); return false; } //static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QString &errorString, QFileSystemMetaData *data) +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data) { QString targetpath = absoluteName(entry).nativeFilePath(); TUint setmask = 0; @@ -350,7 +351,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per } if (err == KErrNone) return true; - errorString = QFileSystemEngine::errorString(err); + error = QSystemError(err, QSystemError::NativeError); return false; } @@ -416,64 +417,4 @@ QFileSystemEntry QFileSystemEngine::currentPath() return ret; } -QString QFileSystemEngine::errorString(int errorcode) -{ - switch (errorcode) { - case KErrNotFound: - return QLatin1String("not found"); - case KErrCancel: - return QLatin1String("cancelled"); - case KErrNoMemory: - return QLatin1String("out of memory"); - case KErrNotSupported: - return QLatin1String("not supported"); - case KErrBadHandle: - return QLatin1String("bad handle"); //KERN-EXEC 0 panic is more likely - case KErrAlreadyExists: - return QLatin1String("already exists"); - case KErrPathNotFound: - return QLatin1String("path not found"); - case KErrInUse: - return QLatin1String("in use"); - case KErrNotReady: - return QLatin1String("not ready (e.g. FS dismounted, no memory card)"); - case KErrCorrupt: - return QLatin1String("corrupt"); - case KErrAccessDenied: - return QLatin1String("access denied"); - case KErrLocked: - return QLatin1String("locked"); - case KErrWrite: - return QLatin1String("incomplete write error"); - case KErrDisMounted: - return QLatin1String("file system dismounted during operation"); //i.e. a forcible dismount was done while we had files open - case KErrEof: - return QLatin1String("end of file"); - case KErrDiskFull: - return QLatin1String("no space in file system"); - case KErrBadName: - return QLatin1String("invalid filename"); - case KErrTimedOut: - return QLatin1String("timed out"); - case KErrBadDescriptor: - return QLatin1String("bad descriptor (passed address on stack to async call?)"); - case KErrAbort: - return QLatin1String("aborted"); - case KErrTooBig: - return QLatin1String("too big"); //e.g. trying to open a >2GB file with 32 bit API - case KErrBadPower: - return QLatin1String("insufficient power"); - case KErrDirFull: - return QLatin1String("no space in directory table"); - case KErrHardwareNotAvailable: - return QLatin1String("hardware not available"); - case KErrSessionClosed: - return QLatin1String("session closed"); - case KErrPermissionDenied: - return QLatin1String("permission denied"); - default: - return QString(QLatin1String("symbian error %d")).arg(errorcode); - } -} - QT_END_NAMESPACE diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 213fdc3..dc6888d 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -572,45 +572,45 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } //static -bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { if (::symlink(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0) return true; - errorString = qt_error_string(errno); + error = QSystemError(errno, QSystemError::StandardLibraryError); return false; } //static -bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { Q_UNUSED(source); Q_UNUSED(target); // # we can implement this using sendfile(2) - errorString = QLatin1String("Not implemented!"); + //when this function returns false, block copy is used in QFile which sets the error code. return false; } //static -bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { if (::rename(source.nativeFilePath().constData(), target.nativeFilePath().constData()) == 0) return true; - errorString = qt_error_string(errno); + error = QSystemError(errno, QSystemError::StandardLibraryError); return false; } //static -bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QString &errorString) +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error) { if (unlink(entry.nativeFilePath().constData()) == 0) return true; - errorString = qt_error_string(errno); + error = QSystemError(errno, QSystemError::StandardLibraryError); return false; } //static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QString &errorString, QFileSystemMetaData *data) +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data) { mode_t mode = 0; if (permissions & QFile::ReadOwner) @@ -645,7 +645,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per data->knownFlagsMask |= QFileSystemMetaData::Permissions; } if (!success) - errorString = qt_error_string(errno); + error = QSystemError(errno, QSystemError::StandardLibraryError); return success; } diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 5cc7395..53b9e43 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1115,43 +1115,43 @@ QFileSystemEntry QFileSystemEngine::currentPath() } //static -bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { - errorString = QLatin1String("not implemented"); - return false; // TODO implement; + Q_ASSERT(false); + return false; // TODO implement; - code needs to be moved from qfsfileengine_win.cpp } //static -bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { bool ret = ::CopyFile((wchar_t*)source.nativeFilePath().utf16(), (wchar_t*)target.nativeFilePath().utf16(), true) != 0; if(!ret) - errorString = qt_error_string(::GetLastError()); + error = QSystemError(::GetLastError(), QSystemError::NativeError); return ret; } //static -bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QString &errorString) +bool QFileSystemEngine::renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) { bool ret = ::MoveFile((wchar_t*)source.nativeFilePath().utf16(), (wchar_t*)target.nativeFilePath().utf16()) != 0; if(!ret) - errorString = qt_error_string(::GetLastError()); + error = QSystemError(::GetLastError(), QSystemError::NativeError); return ret; } //static -bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QString &errorString) +bool QFileSystemEngine::removeFile(const QFileSystemEntry &entry, QSystemError &error) { bool ret = ::DeleteFile((wchar_t*)entry.nativeFilePath().utf16()) != 0; if(!ret) - errorString = qt_error_string(::GetLastError()); + error = QSystemError(::GetLastError(), QSystemError::NativeError); return ret; } //static -bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QString &errorString, +bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Permissions permissions, QSystemError &error, QFileSystemMetaData *data) { Q_UNUSED(data); @@ -1169,7 +1169,7 @@ bool QFileSystemEngine::setPermissions(const QFileSystemEntry &entry, QFile::Per bool ret = (::_wchmod((wchar_t*)entry.nativeFilePath().utf16(), mode) == 0); if(!ret) - errorString = qt_error_string(errno); + error = QSystemError(errno, QSystemError::StandardLibraryError); return ret; } diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 14a8938..715b46f 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -185,10 +185,6 @@ public: int sysOpen(const QString &, int flags); #endif -#ifdef Q_OS_SYMBIAN - void setSymbianError(int symbianError, QFile::FileError defaultError, QString defaultString); -#endif - protected: QFSFileEnginePrivate(); diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index a64f8dc..caf5f4c 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -239,7 +239,7 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) } if (r != KErrNone) { - q->setError(QFile::OpenError, QFileSystemEngine::errorString(r)); + q->setError(QFile::OpenError, QSystemError(r, QSystemError::NativeError).toString()); symbianFile.Close(); return false; } @@ -385,7 +385,7 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) TInt r = symbianFile.Read(ptr); if (r != KErrNone) { - q->setError(QFile::ReadError, QFileSystemEngine::errorString(r)); + q->setError(QFile::ReadError, QSystemError(r, QSystemError::NativeError).toString()); return -1; } return qint64(ptr.Length()); @@ -470,7 +470,7 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) TInt r = symbianFile.Write(ptr); if (r != KErrNone) { - q->setError(QFile::WriteError, QFileSystemEngine::errorString(r)); + q->setError(QFile::WriteError, QSystemError(r, QSystemError::NativeError).toString()); return -1; } return len; @@ -494,7 +494,7 @@ qint64 QFSFileEnginePrivate::nativePos() const #endif TInt err = symbianFile.Seek(ESeekCurrent, pos); if(err != KErrNone) { - const_cast(q)->setError(QFile::PositionError, QFileSystemEngine::errorString(err)); + const_cast(q)->setError(QFile::PositionError, QSystemError(err, QSystemError::NativeError).toString()); return -1; } return pos; @@ -523,7 +523,7 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos) #endif if (r != KErrNone) { - q->setError(QFile::PositionError, QFileSystemEngine::errorString(r)); + q->setError(QFile::PositionError, QSystemError(r, QSystemError::NativeError).toString()); return false; } return true; @@ -555,11 +555,11 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - QString errorString; - bool ret = QFileSystemEngine::removeFile(d->fileEntry, errorString); + QSystemError error; + bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); d->metaData.clear(); if (!ret) { - setError(QFile::RemoveError, errorString); + setError(QFile::RemoveError, error.toString()); } return ret; } @@ -567,10 +567,10 @@ bool QFSFileEngine::remove() bool QFSFileEngine::copy(const QString &newName) { Q_D(QFSFileEngine); - QString error; + QSystemError error; bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(newName), error); if (!ret) { - setError(QFile::CopyError, error); + setError(QFile::CopyError, error.toString()); } return ret; } @@ -578,11 +578,11 @@ bool QFSFileEngine::copy(const QString &newName) bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - QString error; + QSystemError error; bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); if (!ret) { - setError(QFile::RenameError, error); + setError(QFile::RenameError, error.toString()); } return ret; @@ -591,10 +591,10 @@ bool QFSFileEngine::rename(const QString &newName) bool QFSFileEngine::link(const QString &newName) { Q_D(QFSFileEngine); - QString error; + QSystemError error; bool ret = QFileSystemEngine::createLink(d->fileEntry, QFileSystemEntry(newName), error); if (!ret) { - setError(QFile::RenameError, error); + setError(QFile::RenameError, error.toString()); } return ret; } @@ -611,7 +611,7 @@ qint64 QFSFileEnginePrivate::nativeSize() const #endif TInt err = symbianFile.Size(size); if(err != KErrNone) { - const_cast(q)->setError(QFile::PositionError, QFileSystemEngine::errorString(err)); + const_cast(q)->setError(QFile::PositionError, QSystemError(err, QSystemError::NativeError).toString()); return 0; } return size; @@ -850,9 +850,9 @@ QString QFSFileEngine::owner(FileOwner own) const bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); - QString error; + QSystemError error; if (!QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error, 0)) { - setError(QFile::PermissionsError, error); + setError(QFile::PermissionsError, error.toString()); return false; } return true; @@ -884,10 +884,12 @@ bool QFSFileEngine::setSize(qint64 size) ret = (err == KErrNone); } if (!ret) { + QSystemError error; if (err) - setError(QFile::ResizeError, QFileSystemEngine::errorString(err)); + error = QSystemError(err, QSystemError::NativeError); else - setError(QFile::ResizeError, qt_error_string(errno)); + error = QSystemError(errno, QSystemError::StandardLibraryError); + setError(QFile::ResizeError, error.toString()); } return ret; } diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 63f2a9f..cf83c07 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -503,30 +503,30 @@ bool QFSFileEnginePrivate::nativeIsSequential() const bool QFSFileEngine::remove() { Q_D(QFSFileEngine); - QString error; + QSystemError error; bool ret = QFileSystemEngine::removeFile(d->fileEntry, error); if (!ret) - setError(QFile::RemoveError, error); + setError(QFile::RemoveError, error.toString()); return ret; } bool QFSFileEngine::copy(const QString ©Name) { Q_D(QFSFileEngine); - QString error; + QSystemError error; bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(copyName), error); if (!ret) - setError(QFile::CopyError, error); + setError(QFile::CopyError, error.toString()); return ret; } bool QFSFileEngine::rename(const QString &newName) { Q_D(QFSFileEngine); - QString error; + QSystemError error; bool ret = QFileSystemEngine::renameFile(d->fileEntry, QFileSystemEntry(newName), error); if (!ret) - setError(QFile::RenameError, error); + setError(QFile::RenameError, error.toString()); return ret; } @@ -854,10 +854,10 @@ QString QFSFileEngine::owner(FileOwner own) const bool QFSFileEngine::setPermissions(uint perms) { Q_D(QFSFileEngine); - QString error; + QSystemError error; bool ret = QFileSystemEngine::setPermissions(d->fileEntry, QFile::Permissions(perms), error); if (!ret) - setError(QFile::PermissionsError, error); + setError(QFile::PermissionsError, error.toString()); return ret; } diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index 065014a..d2350b5 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -39,8 +39,40 @@ ** ****************************************************************************/ +#include #include "qsystemerror_p.h" -#include +#if !defined(Q_OS_WINCE) +# include +# if defined(Q_CC_MSVC) +# include +# endif +#endif +#ifdef Q_OS_WIN +#include +#endif + +#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ + defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L +namespace { + // There are two incompatible versions of strerror_r: + // a) the XSI/POSIX.1 version, which returns an int, + // indicating success or not + // b) the GNU version, which returns a char*, which may or may not + // be the beginning of the buffer we used + // The GNU libc manpage for strerror_r says you should use the the XSI + // version in portable code. However, it's impossible to do that if + // _GNU_SOURCE is defined so we use C++ overloading to decide what to do + // depending on the return type + static inline QString fromstrerror_helper(int, const QByteArray &buf) + { + return QString::fromLocal8Bit(buf); + } + static inline QString fromstrerror_helper(const char *str, const QByteArray &) + { + return QString::fromLocal8Bit(str); + } +} +#endif static QString standardLibraryErrorString(int errorCode) { @@ -166,23 +198,19 @@ QString QSystemError::toString() switch(errorScope) { case NativeError: #if defined (Q_OS_WIN) - errorString = windowsErrorString(errorCode); - break; + return windowsErrorString(errorCode); #elif defined (Q_OS_SYMBIAN) return symbianErrorString(errorCode); - break; #else //unix: fall through as native and standard library are the same #endif case StandardLibraryError: return standardLibraryErrorString(errorCode); - break; default: qWarning("invalid error scope"); //fall through case NoError: return QLatin1String("No error"); - break; } } diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 6531a83..9e5845c 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -69,6 +69,7 @@ SOURCES += \ ../../corelib/io/qurl.cpp \ ../../corelib/kernel/qmetatype.cpp \ ../../corelib/kernel/qvariant.cpp \ + ../../corelib/kernel/qsystemerror.cpp \ ../../corelib/tools/qbitarray.cpp \ ../../corelib/tools/qbytearray.cpp \ ../../corelib/tools/qbytearraymatcher.cpp \ @@ -83,7 +84,7 @@ SOURCES += \ ../../corelib/tools/qvector.cpp \ ../../corelib/tools/qvsnprintf.cpp \ ../../corelib/xml/qxmlutils.cpp \ - ../../corelib/xml/qxmlstream.cpp \ + ../../corelib/xml/qxmlstream.cpp \ ../../xml/dom/qdom.cpp \ ../../xml/sax/qxml.cpp -- cgit v0.12 From 2030d7894d119a207f872f23fc06ab3f934073f3 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 11 Oct 2010 17:07:09 +0100 Subject: Update documentation of QDir to reflect Qt 4 behaviour Reviewed-By: Thomas Zander --- src/corelib/io/qdir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index bbe9226..eb78e25 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1356,8 +1356,11 @@ QFileInfoList QDir::entryInfoList(const QStringList &nameFilters, Filters filter Returns true on success; otherwise returns false. + If the directory already exists when this function is called, it will return false. + \sa rmdir() */ +// ### Qt5: behaviour when directory already exists should be made consistent for mkdir and mkpath bool QDir::mkdir(const QString &dirName) const { const QDirPrivate* d = d_ptr.constData(); @@ -1406,8 +1409,11 @@ bool QDir::rmdir(const QString &dirName) const Returns true if successful; otherwise returns false. + If the path already exists when this function is called, it will return true. + \sa rmpath() */ +// ### Qt5: behaviour when directory already exists should be made consistent for mkdir and mkpath bool QDir::mkpath(const QString &dirPath) const { const QDirPrivate* d = d_ptr.constData(); -- cgit v0.12 From 0dd8d6e60a850b42b75d64ccc7eb793ae5c1549b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 11 Oct 2010 17:09:47 +0100 Subject: Fix compilation of two autotests These tests did not link when QT_BUILD_INTERNAL was not defined, as one of the private headers was causing QFileInfoGatherer::~QFileInfoGatherer to be referenced Reviewed-By: Thomas Zander --- tests/auto/qfiledialog/tst_qfiledialog.cpp | 4 ++++ tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index ca7c445..5d369b4 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -61,9 +61,13 @@ #include #include #include "../../shared/util.h" +#if defined QT_BUILD_INTERNAL #include "../../../src/gui/dialogs/qsidebar_p.h" #include "../../../src/gui/dialogs/qfilesystemmodel_p.h" #include "../../../src/gui/dialogs/qfiledialog_p.h" +#endif +#include +#include #include "../network-settings.h" diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index c234c96..a391eb9 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -41,7 +41,10 @@ #include +#ifdef QT_BUILD_INTERNAL #include "../../../src/gui/dialogs/qfilesystemmodel_p.h" +#endif +#include #include #include #include @@ -826,8 +829,10 @@ void tst_QFileSystemModel::sort() MyFriendFileSystemModel *myModel = new MyFriendFileSystemModel(); QTreeView *tree = new QTreeView(); +#ifdef QT_BUILD_INTERNAL if (fileDialogMode) myModel->d_func()->disableRecursiveSort = true; +#endif QDir dir(QDir::tempPath()); //initialize the randomness -- cgit v0.12 From 4f9b25ffa8025702c82a32538b82d15acf03303b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 11 Oct 2010 17:11:54 +0100 Subject: Fix return value for QDir::mkdir on symbian Qt 4.7 behaviour was to return false when directory already exists for mkdir but true when directory already exists for mkpath. This change makes symbian do that in master, even though it's inconsistent. Reviewed-By: Thomas Zander --- src/corelib/io/qfilesystemengine_symbian.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 877ea7a..d068248 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -115,6 +115,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) QString orig = entry.filePath(); const bool isAbsolute = entry.isAbsolute(); const bool isDirty = (orig.contains(QLatin1String("/../")) || orig.contains(QLatin1String("/./")) || + orig.contains(QLatin1String("//")) || orig.endsWith(QLatin1String("/..")) || orig.endsWith(QLatin1String("/."))); if (isAbsolute && !isDirty) return entry; @@ -258,7 +259,9 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea r = qt_s60GetRFs().MkDirAll(qt_QString2TPtrC(abspath)); else r = qt_s60GetRFs().MkDir(qt_QString2TPtrC(abspath)); - return (r == KErrNone || r == KErrAlreadyExists); + if (createParents && r == KErrAlreadyExists) + return true; //# Qt5 - QDir::mkdir returns false for existing dir, QDir::mkpath returns true (should be made consistent in Qt 5) + return (r == KErrNone); } //static -- cgit v0.12 From 75016a4a3bb2ae536a3a813f0ef410b1a0c83742 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 11 Oct 2010 16:35:58 +0200 Subject: Add test to test QDir caching behavior. Also fix the qfileenginemodel test to be less fragile Reviewed-by: Prasanth Ullattil --- tests/auto/qdir/tst_qdir.cpp | 13 +++++++++++++ tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 2bb0a3e..d540f29 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -175,6 +175,8 @@ private slots: void detachingOperations(); + void testCaching(); + #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void isRoot_data(); void isRoot(); @@ -1663,6 +1665,17 @@ void tst_QDir::detachingOperations() QCOMPARE(dir1.sorting(), sorting); } +void tst_QDir::testCaching() +{ + QString dirName = QString::fromLatin1("testCaching"); + QDir::current().rmdir(dirName); // cleanup a previous run. + QDir dir(dirName); + QVERIFY(!dir.exists()); + QDir::current().mkdir(dirName); + QVERIFY(QDir(dirName).exists()); // dir exists + QVERIFY(dir.exists()); // QDir doesn't cache the 'exist' between calls. +} + #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void tst_QDir::isRoot_data() { diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index a391eb9..6b63691 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -997,8 +997,8 @@ void tst_QFileSystemModel::dirsBeforeFiles() } dir.rmdir(dirPath); } - dir.mkpath(dirPath); - QVERIFY(dir.exists()); + QVERIFY(dir.mkpath(dirPath)); + QVERIFY(QDir(dirPath).exists()); for (int i = 0; i < 3; ++i) { QLatin1Char c('a' + i); -- cgit v0.12 From aa117bb48971c2fe56aff1e678ee3a7f6358eb0d Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 11 Oct 2010 16:50:09 +0200 Subject: Fix caching of metadata in QDir to not change behavior In 4.7 and before a QDir::exists() always stats and a refresh() call would flush metadata, restore this behavior again. Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index eb78e25..e9bc012 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -131,9 +131,8 @@ QDirPrivate::QDirPrivate(const QDirPrivate ©) bool QDirPrivate::exists() const { if (fileEngine.isNull()) { - if (!metaData.hasFlags(QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType)) - QFileSystemEngine::fillMetaData(dirEntry, metaData, - QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); + QFileSystemEngine::fillMetaData(dirEntry, metaData, + QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); // always stat return metaData.exists() && metaData.isDirectory(); } const QAbstractFileEngine::FileFlags info = @@ -2100,6 +2099,7 @@ bool QDir::isRelativePath(const QString &path) void QDir::refresh() const { QDirPrivate *d = const_cast(this)->d_ptr.data(); + d->metaData.clear(); d->initFileEngine(); d->clearFileLists(); } -- cgit v0.12 From f1f39af98afb2129daa5db2686200907de4c0999 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 11 Oct 2010 17:43:04 +0200 Subject: Test QDir::mkdir/mkpath return codes --- tests/auto/qdir/tst_qdir.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index d540f29..9521921 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -103,6 +103,8 @@ private slots: void mkdir_data(); void mkdir(); + void makedirReturnCode(); + void rmdir_data(); void rmdir(); @@ -295,6 +297,17 @@ void tst_QDir::mkdir() QVERIFY(fi.exists() && fi.isDir()); } +void tst_QDir::makedirReturnCode() +{ + QString dirName = QString::fromLatin1("makedirReturnCode"); + QDir::current().rmdir(dirName); // cleanup a previous run. + QDir dir(dirName); + QVERIFY(!dir.exists()); + QVERIFY(QDir::current().mkdir(dirName)); + QVERIFY(!QDir::current().mkdir(dirName)); // calling mkdir on an existing dir will fail. + QVERIFY(QDir::current().mkpath(dirName)); // calling mkpath on an existing dir will pass +} + void tst_QDir::rmdir_data() { QTest::addColumn("path"); -- cgit v0.12 From 1f8b697da6c6606d57a003666d35115ad72860f2 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 12 Oct 2010 12:04:29 +0100 Subject: Fix deployment for examples and tests Due to the change from default deployment in symbian from being hardcoded in qmake to being in default_deployment.prf the .pro files needed to be changed. Specifically, "DEPLOYMENT = foo" needs to be "DEPLOYMENT += foo" otherwise the default deployment lines are not added and the test won't install. Reviewed-By: Miikka Heikkinen --- demos/declarative/minehunt/minehunt.pro | 2 +- examples/declarative/cppextensions/imageprovider/imageprovider.pro | 2 +- examples/declarative/cppextensions/qwidgets/qwidgets.pro | 2 +- tests/auto/declarative/examples/examples.pro | 2 +- tests/auto/declarative/moduleqt47/moduleqt47.pro | 2 +- tests/auto/declarative/parserstress/parserstress.pro | 2 +- tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro | 2 +- .../qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro | 2 +- .../declarative/qdeclarativeanimations/qdeclarativeanimations.pro | 2 +- .../auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro | 2 +- tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro | 2 +- .../declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro | 2 +- .../declarative/qdeclarativeconnection/qdeclarativeconnection.pro | 2 +- tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro | 2 +- .../declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro | 2 +- .../auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro | 2 +- tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro | 2 +- .../declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro | 2 +- .../qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro | 2 +- .../declarative/qdeclarativefontloader/qdeclarativefontloader.pro | 2 +- tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro | 2 +- tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro | 2 +- tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro | 2 +- tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro | 2 +- tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro | 2 +- .../declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro | 2 +- .../auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro | 2 +- tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro | 2 +- tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro | 2 +- .../qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro | 2 +- .../auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro | 2 +- .../auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro | 2 +- tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro | 2 +- .../declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro | 2 +- .../declarative/qdeclarativepositioners/qdeclarativepositioners.pro | 2 +- tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro | 2 +- tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro | 2 +- tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro | 2 +- .../qdeclarativescriptdebugging/qdeclarativescriptdebugging.pro | 2 +- .../qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro | 2 +- .../qdeclarativespringanimation/qdeclarativespringanimation.pro | 2 +- .../declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro | 2 +- tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro | 2 +- tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro | 2 +- tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro | 2 +- .../auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro | 2 +- .../declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro | 2 +- tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro | 2 +- tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro | 2 +- .../qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro | 2 +- tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro | 2 +- .../declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro | 2 +- .../qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro | 2 +- .../declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro | 2 +- tests/auto/declarative/qmlvisual/qmlvisual.pro | 2 +- tests/auto/networkselftest/networkselftest.pro | 4 ++-- tests/auto/qapplication/test/test.pro | 4 ++-- tests/auto/qaudioinput/qaudioinput.pro | 2 +- tests/auto/qaudiooutput/qaudiooutput.pro | 2 +- tests/auto/qchar/qchar.pro | 2 +- tests/auto/qclipboard/test/test.pro | 2 +- tests/auto/qfile/test/test.pro | 2 +- tests/auto/qfileinfo/qfileinfo.pro | 2 +- tests/auto/qhttp/qhttp.pro | 4 ++-- tests/auto/qlocalsocket/test/test.pro | 2 +- tests/auto/qresourceengine/qresourceengine.pro | 2 +- tests/auto/qsound/qsound.pro | 2 +- tests/benchmarks/declarative/binding/binding.pro | 2 +- tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro | 2 +- tests/benchmarks/declarative/script/script.pro | 2 +- 70 files changed, 73 insertions(+), 73 deletions(-) diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index 753ca4e..4cf1441 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -19,6 +19,6 @@ symbian:{ TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) qmlminehuntfiles.sources = MinehuntCore minehunt.qml - DEPLOYMENT = qmlminehuntfiles + DEPLOYMENT += qmlminehuntfiles } \ No newline at end of file diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.pro b/examples/declarative/cppextensions/imageprovider/imageprovider.pro index 7149986..9797a3f 100644 --- a/examples/declarative/cppextensions/imageprovider/imageprovider.pro +++ b/examples/declarative/cppextensions/imageprovider/imageprovider.pro @@ -24,5 +24,5 @@ symbian:{ importFiles.sources = ImageProviderCore/qmlimageproviderplugin.dll ImageProviderCore/qmldir importFiles.path = ImageProviderCore - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } diff --git a/examples/declarative/cppextensions/qwidgets/qwidgets.pro b/examples/declarative/cppextensions/qwidgets/qwidgets.pro index 2e610f9..3353a8d 100644 --- a/examples/declarative/cppextensions/qwidgets/qwidgets.pro +++ b/examples/declarative/cppextensions/qwidgets/qwidgets.pro @@ -20,5 +20,5 @@ symbian:{ importFiles.sources = QWidgets/qmlqwidgetsplugin.dll QWidgets/qmldir importFiles.path = QWidgets - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index 2e243b4..1a0dc55 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -9,7 +9,7 @@ include(../../../../tools/qml/qml.pri) symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/moduleqt47/moduleqt47.pro b/tests/auto/declarative/moduleqt47/moduleqt47.pro index 4ee634e..711e24c 100644 --- a/tests/auto/declarative/moduleqt47/moduleqt47.pro +++ b/tests/auto/declarative/moduleqt47/moduleqt47.pro @@ -7,7 +7,7 @@ SOURCES += tst_moduleqt47.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/parserstress/parserstress.pro b/tests/auto/declarative/parserstress/parserstress.pro index bb1d69f..17f297b 100644 --- a/tests/auto/declarative/parserstress/parserstress.pro +++ b/tests/auto/declarative/parserstress/parserstress.pro @@ -7,7 +7,7 @@ SOURCES += tst_parserstress.cpp symbian: { importFiles.sources = ..\\..\\qscriptjstestsuite\\tests importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro index 9798bb6..6295079 100644 --- a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro +++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro @@ -6,7 +6,7 @@ macx:CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro index 0a2f0f2..8c2259a 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro @@ -7,7 +7,7 @@ macx:CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro index ed47dca..578f37b 100644 --- a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro +++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro @@ -6,7 +6,7 @@ macx:CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro index cfb59ef..7ba3a7d 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro @@ -6,7 +6,7 @@ macx:CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro index a7ba2a8..0cdaada 100644 --- a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro +++ b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativebinding.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro index a21761b..0e41c13 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro +++ b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro @@ -8,7 +8,7 @@ SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro index d06ce4f..33d81ba 100644 --- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro +++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeconnection.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro index 415d4e2..1866a43 100644 --- a/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro +++ b/tests/auto/declarative/qdeclarativedom/qdeclarativedom.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativedom.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro index 58cad34..2eb333a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro +++ b/tests/auto/declarative/qdeclarativeecmascript/qdeclarativeecmascript.pro @@ -15,7 +15,7 @@ INCLUDEPATH += ../shared symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro index be0ba6c..3f8b5e9 100644 --- a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro +++ b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeflickable.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro index 759e80b..cb42418 100644 --- a/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro +++ b/tests/auto/declarative/qdeclarativeflipable/qdeclarativeflipable.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeflipable.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro index 24749c6..3724a78 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro +++ b/tests/auto/declarative/qdeclarativefocusscope/qdeclarativefocusscope.pro @@ -6,7 +6,7 @@ macx:CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro index 91bf4a7..3299786 100644 --- a/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro +++ b/tests/auto/declarative/qdeclarativefolderlistmodel/qdeclarativefolderlistmodel.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativefolderlistmodel.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro index 01dca26..fbd2550 100644 --- a/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro +++ b/tests/auto/declarative/qdeclarativefontloader/qdeclarativefontloader.pro @@ -8,7 +8,7 @@ SOURCES += tst_qdeclarativefontloader.cpp ../shared/testhttpserver.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro index a99a1b9..4ea1e47 100644 --- a/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro +++ b/tests/auto/declarative/qdeclarativegridview/qdeclarativegridview.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativegridview.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro index 244a1e1..e5db298 100644 --- a/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro +++ b/tests/auto/declarative/qdeclarativeimage/qdeclarativeimage.pro @@ -8,7 +8,7 @@ SOURCES += tst_qdeclarativeimage.cpp ../shared/testhttpserver.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro index 2c20e7e..188ea23 100644 --- a/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro +++ b/tests/auto/declarative/qdeclarativeinfo/qdeclarativeinfo.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeinfo.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro index f4901c4..26bd624 100644 --- a/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro +++ b/tests/auto/declarative/qdeclarativeitem/qdeclarativeitem.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeitem.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro index 43c451f..d702082 100644 --- a/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro +++ b/tests/auto/declarative/qdeclarativelanguage/qdeclarativelanguage.pro @@ -14,7 +14,7 @@ SOURCES += ../shared/testhttpserver.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro index 5076e51..b74ea98 100644 --- a/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro +++ b/tests/auto/declarative/qdeclarativelayoutitem/qdeclarativelayoutitem.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativelayoutitem.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro index e90db49..d1146b1 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro +++ b/tests/auto/declarative/qdeclarativelistmodel/qdeclarativelistmodel.pro @@ -8,7 +8,7 @@ SOURCES += tst_qdeclarativelistmodel.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro index 2c5a859..f26a71e 100644 --- a/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro +++ b/tests/auto/declarative/qdeclarativelistview/qdeclarativelistview.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativelistview.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro index b07bf9e..29b9eb9 100644 --- a/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro +++ b/tests/auto/declarative/qdeclarativeloader/qdeclarativeloader.pro @@ -10,7 +10,7 @@ SOURCES += tst_qdeclarativeloader.cpp \ symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro index fb3630f..36dbb83 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.pro @@ -6,7 +6,7 @@ CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro index 3d39aa8..fec73c5 100644 --- a/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro +++ b/tests/auto/declarative/qdeclarativemousearea/qdeclarativemousearea.pro @@ -8,7 +8,7 @@ SOURCES += tst_qdeclarativemousearea.cpp ../shared/testhttpserver.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro index f9ca90f..9762b7c 100644 --- a/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro +++ b/tests/auto/declarative/qdeclarativeparticles/qdeclarativeparticles.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeparticles.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro index 04fd26b..3270c5e 100644 --- a/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro +++ b/tests/auto/declarative/qdeclarativepathview/qdeclarativepathview.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativepathview.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro index 3130364..2e2c6bc 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro +++ b/tests/auto/declarative/qdeclarativepixmapcache/qdeclarativepixmapcache.pro @@ -12,7 +12,7 @@ SOURCES += ../shared/testhttpserver.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro index 5dc7bb8..f2c9eee 100644 --- a/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro +++ b/tests/auto/declarative/qdeclarativepositioners/qdeclarativepositioners.pro @@ -6,7 +6,7 @@ macx:CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro index 4121a33..504a371 100644 --- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro +++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeproperty.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro index 6af6500..775f445 100644 --- a/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro +++ b/tests/auto/declarative/qdeclarativeqt/qdeclarativeqt.pro @@ -6,7 +6,7 @@ macx:CONFIG -= app_bundle symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro index f3ff9ed..0f3773c 100644 --- a/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro +++ b/tests/auto/declarative/qdeclarativerepeater/qdeclarativerepeater.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativerepeater.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativescriptdebugging/qdeclarativescriptdebugging.pro b/tests/auto/declarative/qdeclarativescriptdebugging/qdeclarativescriptdebugging.pro index c2d30a0..8a63355 100644 --- a/tests/auto/declarative/qdeclarativescriptdebugging/qdeclarativescriptdebugging.pro +++ b/tests/auto/declarative/qdeclarativescriptdebugging/qdeclarativescriptdebugging.pro @@ -11,7 +11,7 @@ INCLUDEPATH += ../shared symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro index 872aeb9..e770d46 100644 --- a/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro +++ b/tests/auto/declarative/qdeclarativesmoothedanimation/qdeclarativesmoothedanimation.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativesmoothedanimation.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro b/tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro index 213b262..07bcbe7 100644 --- a/tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro +++ b/tests/auto/declarative/qdeclarativespringanimation/qdeclarativespringanimation.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativespringanimation.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro index 1462c9a..400512d 100644 --- a/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro +++ b/tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro @@ -8,7 +8,7 @@ SOURCES += tst_qdeclarativesqldatabase.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro index 2bae041..cb3e0fe 100644 --- a/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro +++ b/tests/auto/declarative/qdeclarativestates/qdeclarativestates.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativestates.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro index c1a36fd..28a9fcd 100644 --- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro +++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro @@ -12,7 +12,7 @@ SOURCES += ../shared/testhttpserver.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro index 4b6bd49..8606eb0 100644 --- a/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro +++ b/tests/auto/declarative/qdeclarativetextedit/qdeclarativetextedit.pro @@ -8,7 +8,7 @@ HEADERS += ../shared/testhttpserver.h symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro index 8f42448..7d178d7 100644 --- a/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro +++ b/tests/auto/declarative/qdeclarativetextinput/qdeclarativetextinput.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativetextinput.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro index 90e46d3..56c3cd4 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro +++ b/tests/auto/declarative/qdeclarativevaluetypes/qdeclarativevaluetypes.pro @@ -10,7 +10,7 @@ SOURCES += tst_qdeclarativevaluetypes.cpp \ symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro index 21a9195..2f0a474 100644 --- a/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro +++ b/tests/auto/declarative/qdeclarativeview/qdeclarativeview.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeview.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro index 6189916..08adf26 100644 --- a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro +++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro @@ -9,7 +9,7 @@ SOURCES += tst_qdeclarativeviewer.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro b/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro index 92e5f60..d0d9b36 100644 --- a/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro +++ b/tests/auto/declarative/qdeclarativevisualdatamodel/qdeclarativevisualdatamodel.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativevisualdatamodel.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro index 562a9fb..2ab27a1 100644 --- a/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro +++ b/tests/auto/declarative/qdeclarativewebview/qdeclarativewebview.pro @@ -8,7 +8,7 @@ SOURCES += tst_qdeclarativewebview.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro index 2f8f23d..9d4e0ed 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro +++ b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro @@ -7,7 +7,7 @@ SOURCES += tst_qdeclarativeworkerscript.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro index 619b239..bfd47c5 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/qdeclarativexmlhttprequest.pro @@ -11,7 +11,7 @@ SOURCES += tst_qdeclarativexmlhttprequest.cpp \ symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro index 472cffb..f4b25b5 100644 --- a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro +++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro @@ -11,7 +11,7 @@ SOURCES += tst_qdeclarativexmllistmodel.cpp symbian: { importFiles.sources = data importFiles.path = . - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/declarative/qmlvisual/qmlvisual.pro b/tests/auto/declarative/qmlvisual/qmlvisual.pro index cb7e5d7..be9f26f 100644 --- a/tests/auto/declarative/qmlvisual/qmlvisual.pro +++ b/tests/auto/declarative/qmlvisual/qmlvisual.pro @@ -27,7 +27,7 @@ symbian: { repeater \ selftest_noimages \ webview - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += QT_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" } diff --git a/tests/auto/networkselftest/networkselftest.pro b/tests/auto/networkselftest/networkselftest.pro index d7cb7f3..2217a32 100644 --- a/tests/auto/networkselftest/networkselftest.pro +++ b/tests/auto/networkselftest/networkselftest.pro @@ -6,12 +6,12 @@ QT = core network wince*: { addFiles.sources = rfc3252.txt addFiles.path = . - DEPLOYMENT = addFiles + DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\"\\\" } else:symbian { addFiles.sources = rfc3252.txt addFiles.path = . - DEPLOYMENT = addFiles + DEPLOYMENT += addFiles } else:vxworks*: { DEFINES += SRCDIR=\\\"\\\" } else { diff --git a/tests/auto/qapplication/test/test.pro b/tests/auto/qapplication/test/test.pro index 2c54c37..e1193c2 100644 --- a/tests/auto/qapplication/test/test.pro +++ b/tests/auto/qapplication/test/test.pro @@ -8,7 +8,7 @@ wince* { additional.path = desktopsettingsaware someTest.sources = test.pro someTest.path = test - DEPLOYMENT = additional deploy someTest + DEPLOYMENT += additional deploy someTest } symbian: { @@ -17,7 +17,7 @@ symbian: { someTest.sources = test.pro someTest.path = test windowIcon.sources = ../heart.svg - DEPLOYMENT = additional deploy someTest windowIcon + DEPLOYMENT += additional deploy someTest windowIcon LIBS += -lcone -lavkon } diff --git a/tests/auto/qaudioinput/qaudioinput.pro b/tests/auto/qaudioinput/qaudioinput.pro index 5eb1613..0bbbb19 100644 --- a/tests/auto/qaudioinput/qaudioinput.pro +++ b/tests/auto/qaudioinput/qaudioinput.pro @@ -6,7 +6,7 @@ QT = core multimedia wince* { deploy.sources += 4.wav - DEPLOYMENT = deploy + DEPLOYMENT += deploy DEFINES += SRCDIR=\\\"\\\" QT += gui } else { diff --git a/tests/auto/qaudiooutput/qaudiooutput.pro b/tests/auto/qaudiooutput/qaudiooutput.pro index e1734e0..09d7ae3 100644 --- a/tests/auto/qaudiooutput/qaudiooutput.pro +++ b/tests/auto/qaudiooutput/qaudiooutput.pro @@ -6,7 +6,7 @@ QT = core multimedia wince*|symbian: { deploy.sources += 4.wav - DEPLOYMENT = deploy + DEPLOYMENT += deploy !symbian { DEFINES += SRCDIR=\\\"\\\" QT += gui diff --git a/tests/auto/qchar/qchar.pro b/tests/auto/qchar/qchar.pro index 3813e4e..8224448 100644 --- a/tests/auto/qchar/qchar.pro +++ b/tests/auto/qchar/qchar.pro @@ -5,7 +5,7 @@ QT = core wince*|symbian: { deploy.sources += NormalizationTest.txt -DEPLOYMENT = deploy +DEPLOYMENT += deploy } symbian: { diff --git a/tests/auto/qclipboard/test/test.pro b/tests/auto/qclipboard/test/test.pro index 0f8cad1..620ff36 100644 --- a/tests/auto/qclipboard/test/test.pro +++ b/tests/auto/qclipboard/test/test.pro @@ -26,5 +26,5 @@ wince*|symbian: { reg_resource.path = $$REG_RESOURCE_IMPORT_DIR } - DEPLOYMENT = copier paster rsc reg_resource + DEPLOYMENT += copier paster rsc reg_resource } \ No newline at end of file diff --git a/tests/auto/qfile/test/test.pro b/tests/auto/qfile/test/test.pro index 70c93ce..9a2d847 100644 --- a/tests/auto/qfile/test/test.pro +++ b/tests/auto/qfile/test/test.pro @@ -10,7 +10,7 @@ wince*|symbian { resour.sources += ..\\resources\\file1.ext1 resour.path = resources - DEPLOYMENT = files resour + DEPLOYMENT += files resour } wince* { diff --git a/tests/auto/qfileinfo/qfileinfo.pro b/tests/auto/qfileinfo/qfileinfo.pro index 30656e2..7df721e 100644 --- a/tests/auto/qfileinfo/qfileinfo.pro +++ b/tests/auto/qfileinfo/qfileinfo.pro @@ -10,7 +10,7 @@ wince*:|symbian: { deploy.sources += qfileinfo.qrc tst_qfileinfo.cpp res.sources = resources\\file1 resources\\file1.ext1 resources\\file1.ext1.ext2 res.path = resources - DEPLOYMENT = deploy res + DEPLOYMENT += deploy res } symbian { diff --git a/tests/auto/qhttp/qhttp.pro b/tests/auto/qhttp/qhttp.pro index c0be518..b7b78f1 100644 --- a/tests/auto/qhttp/qhttp.pro +++ b/tests/auto/qhttp/qhttp.pro @@ -11,7 +11,7 @@ wince*: { cgi.path = webserver/cgi-bin addFiles.sources = rfc3252.txt trolltech addFiles.path = . - DEPLOYMENT = addFiles webFiles cgi + DEPLOYMENT += addFiles webFiles cgi DEFINES += SRCDIR=\\\"\\\" } else:symbian { webFiles.sources = webserver/* @@ -20,7 +20,7 @@ wince*: { cgi.path = webserver/cgi-bin addFiles.sources = rfc3252.txt trolltech addFiles.path = . - DEPLOYMENT = addFiles webFiles cgi + DEPLOYMENT += addFiles webFiles cgi TARGET.CAPABILITY = NetworkServices } else:vxworks*: { DEFINES += SRCDIR=\\\"\\\" diff --git a/tests/auto/qlocalsocket/test/test.pro b/tests/auto/qlocalsocket/test/test.pro index 687aae2..0ee1cb6 100644 --- a/tests/auto/qlocalsocket/test/test.pro +++ b/tests/auto/qlocalsocket/test/test.pro @@ -42,7 +42,7 @@ symbian { wince*|symbian { scriptFiles.sources = ../lackey/scripts/*.js scriptFiles.path = lackey/scripts - DEPLOYMENT = additionalFiles scriptFiles + DEPLOYMENT += additionalFiles scriptFiles QT += script # for easy deployment of QtScript requires(contains(QT_CONFIG,script)) diff --git a/tests/auto/qresourceengine/qresourceengine.pro b/tests/auto/qresourceengine/qresourceengine.pro index 17e36af..1ad0f5d 100644 --- a/tests/auto/qresourceengine/qresourceengine.pro +++ b/tests/auto/qresourceengine/qresourceengine.pro @@ -38,7 +38,7 @@ wince*|symbian:{ testsub.path = testqrc/test testsub2.sources = testqrc/test/test/* testsub2.path = testqrc/test/test - DEPLOYMENT = deploy test alias other search1 search2 sub testsub testsub2 + DEPLOYMENT += deploy test alias other search1 search2 sub testsub testsub2 !symbian:DEFINES += SRCDIR=\\\"\\\" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/qsound/qsound.pro b/tests/auto/qsound/qsound.pro index bb1981c..e3279f3 100644 --- a/tests/auto/qsound/qsound.pro +++ b/tests/auto/qsound/qsound.pro @@ -3,7 +3,7 @@ SOURCES += tst_qsound.cpp wince*|symbian: { deploy.sources += 4.wav - DEPLOYMENT = deploy + DEPLOYMENT += deploy !symbian:DEFINES += SRCDIR=\\\"\\\" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro index c1a8223..b93977a 100644 --- a/tests/benchmarks/declarative/binding/binding.pro +++ b/tests/benchmarks/declarative/binding/binding.pro @@ -10,7 +10,7 @@ HEADERS += testtypes.h symbian { data.sources = data data.path = . - DEPLOYMENT = data + DEPLOYMENT += data } else { # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro index a68792b..313282b 100644 --- a/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro +++ b/tests/benchmarks/declarative/qdeclarativeimage/qdeclarativeimage.pro @@ -10,7 +10,7 @@ SOURCES += tst_qdeclarativeimage.cpp symbian { importFiles.sources = image.png importFiles.path = - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/benchmarks/declarative/script/script.pro b/tests/benchmarks/declarative/script/script.pro index 685ba03..759c6dd 100644 --- a/tests/benchmarks/declarative/script/script.pro +++ b/tests/benchmarks/declarative/script/script.pro @@ -10,7 +10,7 @@ SOURCES += tst_script.cpp symbian { importFiles.sources = data importFiles.path = - DEPLOYMENT = importFiles + DEPLOYMENT += importFiles } else { DEFINES += SRCDIR=\\\"$$PWD\\\" } -- cgit v0.12 From ec1c89a9440cefc0ebea225d3aeca2decb56e690 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 12 Oct 2010 17:32:29 +0100 Subject: Correct errors in the qimagereader autotest First, pgm and pbm formats need the same exception given to ppm format as they are subtypes of the same format. (as text based image formats they are vulnerable to line end differences) Second, a workaround for the readFromDevice test case hanging on the symbian emulator. The test expects to be able to send a whole image to a socket and have this fit within the send/receive buffers of the TCP stack. At least for the emulator's winsock backend, this hangs the autotest inside a blocking write. On the Nokia 5800, the test passed so it's currently skipped only for the emulator. Reviewed-By: Jason Barron --- tests/auto/qimagereader/tst_qimagereader.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/auto/qimagereader/tst_qimagereader.cpp b/tests/auto/qimagereader/tst_qimagereader.cpp index 4b4bdd6..a6fb886 100644 --- a/tests/auto/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/qimagereader/tst_qimagereader.cpp @@ -1098,6 +1098,11 @@ void tst_QImageReader::readFromDevice() QCOMPARE(image1, expectedImage); } +#if defined (Q_OS_SYMBIAN) && defined (__WINS__) + //the emulator hangs in socket write (this is a test bug, it assumes the TCP stack can accept a whole image to its buffers) + if(imageData.size() > 16384) + QSKIP("image larger than socket buffer (test needs to be rewritten)", SkipSingle); +#endif Server server(imageData); QEventLoop loop; connect(&server, SIGNAL(ready()), &loop, SLOT(quit())); @@ -1249,7 +1254,10 @@ void tst_QImageReader::devicePosition() buf.seek(preLen); QImageReader reader(&buf, format); QCOMPARE(expected, reader.read()); - if (format != "ppm" && format != "gif") // Known not to work + if (format != "ppm" && + format != "pgm" && + format != "pbm" && + format != "gif") // Known not to work QCOMPARE(buf.pos(), qint64(preLen+imageDataSize)); } -- cgit v0.12 From 0aa70ec7195e7a6ee07f73ac3c37030c9d37b132 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 12 Oct 2010 17:38:24 +0100 Subject: Fix for QFile::copy failing silently with relative paths CFileMan doesn't support . and .. in relative paths. Therefore, paths are converted to absolute first. Also, the error was being ignored which has been fixed. Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index d068248..e2dfe53 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -302,10 +302,11 @@ bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSyst CFileMan *fm = 0; TRAPD(err, fm = CFileMan::NewL(qt_s60GetRFs())); if (err == KErrNone) { - err = fm->Copy(qt_QString2TPtrC(source.nativeFilePath()), qt_QString2TPtrC(target.nativeFilePath()), 0); + err = fm->Copy(qt_QString2TPtrC(absoluteName(source).nativeFilePath()), qt_QString2TPtrC(absoluteName(target).nativeFilePath()), 0); delete fm; - return true; } + if (err == KErrNone) + return true; error = QSystemError(err, QSystemError::NativeError); return false; } -- cgit v0.12 From 5c5a74aa789a876805dbdb0f58de03c2195c3b97 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 12 Oct 2010 17:40:21 +0100 Subject: Fix for qfileinfo isExecutable test case. Files in /sys/bin/ on any drive can be assumed to be executable. So the executable flag is set in the metadata for this path, even though RFs::Entry fails due to permissions (so we don't know if the file exists or not) Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 3 +++ tests/auto/qfileinfo/tst_qfileinfo.cpp | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index e2dfe53..dcb99d4 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -244,6 +244,9 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM data.modificationTime_ = TTime(0); data.entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); } + //files in /sys/bin on any drive are executable, even though we don't normally have permission to check whether they exist or not + if(absentry.filePath().midRef(1,10).compare(QLatin1String(":/sys/bin/"), Qt::CaseInsensitive) == 0) + data.entryFlags |= QFileSystemMetaData::ExecutePermissions; } return data.hasFlags(what); } diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index e4aa0d3..d2019b1 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1465,9 +1465,6 @@ void tst_QFileInfo::isWritable() void tst_QFileInfo::isExecutable() { #ifdef Q_OS_SYMBIAN -# if defined(Q_CC_NOKIAX86) - QSKIP("Impossible to implement reading/touching of application binaries in Symbian emulator", SkipAll); -# endif QString appPath = "c:/sys/bin/tst_qfileinfo.exe"; #else QString appPath = QCoreApplication::applicationDirPath(); -- cgit v0.12 From 303bb0a3d60c3d7b991ea7829c6dd2c5b3beb9d6 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 13 Oct 2010 14:20:38 +0100 Subject: Fix crash in QApplication auto test The pointer is lazily initialised by QWidget, but becomes invalid after the application is destroyed. In the QApplication autotest, QApplication is created and destroyed many times in the same thread (while in normal use it is created at startup and destroyed on exit) As a result, the pointer which is stored in global data became stale and caused a crash due to calling functions on a deleted object. Reviewed-By: Jason Barron --- src/gui/kernel/qapplication_s60.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index ad44d21..57702c6 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1613,6 +1613,9 @@ extern void qt_cleanup_symbianFontDatabaseExtras(); // qfontdatabase_s60.cpp *****************************************************************************/ void qt_cleanup() { +#ifdef Q_WS_S60 + S60->setButtonGroupContainer(0); +#endif if(qt_S60Beep) { delete qt_S60Beep; qt_S60Beep = 0; -- cgit v0.12 From 7a5adf67655b54a0ea43b641dfbd0924b06d214a Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 13 Oct 2010 17:40:03 +0100 Subject: Create regression test for QFileInfo("").exists() File engine refactor caused a regression in QTextDocument, due to a QFileInfo constructed with an empty string returning true from exists() Added a test case to QFileInfo to catch this at the correct level. Reviewed-By: joao --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index d2019b1..cd1a597 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -412,6 +412,7 @@ void tst_QFileInfo::exists_data() QTest::newRow("data9") << SRCDIR "resources/file?.ext1" << false; QTest::newRow("data10") << "." << true; QTest::newRow("data11") << ". " << false; + QTest::newRow("empty") << "" << false; QTest::newRow("simple dir") << SRCDIR "resources" << true; QTest::newRow("simple dir with slash") << SRCDIR "resources/" << true; -- cgit v0.12 From c822fba71e2949eea3de49009ef99602a4110914 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 13 Oct 2010 17:42:54 +0100 Subject: Fix QFileInfo("").exists() regression for symbian Because RFs::Entry("") gets the entry for the current directory, we need to explicitly check for empty strings and treat as a non existant file. Reviewed-By: joao --- src/corelib/io/qfilesystemengine_symbian.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index dcb99d4..89a2b29 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -222,7 +222,9 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM RFs& fs(qt_s60GetRFs()); TInt err; QFileSystemEntry absentry(absoluteName(entry)); - if (absentry.isRoot()) { + if (entry.isEmpty()) { + err = KErrNotFound; + } else if (absentry.isRoot()) { //Root directories don't have an entry, and Entry() returns KErrBadName. //Therefore get information about the volume instead. TInt drive; -- cgit v0.12 From 9ea66f867c1aeb60dc4e90acefb2258a084740ca Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 13 Oct 2010 19:00:00 +0100 Subject: Autotest for seeking beyond end of file and then writing File engine refactor caused a regression in the TIFF image codec, as QFile::seek() previously worked like lseek() / fseek() in posix. But on symbian the native RFile::Seek api clamps to the end of the file if you attempt to seek beyond there. This test checks seek behaviour in the appropriate place, the QFile auto test. Reviewed-By: joao --- tests/auto/qfile/tst_qfile.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 2524e6e..4e7cb9f 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -170,6 +170,7 @@ private slots: void encodeName(); void truncate(); void seekToPos(); + void seekAfterEndOfFile(); void FILEReadWrite(); void i18nFileName_data(); void i18nFileName(); @@ -1644,6 +1645,36 @@ void tst_QFile::seekToPos() } +void tst_QFile::seekAfterEndOfFile() +{ + QLatin1String filename("seekAfterEof.dat"); + QFile::remove(filename); + { + QFile file(filename); + QVERIFY(file.open(QFile::WriteOnly)); + file.write("abcd"); + QCOMPARE(file.size(), qint64(4)); + file.seek(8); + file.write("ijkl"); + QCOMPARE(file.size(), qint64(12)); + file.seek(4); + file.write("efgh"); + QCOMPARE(file.size(), qint64(12)); + file.seek(16); + file.write("----"); + QCOMPARE(file.size(), qint64(20)); + file.flush(); + } + + QFile file(filename); + QVERIFY(file.open(QFile::ReadOnly)); + QByteArray contents = file.readAll(); + QCOMPARE(contents.left(12), QByteArray("abcdefghijkl", 12)); + //bytes 12-15 are uninitialised so we don't care what they read as. + QCOMPARE(contents.mid(16), QByteArray("----", 4)); + file.close(); + QFile::remove(filename); +} void tst_QFile::FILEReadWrite() { -- cgit v0.12 From a2a748f59a14f71c7f7cd5762ae9d358af2518c3 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 14 Oct 2010 14:42:34 +0100 Subject: Fix crashes and hangs in qprocess autotest The qprocess autotest launches various sub processes and checks their results, but this lacked error handling. Added a QVERIFY when opening files (if fopen returned NULL, the test fails instead of crashing) Added a 10s guard when waiting for a subprocess to create a file - previously this loop did not terminate if the subprocess failed. Reviewed-By: Markus Goetz --- tests/auto/qprocess/tst_qprocess.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index fd310f4..a497b13 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -1585,6 +1585,7 @@ void tst_QProcess::spaceArgsTest() #if defined(Q_OS_SYMBIAN) // Symbian test outputs to a file, so check that FILE* file = fopen("c:\\logs\\qprocess_args_test.txt","r"); + QVERIFY(file); char buf[256]; fgets(buf, 256, file); fclose(file); @@ -1614,6 +1615,7 @@ void tst_QProcess::spaceArgsTest() #if defined(Q_OS_SYMBIAN) // Symbian test outputs to a file, so check that file = fopen("c:\\logs\\qprocess_args_test.txt","r"); + QVERIFY(file); fgets(buf, 256, file); fclose(file); actual = QString::fromLatin1(buf).split("|"); @@ -1661,6 +1663,7 @@ void tst_QProcess::nativeArguments() # else FILE* file = fopen("\\temp\\qprocess_args_test.txt","r"); # endif + QVERIFY(file); char buf[256]; fgets(buf, 256, file); fclose(file); @@ -2285,7 +2288,9 @@ void tst_QProcess::detachedWorkingDirectoryAndPid() QFileInfo fi(infoFile); fi.setCaching(false); - while (fi.size() == 0) { + //The guard counter ensures the test does not hang if the sub process fails. + //Instead, the test will fail when trying to open & verify the sub process output file. + for (int guard = 0; guard < 100 && fi.size() == 0; guard++) { QTest::qSleep(100); } @@ -2397,6 +2402,7 @@ void tst_QProcess::startFinishStartFinish() #if defined(Q_OS_SYMBIAN) // Symbian test outputs to a file, so check that FILE* file = fopen("c:\\logs\\qprocess_output_test.txt","r"); + QVERIFY(file); char buf[30]; fgets(buf, 30, file); QCOMPARE(QString::fromLatin1(buf), -- cgit v0.12 From 2e35e9c1eabe667798572457c61e1d1d1f373317 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 15 Oct 2010 12:12:49 +0100 Subject: Document behaviour of QFile::seek when seeking beyond EOF Reviewed-By: joao --- src/corelib/io/qfile.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 50e9a8f..a0bc68e 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1477,7 +1477,17 @@ bool QFile::atEnd() const } /*! - \reimp + For random-access devices, this function sets the current position + to \a pos, returning true on success, or false if an error occurred. + For sequential devices, the default behavior is to do nothing and + return false. + + Seeking beyond the end of a file: + If the position is beyond the end of a file, then seek() shall not + immediately extend the file. If a write is performed at this position, + then the file shall be extended. The content of the file between the + previous end of file and the newly written data is UNDEFINED and + varies between platforms and file systems. */ bool QFile::seek(qint64 off) -- cgit v0.12 From 366d2ed09ebf5aa27171a46d723497e5aaa5dd06 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 18 Oct 2010 15:15:39 +0100 Subject: Implement seek beyond end of file for symbian On Symbian, the Seek() function clamps to the end of file position if a position beyond the end of file is given. Also the write functions which take a position silently append at the end of file position if asked to write to a start position beyond EOF. To avoid this behaviour, we don't use seek but rather maintain our own cursor position. When writing, we check if the cursor is beyond EOF and if so extend the file using SetSize() before writing. Reviewed-By: joao --- src/corelib/io/qfsfileengine_unix.cpp | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index caf5f4c..96946d6 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -382,12 +382,13 @@ qint64 QFSFileEnginePrivate::nativeRead(char *data, qint64 len) return -1; } TPtr8 ptr(reinterpret_cast(data), static_cast(len)); - TInt r = symbianFile.Read(ptr); + TInt r = symbianFile.Read(symbianFilePos, ptr); if (r != KErrNone) { q->setError(QFile::ReadError, QSystemError(r, QSystemError::NativeError).toString()); return -1; } + symbianFilePos += ptr.Length(); return qint64(ptr.Length()); } #endif @@ -467,12 +468,28 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len) return -1; } const TPtrC8 ptr(reinterpret_cast(data), static_cast(len)); - TInt r = symbianFile.Write(ptr); - if (r != KErrNone) - { +#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API + TInt64 eofpos = 0; +#else + TInt eofpos = 0; +#endif + //The end of file position is not cached because QFile is read/write sharable, therefore another + //process may have altered the file size. + TInt r = symbianFile.Seek(ESeekEnd, eofpos); + if (r == KErrNone && symbianFilePos > eofpos) { + //seek position is beyond end of file so file needs to be extended before write. + //note that SetSize does not zero-initialise (c.f. posix lseek) + r = symbianFile.SetSize(symbianFilePos); + } + if (r == KErrNone) { + //write to specific position in the file (i.e. use our own cursor rather than calling seek) + r = symbianFile.Write(symbianFilePos, ptr); + } + if (r != KErrNone) { q->setError(QFile::WriteError, QSystemError(r, QSystemError::NativeError).toString()); return -1; } + symbianFilePos += len; return len; } #endif @@ -487,17 +504,7 @@ qint64 QFSFileEnginePrivate::nativePos() const #ifdef Q_OS_SYMBIAN const Q_Q(QFSFileEngine); if (symbianFile.SubSessionHandle()) { -#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API - qint64 pos = 0; -#else - TInt pos = 0; -#endif - TInt err = symbianFile.Seek(ESeekCurrent, pos); - if(err != KErrNone) { - const_cast(q)->setError(QFile::PositionError, QSystemError(err, QSystemError::NativeError).toString()); - return -1; - } - return pos; + return symbianFilePos; } #endif return posFdFh(); @@ -511,21 +518,13 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos) #ifdef Q_OS_SYMBIAN Q_Q(QFSFileEngine); if (symbianFile.SubSessionHandle()) { -#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API - TInt r = symbianFile.Seek(ESeekStart, pos); -#else +#ifndef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API if(pos > KMaxTInt) { q->setError(QFile::PositionError, QLatin1String("Maximum 2GB file position on this platform")); return false; } - TInt pos32(pos); - TInt r = symbianFile.Seek(ESeekStart, pos32); #endif - if (r != KErrNone) - { - q->setError(QFile::PositionError, QSystemError(r, QSystemError::NativeError).toString()); - return false; - } + symbianFilePos = pos; return true; } #endif @@ -867,6 +866,8 @@ bool QFSFileEngine::setSize(qint64 size) if (d->symbianFile.SubSessionHandle()) { TInt err = d->symbianFile.SetSize(size); ret = (err == KErrNone); + if (ret && d->symbianFilePos > size) + d->symbianFilePos = size; } else if (d->fd != -1) ret = QT_FTRUNCATE(d->fd, size) == 0; -- cgit v0.12 From 4bdf081da0276f55662de826568441ca0e85e877 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 14 Oct 2010 14:06:20 +0100 Subject: Move QDir::fromNativeSeparators call to the QFileSystemEntry constructor The m_filePath should always have / as the separator, while m_nativeFilePath should always have the native separator. Almost every place the constructor is used, the path could be one passed into an API from code outside our control. So it's easier to do the path conversion in the constructor than to have to remember to call fromNativeSeparators in every place a QFileSystemEntry is constructed (especially since unix tests won't reveal any error) Reviewed-By: joao --- src/corelib/io/qdir.cpp | 6 +++--- src/corelib/io/qfilesystemengine_symbian.cpp | 2 +- src/corelib/io/qfilesystemengine_win.cpp | 2 +- src/corelib/io/qfilesystementry.cpp | 24 +++++++++++++++++++++++- src/corelib/io/qfilesystementry_p.h | 2 ++ src/corelib/io/qfsfileengine.cpp | 4 ++-- src/corelib/io/qfsfileengine_unix.cpp | 2 +- 7 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index e9bc012..22a3baa 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -177,7 +177,7 @@ inline void QDirPrivate::setPath(const QString &path) p.truncate(p.length() - 1); } - dirEntry = QFileSystemEntry(p); + dirEntry = QFileSystemEntry(p, QFileSystemEntry::FromInternalPath()); metaData.clear(); initFileEngine(); clearFileLists(); @@ -198,7 +198,7 @@ inline void QDirPrivate::resolveAbsoluteEntry() const if (dirEntry.isRelative()) { QFileSystemEntry answer = QFileSystemEngine::absoluteName(dirEntry); - absoluteDirEntry = QFileSystemEntry(QDir::cleanPath(answer.filePath())); + absoluteDirEntry = QFileSystemEntry(QDir::cleanPath(answer.filePath()), QFileSystemEntry::FromInternalPath()); } else { absoluteDirEntry = dirEntry; } @@ -1757,7 +1757,7 @@ QChar QDir::separator() */ bool QDir::setCurrent(const QString &path) { - return QFileSystemEngine::setCurrentPath(QFileSystemEntry(fromNativeSeparators(path))); + return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path)); } /*! diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 89a2b29..c4e8d36 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -148,7 +148,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) result.append(orig); } - return QFileSystemEntry(symbianCleanAbsolutePath(result)); + return QFileSystemEntry(symbianCleanAbsolutePath(result), QFileSystemEntry::FromInternalPath()); } //static diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 53b9e43..8fa4d62 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -444,7 +444,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, ret = readLink(link); else if (data.isLink()) ret = readSymLink(link); - return QFileSystemEntry(QDir::fromNativeSeparators(ret)); + return QFileSystemEntry(ret); } //static diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index bc7f121..d4c6d0a 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -81,7 +81,25 @@ QFileSystemEntry::QFileSystemEntry() { } +/*! + \internal + Use this constructor when the path is supplied by user code, as it may contain a mix + of '/' and the native separator. + */ QFileSystemEntry::QFileSystemEntry(const QString &filePath) + : m_filePath(QDir::fromNativeSeparators(filePath)), + m_lastSeparator(-2), + m_firstDotInFileName(-2), + m_lastDotInFileName(0) +{ +} + +/*! + \internal + Use this constructor when the path is guaranteed to be in internal format, i.e. all + directory separators are '/' and not the native separator. + */ +QFileSystemEntry::QFileSystemEntry(const QString &filePath, FromInternalPath /* dummy */) : m_filePath(filePath), m_lastSeparator(-2), m_firstDotInFileName(-2), @@ -89,6 +107,10 @@ QFileSystemEntry::QFileSystemEntry(const QString &filePath) { } +/*! + \internal + Use this constructor when the path comes from a native API + */ QFileSystemEntry::QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath /* dummy */) : m_nativeFilePath(nativeFilePath), m_lastSeparator(-2), @@ -98,7 +120,7 @@ QFileSystemEntry::QFileSystemEntry(const NativePath &nativeFilePath, FromNativeP } QFileSystemEntry::QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath) - : m_filePath(filePath), + : m_filePath(QDir::fromNativeSeparators(filePath)), m_nativeFilePath(nativeFilePath), m_lastSeparator(-2), m_firstDotInFileName(-2), diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h index 7a9c2a5..2ce0a83 100644 --- a/src/corelib/io/qfilesystementry_p.h +++ b/src/corelib/io/qfilesystementry_p.h @@ -72,10 +72,12 @@ public: typedef QString NativePath; #endif struct FromNativePath{}; + struct FromInternalPath{}; QFileSystemEntry(); explicit QFileSystemEntry(const QString &filePath); + QFileSystemEntry(const QString &filePath, FromInternalPath dummy); QFileSystemEntry(const NativePath &nativeFilePath, FromNativePath dummy); QFileSystemEntry(const QString &filePath, const NativePath &nativeFilePath); diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 9c8df39..5491caf 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -140,7 +140,7 @@ QFSFileEngine::QFSFileEngine(const QString &file) : QAbstractFileEngine(*new QFSFileEnginePrivate) { Q_D(QFSFileEngine); - d->fileEntry = QFileSystemEntry(QDir::fromNativeSeparators(file)); + d->fileEntry = QFileSystemEntry(file); } /*! @@ -189,7 +189,7 @@ void QFSFileEngine::setFileName(const QString &file) { Q_D(QFSFileEngine); d->init(); - d->fileEntry = QFileSystemEntry(QDir::fromNativeSeparators(file)); + d->fileEntry = QFileSystemEntry(file); } /*! diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 96946d6..28e0677 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -640,7 +640,7 @@ bool QFSFileEngine::caseSensitive() const bool QFSFileEngine::setCurrentPath(const QString &path) { - return QFileSystemEngine::setCurrentPath(QFileSystemEntry(QDir::fromNativeSeparators(path))); + return QFileSystemEngine::setCurrentPath(QFileSystemEntry(path)); } QString QFSFileEngine::currentPath(const QString &) -- cgit v0.12 From 064c5714c2167fb2ddfb4f1ab2f706282444884f Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 19 Oct 2010 10:12:30 +0100 Subject: Fix compile error in tst_qxmlstream The same workaround used for other autotests, as the symbian build system doesn't accept \" in DEFINES. Reviewed-By: Janne Koskinen --- tests/auto/qxmlstream/qxmlstream.pro | 2 +- tests/auto/qxmlstream/tst_qxmlstream.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qxmlstream/qxmlstream.pro b/tests/auto/qxmlstream/qxmlstream.pro index 8f076be..31331cf 100644 --- a/tests/auto/qxmlstream/qxmlstream.pro +++ b/tests/auto/qxmlstream/qxmlstream.pro @@ -8,7 +8,7 @@ wince*|symbian: { addFiles.sources = data XML-Test-Suite addFiles.path = . DEPLOYMENT += addFiles - DEFINES += SRCDIR=\\\"\\\" + wince*:DEFINES += SRCDIR=\\\"\\\" } else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp index 7d5e3b7..19e4b90 100644 --- a/tests/auto/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp @@ -55,6 +55,10 @@ //TESTED_CLASS=QXmlStreamReader QXmlStreamWriter //TESTED_FILES=corelib/xml/stream/qxmlutils.cpp corelib/xml/stream/qxmlstream.cpp corelib/xml/stream/qxmlstream_p.h +#ifdef Q_OS_SYMBIAN +#define SRCDIR "" +#endif + Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour) static const char *const catalogFile = SRCDIR "XML-Test-Suite/xmlconf/finalCatalog.xml"; -- cgit v0.12 From ea69ae0df02de27ec0f0a1a9b0a122655445fc01 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 20 Oct 2010 13:36:00 +0100 Subject: Fix QFileDialog regression in symbian Symbian now follows the same convention as windows, where "c:" means the working directory on the C: drive. As a result, the path "c:/" needs to be passed to QFileInfoGatherer when getting info for the root directory. This code already existed but only enabled for windows - now enabled for symbian as well. Reviewed-By: Markus Goetz --- src/gui/dialogs/qfilesystemmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index b8aafe3..be4261d 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1290,7 +1290,7 @@ QString QFileSystemModelPrivate::filePath(const QModelIndex &index) const if ((fullPath.length() > 2) && fullPath[0] == QLatin1Char('/') && fullPath[1] == QLatin1Char('/')) fullPath = fullPath.mid(1); #endif -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) if (fullPath.length() == 2 && fullPath.endsWith(QLatin1Char(':'))) fullPath.append(QLatin1Char('/')); #endif -- cgit v0.12 From 12ae7dea67244458fc92575ae2f49a8e32343047 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 20 Oct 2010 13:45:50 +0100 Subject: Fix errors in the QFileDialog autotest The filesSelectedSignal() test case was using the Qt source tree as its test directory - however this is not deployed to the device for symbian and windows CE. On symbian, the path evaluates to the root directory, which doesn't meet the conditions of the test (it contains only directories, while the test requires both files and directories to be present) Changed the test to use SRCDIR (on desktops, the source directory of the test code; on symbian/wince the deployed files location) This directory is valid for the test as it contains both files and directories. The hooks() test case crashes on symbian versions prior to symbian^3, because data exports from dlls are not properly supported by the symbian kernel So, this test is skipped for old symbian versions (if a test crashes, then no xml result file is created) Reviewed-By: Markus Goetz --- tests/auto/qfiledialog/tst_qfiledialog.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 5d369b4..ec244c5 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -279,7 +279,7 @@ void tst_QFiledialog::filesSelectedSignal() QNonNativeFileDialog fd; fd.setViewMode(QFileDialog::List); fd.setOptions(QFileDialog::DontUseNativeDialog); - QDir testDir(SRCDIR"/../../.."); + QDir testDir(SRCDIR); fd.setDirectory(testDir); QFETCH(QFileDialog::FileMode, fileMode); fd.setFileMode(fileMode); @@ -1308,6 +1308,10 @@ QString saveName(QWidget *, const QString &, const QString &, const QString &, Q void tst_QFiledialog::hooks() { +#ifdef Q_OS_SYMBIAN + if(QSysInfo::symbianVersion() < QSysInfo::SV_SF_3) + QSKIP("writing to data exports in paged dll not supported and crashes on symbian versions prior to ^3", SkipAll); +#endif qt_filedialog_existing_directory_hook = &existing; qt_filedialog_save_filename_hook = &saveName; qt_filedialog_open_filename_hook = &openName; -- cgit v0.12 From 848bbec851ca1bb83ce43aa07240c28cdcb0125a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 22 Oct 2010 10:50:40 +0200 Subject: Fix qmake compilation on *nix platforms --- qmake/Makefile.unix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 7d61cf8..f1697a9 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -106,7 +106,7 @@ qsettings.o: $(SOURCE_PATH)/src/corelib/io/qsettings.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/io/qsettings.cpp qsystemerror.o: $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp - $(CXX) $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp + $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/kernel/qsystemerror.cpp qlibraryinfo.o: $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp $(CXX) -c -o $@ $(CXXFLAGS) $(SOURCE_PATH)/src/corelib/global/qlibraryinfo.cpp -- cgit v0.12 From 02f3d23bc2cb6f4011918cff50fe157a8523c10b Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 26 Oct 2010 13:48:15 +0200 Subject: Add support for QFileInfo owner() & group() on Windows Since windows doesn't have the concept of user and group IDs, the name resolution has to be done differently. If the qt_ntfs_permission_lookup flag is set (default = 0), the user information is retrieved through the NTFS object security information. Reviewed-by: Joao --- src/corelib/io/qfilesystemengine.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 9bfd382..8613dd7 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -349,17 +349,35 @@ void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry) //static QString QFileSystemEngine::resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData) { +#if defined (Q_OS_SYMBIAN) + Q_UNUSED(entry); + Q_UNUSED(metaData); + return QString(); +#elif defined(Q_OS_WIN) + Q_UNUSED(metaData); + return QFileSystemEngine::owner(entry, QAbstractFileEngine::OwnerUser); +#else //(Q_OS_UNIX) if (!metaData.hasFlags(QFileSystemMetaData::UserId)) QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId); return resolveGroupName(metaData.userId()); +#endif } //static QString QFileSystemEngine::resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData) { +#if defined (Q_OS_SYMBIAN) + Q_UNUSED(entry); + Q_UNUSED(metaData); + return QString(); +#elif defined(Q_OS_WIN) + Q_UNUSED(metaData); + return QFileSystemEngine::owner(entry, QAbstractFileEngine::OwnerGroup); +#else //(Q_OS_UNIX) if (!metaData.hasFlags(QFileSystemMetaData::GroupId)) QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::GroupId); return resolveGroupName(metaData.groupId()); +#endif } QT_END_NAMESPACE -- cgit v0.12 From ae9b1a4a392953097d05d55549cc1583f94c3bc8 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 27 Oct 2010 13:48:43 +0200 Subject: Add tests for QFileInfo::owner() Reviewed-by: Joao --- tests/auto/qfileinfo/qfileinfo.pro | 2 ++ tests/auto/qfileinfo/tst_qfileinfo.cpp | 66 ++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/tests/auto/qfileinfo/qfileinfo.pro b/tests/auto/qfileinfo/qfileinfo.pro index 7df721e..101128c 100644 --- a/tests/auto/qfileinfo/qfileinfo.pro +++ b/tests/auto/qfileinfo/qfileinfo.pro @@ -13,6 +13,8 @@ wince*:|symbian: { DEPLOYMENT += deploy res } +win32*:LIBS += -ladvapi32 -lnetapi32 + symbian { TARGET.CAPABILITY=AllFiles LIBS *= -lefsrv diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index cd1a597..898bf54 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -59,6 +59,7 @@ #define _WIN32_WINNT 0x500 #include #include +#include #endif #include #include @@ -184,6 +185,10 @@ private slots: void notEqualOperator() const; void detachingOperations(); + +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) + void owner(); +#endif }; tst_QFileInfo::tst_QFileInfo() @@ -1599,5 +1604,66 @@ void tst_QFileInfo::detachingOperations() QVERIFY(!info1.caching()); } +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) +void tst_QFileInfo::owner() +{ + QString userName; +#if defined(Q_OS_UNIX) + char *usernameBuf = getlogin(); + if (usernameBuf) { + userName = QString::fromLocal8Bit(usernameBuf); + } +#endif +#if defined(Q_OS_WIN) + wchar_t usernameBuf[1024]; + DWORD bufSize = 1024; + if (GetUserNameW(usernameBuf, &bufSize)) { + userName = QString::fromWCharArray(usernameBuf, bufSize); + // Special case : If the user is a member of Adminstrators group, all files + // created by the current user are owned by the Admistrators group. + LPLOCALGROUP_USERS_INFO_0 pBuf = NULL; + DWORD dwLevel = 0; + DWORD dwFlags = LG_INCLUDE_INDIRECT ; + DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH; + DWORD dwEntriesRead = 0; + DWORD dwTotalEntries = 0; + NET_API_STATUS nStatus; + nStatus = NetUserGetLocalGroups(0, usernameBuf, dwLevel, dwFlags, (LPBYTE *) &pBuf, + dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries); + // Check if the current user is a member of Adminstrators group + if (nStatus == NERR_Success && pBuf){ + for (int i = 0; i < dwEntriesRead; i++) { + QString groupName = QString::fromWCharArray(pBuf[i].lgrui0_name); + if (!groupName.compare(QLatin1String("Administrators"))) + userName = groupName; + } + } + if (pBuf != NULL) + NetApiBufferFree(pBuf); + } + extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; + qt_ntfs_permission_lookup = 1; +#endif + if (userName.isEmpty()) + QSKIP("Can't retrieve the user name", SkipAll); + QString fileName("ownertest.txt"); + if (QFile::exists(fileName)) + QFile::remove(fileName); + QFile testFile(fileName); + QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text)); + QByteArray testData("testfile"); + QVERIFY(testFile.write(testData) != -1); + testFile.close(); + QFileInfo fi(fileName); + QVERIFY(fi.exists()); + QCOMPARE(userName, fi.owner()); + if (QFile::exists(fileName)) + QFile::remove(fileName); +#if defined(Q_OS_WIN) + qt_ntfs_permission_lookup = 0; +#endif +} +#endif + QTEST_MAIN(tst_QFileInfo) #include "tst_qfileinfo.moc" -- cgit v0.12 From 484770255f421d71954df4511e3541d2d4654d4e Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 22 Oct 2010 16:00:24 +0100 Subject: Re-enable emulated QFile::map on symbian Memory mapping of RFile handles is not supported in current symbian OS versions. However the "open C" libraries provide an emulated mmap() implementation which was used by QFile::map in Qt 4.6 release. To avoid breaking applications which rely on this function, QFile::map will now open the file with open C as well in order to use that handle to call mmap(). When symbian implements a file mapping API, we can switch the implementation to use that for RFile handles. Reviewed-By: joao --- src/corelib/io/qfile.cpp | 2 ++ src/corelib/io/qfsfileengine.cpp | 12 +++++++++ src/corelib/io/qfsfileengine_p.h | 2 ++ src/corelib/io/qfsfileengine_unix.cpp | 47 ++++++++++++++++------------------- tests/auto/qfile/tst_qfile.cpp | 12 --------- 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index a0bc68e..f0ca11b 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -48,6 +48,7 @@ #include "qfileinfo.h" #include "private/qiodevice_p.h" #include "private/qfile_p.h" +#include "private/qsystemerror_p.h" #if defined(QT_BUILD_CORE_LIB) # include "qcoreapplication.h" #endif @@ -1223,6 +1224,7 @@ bool QFile::unmap(uchar *address) d->setError(d->fileEngine->error(), d->fileEngine->errorString()); return success; } + d->setError(PermissionsError, QSystemError(EACCES, QSystemError::StandardLibraryError).toString()); return false; } diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 5491caf..ae301f7 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -120,6 +120,9 @@ void QFSFileEnginePrivate::init() openMode = QIODevice::NotOpen; fd = -1; fh = 0; +#ifdef Q_OS_SYMBIAN + fileHandleForMaps = -1; +#endif lastIOCommand = IOFlushCommand; lastFlushFailed = false; closeFileHandle = false; @@ -355,6 +358,7 @@ bool QFSFileEnginePrivate::closeFdFh() if (fd == -1 && !fh #ifdef Q_OS_SYMBIAN && !symbianFile.SubSessionHandle() + && fileHandleForMaps == -1 #endif ) return false; @@ -364,6 +368,14 @@ bool QFSFileEnginePrivate::closeFdFh() bool closed = true; tried_stat = 0; +#ifdef Q_OS_SYMBIAN + // Map handle is always owned by us so always close it + if (fileHandleForMaps >= 0) { + QT_CLOSE(fileHandleForMaps); + fileHandleForMaps = -1; + } +#endif + // Close the file if we created the handle. if (closeFileHandle) { int ret; diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index 715b46f..7c088b8 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -139,6 +139,8 @@ public: */ TInt symbianFilePos; #endif + mutable int fileHandleForMaps; + int getMapHandle(); #endif #ifdef Q_WS_WIN diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 28e0677..035e78f 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -85,6 +85,7 @@ static bool isRelativePathSymbian(const QString& fileName) #endif +#ifndef Q_OS_SYMBIAN /*! \internal @@ -124,6 +125,7 @@ static inline QByteArray openModeToFopenMode(QIODevice::OpenMode flags, const QF return mode; } +#endif /*! \internal @@ -153,6 +155,7 @@ static inline int openModeToOpenFlags(QIODevice::OpenMode mode) return oflags; } +#ifndef Q_OS_SYMBIAN /*! \internal @@ -163,6 +166,7 @@ static inline bool setCloseOnExec(int fd) { return fd != -1 && fcntl(fd, F_SETFD, FD_CLOEXEC) != -1; } +#endif #ifdef Q_OS_SYMBIAN /*! @@ -539,6 +543,22 @@ int QFSFileEnginePrivate::nativeHandle() const return fh ? fileno(fh) : fd; } +#ifdef Q_OS_SYMBIAN +int QFSFileEnginePrivate::getMapHandle() +{ + if (symbianFile.SubSessionHandle()) { + // Symbian file handle can't be used for open C mmap() so open the file with open C as well. + if (fileHandleForMaps < 0) { + int flags = openModeToOpenFlags(openMode); + flags &= ~(O_CREAT | O_TRUNC); + fileHandleForMaps = ::wopen((wchar_t*)(fileEntry.nativeFilePath().utf16()), flags, 0666); + } + return fileHandleForMaps; + } + return nativeHandle(); +} +#endif + /*! \internal */ @@ -921,30 +941,6 @@ QDateTime QFSFileEngine::fileTime(FileTime time) const return QDateTime(); } -#ifdef Q_OS_SYMBIAN -uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) -{ - //Q_Q(QFSFileEngine); - Q_UNUSED(flags) - Q_UNUSED(offset) - Q_UNUSED(size) - return 0; - //TODO: use RFileMap when available in symbian^4 -} - -bool QFSFileEnginePrivate::unmap(uchar *ptr) -{ - //TODO: RFileMap as the value in maps, unmap it here when API is available... - //Q_Q(QFSFileEngine); - //if (!maps.contains(ptr)) { - // q->setError(QFile::PermissionsError, qt_error_string(EACCES)); - // return false; - //} - Q_UNUSED(ptr) - - return false; -} -#else uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags) { Q_Q(QFSFileEngine); @@ -985,7 +981,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla #ifdef Q_OS_SYMBIAN void *mapAddress; TRAPD(err, mapAddress = QT_MMAP((void*)0, realSize, - access, MAP_SHARED, nativeHandle(), realOffset)); + access, MAP_SHARED, getMapHandle(), realOffset)); if (err != KErrNone) { qWarning("OpenC bug: leave from mmap %d", err); mapAddress = MAP_FAILED; @@ -1035,7 +1031,6 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr) maps.remove(ptr); return true; } -#endif QT_END_NAMESPACE diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 4e7cb9f..088c1f2 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -2800,10 +2800,6 @@ void tst_QFile::map() QFETCH(int, size); QFETCH(QFile::FileError, error); -#ifdef Q_OS_SYMBIAN - QSKIP("memory mapped files not supported on this platform", SkipAll); -#endif - QString fileName = QDir::currentPath() + '/' + "qfile_map_testfile"; #ifdef Q_WS_WINCE @@ -2925,10 +2921,6 @@ void tst_QFile::mapResource() QFETCH(int, size); QFETCH(QFile::FileError, error); -#ifdef Q_OS_SYMBIAN - QSKIP("memory mapped files not supported on this platform", SkipAll); -#endif - QFile file(fileName); uchar *memory = file.map(offset, size); QCOMPARE(file.error(), error); @@ -2954,10 +2946,6 @@ void tst_QFile::mapOpenMode() QFETCH(int, openMode); static const qint64 fileSize = 4096; -#ifdef Q_OS_SYMBIAN - QSKIP("memory mapped files not supported on this platform", SkipAll); -#endif - QByteArray pattern(fileSize, 'A'); QString fileName = QDir::currentPath() + '/' + "qfile_map_testfile"; -- cgit v0.12 From b251f7f9d2d1fb336e0b4f92858aad2eab0ba88c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 16 Nov 2010 15:17:49 +0100 Subject: QFileSystemEngine::resolveUserName and not group Reviewed-by: Shane Kearns --- src/corelib/io/qfilesystemengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 8613dd7..fe0bad7 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -359,7 +359,7 @@ QString QFileSystemEngine::resolveUserName(const QFileSystemEntry &entry, QFileS #else //(Q_OS_UNIX) if (!metaData.hasFlags(QFileSystemMetaData::UserId)) QFileSystemEngine::fillMetaData(entry, metaData, QFileSystemMetaData::UserId); - return resolveGroupName(metaData.userId()); + return resolveUserName(metaData.userId()); #endif } -- cgit v0.12 From eb474123412c52e74f402e082c85286047c9aeda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 16 Nov 2010 15:28:17 +0100 Subject: QFile: Fix compilation EACCES was not defined at this point, but it is also not needed, since we know exactly why unmap is failing. Reviewed-by: Shane Kearns --- src/corelib/io/qfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index f0ca11b..fac4ac6 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -1224,7 +1224,7 @@ bool QFile::unmap(uchar *address) d->setError(d->fileEngine->error(), d->fileEngine->errorString()); return success; } - d->setError(PermissionsError, QSystemError(EACCES, QSystemError::StandardLibraryError).toString()); + d->setError(PermissionsError, tr("No file engine available or engine does not support UnMapExtension")); return false; } -- cgit v0.12 From 02aca4e5a1d3e3e47a2c69a63faa772439ac92cf Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 16 Nov 2010 11:53:14 +0000 Subject: Fix tst_qfileinfo crash on windows with UAC enabled Creating symbolic links requires admin privilege by default - when UAC is enabled then even users in the administrators group do not have admin privileges without an escalation prompt. (which is inappropriate for an autotest). When run with insufficient privileges, the test is skipped with a warning Reviewed-By: Prasanth Ullattil --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 898bf54..07e33d3 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1353,8 +1353,24 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() file.open(QIODevice::ReadWrite); file.close(); - QVERIFY(pwd.exists("abs_symlink") || createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x1)); - QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x1)); + DWORD err = ERROR_SUCCESS ; + if (!pwd.exists("abs_symlink")) + if (!createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x1)) + err = GetLastError(); + if (err == ERROR_SUCCESS && !pwd.exists(relSymlink)) + if (!createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x1)) + err = GetLastError(); + if (err != ERROR_SUCCESS) { + wchar_t errstr[0x100]; + DWORD count = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, + 0, err, 0, errstr, 0x100, 0); + QString error(QString::fromUtf16(errstr, count)); + qWarning() << error; + //we need at least one data set for the test not to assert fail when skipping _data function + QDir target("target"); + QTest::newRow("dummy") << target.path() << false << "" << target.canonicalPath(); + QSKIP("link not supported by FS or insufficient privilege", SkipSingle); + } QVERIFY(file.exists()); QTest::newRow("absolute dir symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); -- cgit v0.12 From 5a9b670ef04232c7cd5017bd5e241c6ed975be6e Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 16 Nov 2010 13:43:14 +0000 Subject: Test coverage - ensure tst_qfileinfo tests dir & absoluteDir functions The existing dir test function is appropriate, now it checks the dir functions as well as the path functions. Reviewed-By: Prasanth Ullattil --- tests/auto/qfileinfo/qfileinfo.pro | 1 + tests/auto/qfileinfo/tst_qfileinfo.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfileinfo/qfileinfo.pro b/tests/auto/qfileinfo/qfileinfo.pro index 101128c..fdbcd26 100644 --- a/tests/auto/qfileinfo/qfileinfo.pro +++ b/tests/auto/qfileinfo/qfileinfo.pro @@ -30,3 +30,4 @@ wince* { DEFINES += SRCDIR=\\\"$$PWD/\\\" } +contains(QT_CONFIG, qt3support): QT += qt3support diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 07e33d3..d021df5 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -705,10 +705,19 @@ void tst_QFileInfo::dir() QFETCH(QString, expected); QFileInfo fi(file); - if (absPath) + if (absPath) { QCOMPARE(fi.absolutePath(), expected); - else + QCOMPARE(fi.absoluteDir().path(), expected); +#ifdef QT3_SUPPORT + QCOMPARE(fi.dir(true).path(), expected); +#endif + } else { QCOMPARE(fi.path(), expected); + QCOMPARE(fi.dir().path(), expected); +#ifdef QT3_SUPPORT + QCOMPARE(fi.dir(false).path(), expected); +#endif + } } -- cgit v0.12 From eab60b677c6e61c2d31f7aec02f05eb9c12862c9 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 16 Nov 2010 16:20:44 +0000 Subject: test coverage: test QFileInfo::group() Reviewed-By: joao --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index d021df5..3e67fb8 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -189,6 +189,7 @@ private slots: #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) void owner(); #endif + void group(); }; tst_QFileInfo::tst_QFileInfo() @@ -1690,5 +1691,29 @@ void tst_QFileInfo::owner() } #endif +void tst_QFileInfo::group() +{ + QString expected; +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + struct group *gr; + gid_t gid = getegid(); + gr = getgrgid(gid); + expected = QString::fromLocal8Bit(gr->gr_name); +#endif + + QString fileName("ownertest.txt"); + if (QFile::exists(fileName)) + QFile::remove(fileName); + QFile testFile(fileName); + QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Text)); + QByteArray testData("testfile"); + QVERIFY(testFile.write(testData) != -1); + testFile.close(); + QFileInfo fi(fileName); + QVERIFY(fi.exists()); + + QCOMPARE(fi.group(), expected); +} + QTEST_MAIN(tst_QFileInfo) #include "tst_qfileinfo.moc" -- cgit v0.12 From c7e569802ac4d547482d529e910232a80347fc67 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 16 Nov 2010 16:50:38 +0000 Subject: test coverage: test QDir::addSearchPath Reviewed-By: joao --- tests/auto/qdir/tst_qdir.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 9521921..4f6c784 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -1434,6 +1434,29 @@ void tst_QDir::searchPaths() for (int i = 0; i < searchPathPrefixList.count(); ++i) { QVERIFY(QDir::searchPaths(searchPathPrefixList.at(i)).isEmpty()); } + + for (int i = 0; i < searchPathPrefixList.count(); ++i) { + foreach (QString path, searchPathsList.at(i).split(",")) { + QDir::addSearchPath(searchPathPrefixList.at(i), path); + } + } + for (int i = 0; i < searchPathPrefixList.count(); ++i) { + QVERIFY(QDir::searchPaths(searchPathPrefixList.at(i)) == searchPathsList.at(i).split(",")); + } + + QCOMPARE(QFile(filename).exists(), exists); + QCOMPARE(QFileInfo(filename).exists(), exists); + + if (exists) { + QCOMPARE(QFileInfo(filename).absoluteFilePath(), expectedAbsolutePath); + } + + for (int i = 0; i < searchPathPrefixList.count(); ++i) { + QDir::setSearchPaths(searchPathPrefixList.at(i), QStringList()); + } + for (int i = 0; i < searchPathPrefixList.count(); ++i) { + QVERIFY(QDir::searchPaths(searchPathPrefixList.at(i)).isEmpty()); + } } void tst_QDir::entryListWithSearchPaths() -- cgit v0.12 From bc6d6b99981f5abf4d8f4059f86f0441156b6700 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 16 Nov 2010 16:56:20 +0000 Subject: test coverage: add test for QDir::match static functions Reviewed-By: joao --- tests/auto/qdir/tst_qdir.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 4f6c784..62f45e8 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -183,6 +183,11 @@ private slots: void isRoot_data(); void isRoot(); #endif + +#ifndef QT_NO_REGEXP + void match_data(); + void match(); +#endif }; // Testing get/set functions @@ -1738,6 +1743,31 @@ void tst_QDir::isRoot() } #endif +#ifndef QT_NO_REGEXP +void tst_QDir::match_data() +{ + QTest::addColumn("filter"); + QTest::addColumn("filename"); + QTest::addColumn("match"); + + QTest::newRow("single, matching") << "*.cpp" << "tst_qdir.cpp" << true; + QTest::newRow("single, not matching") << "*.cpp" << "tst_qdir.h" << false; + QTest::newRow("multi, matching") << "*.cpp;*.h" << "tst_qdir.cpp" << true; + QTest::newRow("multi, matching2") << "*.cpp;*.h" << "tst_qdir.h" << true; + QTest::newRow("multi, not matching") << "*.cpp;*.h" << "readme.txt" << false; +} + +void tst_QDir::match() +{ + QFETCH(QString, filter); + QFETCH(QString, filename); + QFETCH(bool, match); + + QCOMPARE(QDir::match(filter, filename), match); + QCOMPARE(QDir::match(filter.split(QLatin1Char(';')), filename), match); +} +#endif + QTEST_MAIN(tst_QDir) #include "tst_qdir.moc" -- cgit v0.12 From 43aa80fe8c1064d88b104a8f8f1b97bbaeaf1cec Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 16 Nov 2010 18:21:05 +0000 Subject: Test coverage: test QFile::resize Reviewed-By: joao --- tests/auto/qfile/tst_qfile.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 088c1f2..53618e5 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -211,6 +211,9 @@ private slots: void openStandardStreams(); + void resize_data(); + void resize(); + // --- Task related tests below this line void task167217(); @@ -3085,5 +3088,28 @@ void tst_QFile::writeNothing() } } +void tst_QFile::resize_data() +{ + QTest::addColumn("filetype"); + + QTest::newRow("native") << int(OpenQFile); + QTest::newRow("fileno") << int(OpenFd); + QTest::newRow("stream") << int(OpenStream); +} + +void tst_QFile::resize() +{ + QFETCH(int, filetype); + QString filename(QLatin1String("file.txt")); + QFile file(filename); + QVERIFY(openFile(file, QIODevice::ReadWrite, FileType(filetype))); + QVERIFY(file.resize(8)); + QCOMPARE(file.size(), qint64(8)); + closeFile(file); + QFile::resize(filename, 4); + QCOMPARE(QFileInfo(filename).size(), qint64(4)); + QVERIFY(QFile::remove(filename)); +} + QTEST_MAIN(tst_QFile) #include "tst_qfile.moc" -- cgit v0.12 From f50098de5af1886f69214285345ef7ef4ebdc1fd Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 16 Nov 2010 18:21:56 +0000 Subject: Fix QFile::resize on windows for files opened from a FILE* Reviewed-By: joao --- src/corelib/io/qfsfileengine_win.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index cf83c07..97d1330 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -865,12 +865,16 @@ bool QFSFileEngine::setSize(qint64 size) { Q_D(QFSFileEngine); - if (d->fileHandle != INVALID_HANDLE_VALUE || d->fd != -1) { + if (d->fileHandle != INVALID_HANDLE_VALUE || d->fd != -1 || d->fh) { // resize open file HANDLE fh = d->fileHandle; #if !defined(Q_OS_WINCE) - if (fh == INVALID_HANDLE_VALUE) - fh = (HANDLE)_get_osfhandle(d->fd); + if (fh == INVALID_HANDLE_VALUE) { + if (d->fh) + fh = (HANDLE)_get_osfhandle(QT_FILENO(d->fh)); + else + fh = (HANDLE)_get_osfhandle(d->fd); + } #endif if (fh == INVALID_HANDLE_VALUE) return false; -- cgit v0.12 From 5ebad6878478c33f8a832929a2fb74e93bc29b62 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 17 Nov 2010 12:29:54 +0000 Subject: Test coverage: test more of QFile API Adding tests for these functions: symLinkTarget / readLink (static & non static) permissions (static) constructors which take a QObject parent After this, all function of QFile API are tested except encoding/decoding functions and some QT3_SUPPORT inlines in the header. Reviewed-by: joao --- tests/auto/qfile/tst_qfile.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 53618e5..f60ab1e 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -214,6 +214,8 @@ private slots: void resize_data(); void resize(); + void objectConstructors(); + // --- Task related tests below this line void task167217(); @@ -1112,6 +1114,7 @@ void tst_QFile::permissions() QFETCH(bool, expected); QFile f(file); QCOMPARE(((f.permissions() & perms) == QFile::Permissions(perms)), expected); + QCOMPARE(((QFile::permissions(file) & perms) == QFile::Permissions(perms)), expected); } void tst_QFile::setPermissions() @@ -1299,6 +1302,12 @@ void tst_QFile::link() QVERIFY(info2.isSymLink()); QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); + QFile link("myLink.lnk"); + QVERIFY(link.open(QIODevice::ReadOnly)); + QCOMPARE(link.symLinkTarget(), info1.absoluteFilePath()); + link.close(); + QCOMPARE(QFile::symLinkTarget("myLink.lnk"), info1.absoluteFilePath()); + #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath()); QCOMPARE(QDir::fromNativeSeparators(wd), info1.absolutePath()); @@ -3111,5 +3120,14 @@ void tst_QFile::resize() QVERIFY(QFile::remove(filename)); } +void tst_QFile::objectConstructors() +{ + QObject ob; + QFile* file1 = new QFile(SRCDIR "testfile.txt", &ob); + QFile* file2 = new QFile(&ob); + QVERIFY(file1->exists()); + QVERIFY(!file2->exists()); +} + QTEST_MAIN(tst_QFile) #include "tst_qfile.moc" -- cgit v0.12 From 51a28e0ffaaff9f97117256fc6d0e11df392d706 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 17 Nov 2010 12:34:26 +0000 Subject: Windows: fix QFile::symLinkTarget Missing return statement Reviewed-by: joao --- src/corelib/io/qfsfileengine_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 97d1330..f3e2c4c 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -825,7 +825,7 @@ QString QFSFileEngine::fileName(FileName file) const return entry.path(); return entry.filePath(); } else if (file == LinkName) { - QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData).filePath(); + return QFileSystemEngine::getLinkTarget(d->fileEntry, d->metaData).filePath(); } else if (file == BundleName) { return QString(); } -- cgit v0.12 From 43adb2ed628f79d3c59f4bf0b4cec03efc9c3ab6 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 17 Nov 2010 16:28:21 +0000 Subject: Test Coverage: add tests to cover QDir API Functional coverage of QDir, except for trivial shims for deprecated APIs and the QDebug streaming functions. Reviewed-by: joao --- tests/auto/qdir/qdir.pro | 1 + tests/auto/qdir/tst_qdir.cpp | 210 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 207 insertions(+), 4 deletions(-) diff --git a/tests/auto/qdir/qdir.pro b/tests/auto/qdir/qdir.pro index cf612f1..01a88cd 100644 --- a/tests/auto/qdir/qdir.pro +++ b/tests/auto/qdir/qdir.pro @@ -15,6 +15,7 @@ wince* { TARGET.CAPABILITY += AllFiles TARGET.UID3 = 0xE0340002 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) + LIBS += -lefsrv } else { contains(QT_CONFIG, qt3support):QT += qt3support DEFINES += SRCDIR=\\\"$$PWD/\\\" diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 62f45e8..7f98a9a 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -57,11 +57,13 @@ #include "../../shared/filesystem.h" #if defined(Q_OS_SYMBIAN) +# include # define STRINGIFY(x) #x # define TOSTRING(x) STRINGIFY(x) # define SRCDIR "C:/Private/" TOSTRING(SYMBIAN_SRCDIR_UID) "/" #elif defined(Q_OS_UNIX) # include +# include #endif #if defined(Q_OS_VXWORKS) @@ -188,6 +190,22 @@ private slots: void match_data(); void match(); #endif + + void drives(); + + void arrayOperator(); + +#ifdef QT3_SUPPORT + void setNameFilter(); +#endif + + void equalityOperator_data(); + void equalityOperator(); + + void isRelative_data(); + void isRelative(); + + void isReadable(); }; // Testing get/set functions @@ -1190,6 +1208,8 @@ void tst_QDir::remove() QDir dir; QVERIFY(dir.remove("remove-test")); QVERIFY(!dir.remove("/remove-test")); + QTest::ignoreMessage(QtWarningMsg, "QDir::remove: Empty or null file name"); + QVERIFY(!dir.remove("")); } void tst_QDir::rename() @@ -1202,10 +1222,18 @@ void tst_QDir::rename() QVERIFY(dir.rename("rename-test-renamed", "rename-test")); #if defined(Q_OS_MAC) QVERIFY(!dir.rename("rename-test", "/etc/rename-test-renamed")); -#elif !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) - // on windows/symbian this is possible - maybe make the test a bit better +#elif defined(Q_OS_SYMBIAN) + QVERIFY(!dir.rename("rename-test", "/resource/rename-test-renamed")); +#elif !defined(Q_OS_WIN) + // on windows this is possible - maybe make the test a bit better QVERIFY(!dir.rename("rename-test", "/rename-test-renamed")); #endif + QTest::ignoreMessage(QtWarningMsg, "QDir::rename: Empty or null file name(s)"); + QVERIFY(!dir.rename("rename-test", "")); + QTest::ignoreMessage(QtWarningMsg, "QDir::rename: Empty or null file name(s)"); + QVERIFY(!dir.rename("", "rename-test-renamed")); + QVERIFY(!dir.rename("some-file-that-does-not-exist", "rename-test-renamed")); + QVERIFY(dir.remove("rename-test")); } @@ -1717,7 +1745,6 @@ void tst_QDir::testCaching() QVERIFY(dir.exists()); // QDir doesn't cache the 'exist' between calls. } -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void tst_QDir::isRoot_data() { QTest::addColumn("path"); @@ -1729,8 +1756,13 @@ void tst_QDir::isRoot_data() QTest::newRow(QString("./ appended " + test).toLatin1()) << test << false; test = QDir(QDir::rootPath().append("./")).canonicalPath(); QTest::newRow(QString("canonicalPath " + test).toLatin1()) << test << true; +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) test = QDir::rootPath().left(2); QTest::newRow(QString("drive relative " + test).toLatin1()) << test << false; +#endif + + QTest::newRow("resources root") << ":/" << true; + QTest::newRow("resources nonroot") << ":/entrylist" << false; } void tst_QDir::isRoot() @@ -1741,7 +1773,6 @@ void tst_QDir::isRoot() QDir dir(path); QCOMPARE(dir.isRoot(),isRoot); } -#endif #ifndef QT_NO_REGEXP void tst_QDir::match_data() @@ -1768,6 +1799,177 @@ void tst_QDir::match() } #endif +void tst_QDir::drives() +{ + QFileInfoList list(QDir::drives()); +#if defined(Q_OS_WIN) + QVERIFY(list.count() >= 1); //system + QLatin1Char systemdrive('c'); +#elif defined(Q_OS_SYMBIAN) + QVERIFY(list.count() >= 2); //system, rom + QLatin1Char romdrive('z'); + QLatin1Char systemdrive('a' + int(RFs::SystemDrive())); +#endif +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + QVERIFY(list.count() <= 26); + bool foundsystem = false; +#ifdef Q_OS_SYMBIAN + bool foundrom = false; +#endif + foreach (QFileInfo fi, list) { + QCOMPARE(fi.absolutePath().size(), 3); //"x:/" + QCOMPARE(fi.absolutePath().at(1), QChar(QLatin1Char(':'))); + QCOMPARE(fi.absolutePath().at(2), QChar(QLatin1Char('/'))); + if (fi.absolutePath().at(0).toLower() == systemdrive) + foundsystem = true; +#ifdef Q_OS_SYMBIAN + if (fi.absolutePath().at(0).toLower() == romdrive) + foundrom = true; +#endif + } + QCOMPARE(foundsystem, true); +#ifdef Q_OS_SYMBIAN + QCOMPARE(foundrom, true); +#endif +#else + QCOMPARE(list.count(), 1); //root + QCOMPARE(list.at(0).absolutePath(), "/"); +#endif +} + +void tst_QDir::arrayOperator() +{ + QDir dir1(SRCDIR "entrylist/"); + QDir dir2(SRCDIR "entrylist/"); + + QStringList entries(dir1.entryList()); + int i = dir2.count(); + QCOMPARE(i, entries.count()); + --i; + for (;i>=0;--i) { + QCOMPARE(dir2[i], entries.at(i)); + } +} + +#ifdef QT3_SUPPORT +void tst_QDir::setNameFilter() +{ + QStringList filters; + filters << "*.jpg" << "*.png" << "*.gif"; + QStringList filters2; + filters2 << "*.cpp" << "*.h" << "*.c"; + + QDir dir(SRCDIR "entrylist/"); + + dir.setNameFilter(filters.join(";")); + QCOMPARE(filters, dir.nameFilters()); + QCOMPARE(filters, dir.nameFilter().split(';')); + + dir.setNameFilters(filters2); + QCOMPARE(filters2, dir.nameFilter().split(';')); + + dir.setNameFilter(filters.join(" ")); + QCOMPARE(filters, dir.nameFilters()); + QCOMPARE(filters, dir.nameFilter().split(' ')); + + dir.setNameFilters(filters2); + QCOMPARE(filters2, dir.nameFilter().split(' ')); +} +#endif + +void tst_QDir::equalityOperator_data() +{ + QTest::addColumn("leftPath"); + QTest::addColumn("leftNameFilters"); + QTest::addColumn("leftSort"); + QTest::addColumn("leftFilters"); + QTest::addColumn("rightPath"); + QTest::addColumn("rightNameFilters"); + QTest::addColumn("rightSort"); + QTest::addColumn("rightFilters"); + QTest::addColumn("expected"); + + QTest::newRow("same") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << true; + + QTest::newRow("relativepaths") << "entrylist/" << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << "./entrylist" << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << true; + + QTest::newRow("diff-filters") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Dirs) + << false; + + QTest::newRow("diff-sort") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << SRCDIR << "*.cpp" << int(QDir::Time) << int(QDir::Files) + << false; + + QTest::newRow("diff-namefilters") << SRCDIR << "*.cpp" << int(QDir::Name) << int(QDir::Files) + << SRCDIR << "*.jpg" << int(QDir::Name) << int(QDir::Files) + << false; +} + +void tst_QDir::equalityOperator() +{ + QFETCH(QString, leftPath); + QFETCH(QString, leftNameFilters); + QFETCH(int, leftSort); + QFETCH(int, leftFilters); + QFETCH(QString, rightPath); + QFETCH(QString, rightNameFilters); + QFETCH(int, rightSort); + QFETCH(int, rightFilters); + QFETCH(bool, expected); + + QDir dir1(leftPath, leftNameFilters, QDir::SortFlags(leftSort), QDir::Filters(leftFilters)); + QDir dir2(rightPath, rightNameFilters, QDir::SortFlags(rightSort), QDir::Filters(rightFilters)); + + QCOMPARE((dir1 == dir2), expected); + QCOMPARE((dir2 == dir1), expected); + QCOMPARE((dir1 != dir2), !expected); + QCOMPARE((dir2 != dir1), !expected); +} + +void tst_QDir::isRelative_data() +{ + QTest::addColumn("path"); + QTest::addColumn("relative"); + + QTest::newRow(".") << "./" << true; + QTest::newRow("..") << "../" << true; + QTest::newRow("content") << "entrylist/" << true; + QTest::newRow("current") << QDir::currentPath() << false; + QTest::newRow("homepath") << QDir::homePath() << false; + QTest::newRow("temppath") << QDir::tempPath() << false; + QTest::newRow("rootpath") << QDir::rootPath() << false; + foreach (QFileInfo root, QDir::drives()) { + QTest::newRow(root.absolutePath()) << root.absolutePath() << false; + } +} + +void tst_QDir::isRelative() +{ + QFETCH(QString, path); + QFETCH(bool, relative); + + QCOMPARE(QDir(path).isRelative(), relative); +} + +void tst_QDir::isReadable() +{ + QDir dir; + + QVERIFY(dir.isReadable()); +#if defined (Q_OS_UNIX) && !defined (Q_OS_SYMBIAN) + QVERIFY(dir.mkdir("nonreadabledir")); + QVERIFY(0 == ::chmod("nonreadabledir", 0)); + QVERIFY(!QDir("nonreadabledir").isReadable()); + QVERIFY(0 == ::chmod("nonreadabledir", S_IRUSR | S_IWUSR | S_IXUSR)); + QVERIFY(dir.rmdir("nonreadabledir")); +#endif +} + QTEST_MAIN(tst_QDir) #include "tst_qdir.moc" -- cgit v0.12 From a5de017fe85ce8058c32df1f61df0c9c59ccf01c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 17 Nov 2010 18:21:45 +0100 Subject: Fix test compile error on linux Reviewed-By: Trust Me --- tests/auto/qdir/tst_qdir.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 7f98a9a..e8c8e07 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -181,10 +181,8 @@ private slots: void testCaching(); -#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void isRoot_data(); void isRoot(); -#endif #ifndef QT_NO_REGEXP void match_data(); @@ -1833,7 +1831,7 @@ void tst_QDir::drives() #endif #else QCOMPARE(list.count(), 1); //root - QCOMPARE(list.at(0).absolutePath(), "/"); + QCOMPARE(list.at(0).absolutePath(), QLatin1String("/")); #endif } -- cgit v0.12 From c75d76bc8c08805d2f1b0003ff17c25a28955b52 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 17 Nov 2010 18:04:32 +0000 Subject: Fix test compile issues on symbian Reviewed-by: Trust Me --- tests/auto/qdir/tst_qdir.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index e8c8e07..6a81da6 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -1305,12 +1305,13 @@ void tst_QDir::dotAndDotDot() { #if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) QSKIP("WinCE and Symbian do not have . nor ..", SkipAll); -#endif +#else QDir dir(QString(SRCDIR "testdir/")); QStringList entryList = dir.entryList(QDir::Dirs); QCOMPARE(entryList, QStringList() << QString(".") << QString("..") << QString("dir") << QString("spaces")); entryList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); QCOMPARE(entryList, QStringList() << QString("dir") << QString("spaces")); +#endif } #ifdef QT3_SUPPORT @@ -1806,7 +1807,7 @@ void tst_QDir::drives() #elif defined(Q_OS_SYMBIAN) QVERIFY(list.count() >= 2); //system, rom QLatin1Char romdrive('z'); - QLatin1Char systemdrive('a' + int(RFs::SystemDrive())); + QLatin1Char systemdrive('a' + int(RFs::GetSystemDrive())); #endif #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) QVERIFY(list.count() <= 26); @@ -1942,7 +1943,7 @@ void tst_QDir::isRelative_data() QTest::newRow("temppath") << QDir::tempPath() << false; QTest::newRow("rootpath") << QDir::rootPath() << false; foreach (QFileInfo root, QDir::drives()) { - QTest::newRow(root.absolutePath()) << root.absolutePath() << false; + QTest::newRow(root.absolutePath().toLocal8Bit()) << root.absolutePath() << false; } } -- cgit v0.12 From c5a5696ca5273fb0a8474b525d1df4a52463afbd Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 18 Nov 2010 11:55:55 +0000 Subject: Update QDirModel autotest (symbian) Skip test requiring symbolic link as they aren't supported Move a Q_EXPECT_FAIL to immediately before the test function that fails (so the test result is XFAIL instead of FAIL) Reviewed-by: joao --- tests/auto/qdirmodel/tst_qdirmodel.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp index 41bbd87..e252b82 100644 --- a/tests/auto/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp @@ -583,19 +583,15 @@ void tst_QDirModel::unreadable() void tst_QDirModel::filePath() { +#ifdef Q_OS_SYMBIAN + QSKIP("OS doesn't support symbolic links", SkipAll); +#else QFile::remove(SRCDIR "test.lnk"); QVERIFY(QFile(SRCDIR "tst_qdirmodel.cpp").link(SRCDIR "test.lnk")); QDirModel model; model.setResolveSymlinks(false); QModelIndex index = model.index(SRCDIR "test.lnk"); QVERIFY(index.isValid()); -#if defined(Q_OS_SYMBIAN) - // Since model will force lowercase path in Symbian, make case insensitive compare - // Note: Windows should fail this, too, if test path has any uppercase letters. - QCOMPARE(model.filePath(index).toLower(), QString(SRCDIR).toLower() + "test.lnk"); - model.setResolveSymlinks(true); - QCOMPARE(model.filePath(index).toLower(), QString(SRCDIR).toLower() + "tst_qdirmodel.cpp"); -#else #ifndef Q_OS_WINCE QString path = SRCDIR; #else @@ -604,8 +600,8 @@ void tst_QDirModel::filePath() QCOMPARE(model.filePath(index), path + QString( "test.lnk")); model.setResolveSymlinks(true); QCOMPARE(model.filePath(index), path + QString( "tst_qdirmodel.cpp")); -#endif QFile::remove(SRCDIR "test.lnk"); +#endif } void tst_QDirModel::task196768_sorting() @@ -613,11 +609,6 @@ void tst_QDirModel::task196768_sorting() //this task showed that the persistent model indexes got corrupted when sorting QString path = SRCDIR; -#ifdef Q_OS_SYMBIAN - if(!RProcess().HasCapability(ECapabilityAllFiles)) - QEXPECT_FAIL("", "QTBUG-9746", Continue); -#endif - QDirModel model; /* QDirModel has a bug if we show the content of the subdirectory inside a hidden directory @@ -637,6 +628,11 @@ void tst_QDirModel::task196768_sorting() QCOMPARE(index.data(), index2.data()); view.setSortingEnabled(true); index2 = model.index(path); + +#ifdef Q_OS_SYMBIAN + if(!RProcess().HasCapability(ECapabilityAllFiles)) + QEXPECT_FAIL("", "QTBUG-9746", Continue); +#endif QCOMPARE(index.data(), index2.data()); } -- cgit v0.12 From 96acd93d741cd735f8c4bdaf6fdcf073192b1562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 17 Nov 2010 18:20:26 +0100 Subject: QFileSystemEngine: clean up unused code resolveUser/GroupName(id) only make sense on Unix platforms, there's no point in replicating them elsewhere. bundleName is a Mac-only feature, so we can otherwise merge the default implementation for other platforms. Reviewed-by: Shane Kearns --- src/corelib/io/qfilesystemengine_p.h | 9 ++++++++- src/corelib/io/qfilesystemengine_symbian.cpp | 21 --------------------- src/corelib/io/qfilesystemengine_unix.cpp | 6 ++---- src/corelib/io/qfilesystemengine_win.cpp | 19 ------------------- 4 files changed, 10 insertions(+), 45 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 1f4aad0..63d2a91 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -69,11 +69,18 @@ public: static QFileSystemEntry canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data); static QFileSystemEntry absoluteName(const QFileSystemEntry &entry); static QString resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &data); - static QString resolveUserName(uint userId); static QString resolveGroupName(const QFileSystemEntry &entry, QFileSystemMetaData &data); + +#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) + static QString resolveUserName(uint userId); static QString resolveGroupName(uint groupId); +#endif +#if !defined(QWS) && defined(Q_OS_MAC) static QString bundleName(const QFileSystemEntry &entry); +#else + static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); } +#endif static bool fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what); diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index c4e8d36..3659a39 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -151,27 +151,6 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) return QFileSystemEntry(symbianCleanAbsolutePath(result), QFileSystemEntry::FromInternalPath()); } -//static -QString QFileSystemEngine::resolveUserName(uint userId) -{ - Q_UNUSED(userId) - return QString(); // no users or groups on symbian -} - -//static -QString QFileSystemEngine::resolveGroupName(uint groupId) -{ - Q_UNUSED(groupId) - return QString(); // no users or groups on symbian -} - -//static -QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) -{ - Q_UNUSED(entry); - return QString(); -} - void QFileSystemMetaData::fillFromTEntry(const TEntry& entry) { entryFlags &= ~(QFileSystemMetaData::SymbianTEntryFlags); diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index dc6888d..329da08 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -333,10 +333,10 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) return QString(); } +#if !defined(QWS) && defined(Q_OS_MAC) //static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { -#if !defined(QWS) && defined(Q_OS_MAC) QCFType url = CFURLCreateWithFileSystemPath(0, QCFString(entry.filePath()), kCFURLPOSIXPathStyle, true); if (QCFType dict = CFBundleCopyInfoDictionaryForURL(url)) { @@ -345,11 +345,9 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) return QCFString::toQString((CFStringRef)name); } } -#else - Q_UNUSED(entry); -#endif return QString(); } +#endif //static bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 8fa4d62..b2afe90 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -529,25 +529,6 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) } //static -QString QFileSystemEngine::resolveUserName(uint userId) -{ - return QString(); // TODO -} - -//static -QString QFileSystemEngine::resolveGroupName(uint groupId) -{ - return QString(); // TODO -} - -//static -QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) -{ - Q_UNUSED(entry); - return QString(); -} - -//static QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own) { QString name; -- cgit v0.12 From ee1f78b08521955342b2ce0f1244c7406bfd3124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 17 Nov 2010 18:28:11 +0100 Subject: QFileSystemEngine: remove symbian code from Unix-specific implementation Symbian is not serviced by this code, anyway. So it's just dead code. Reviewed-by: Shane Kearns --- src/corelib/io/qfilesystemengine_unix.cpp | 51 ------------------------------- 1 file changed, 51 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 329da08..815ff42 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -52,12 +52,6 @@ #include #include -#if defined(Q_OS_SYMBIAN) -# include -# include -# include -# include -#endif #if defined(Q_OS_MAC) # include @@ -65,24 +59,6 @@ QT_BEGIN_NAMESPACE -#if defined(Q_OS_SYMBIAN) -static bool _q_isSymbianHidden(const QFileSystemEntry &entry, bool isDir) -{ - RFs rfs = qt_s60GetRFs(); - - QFileSystemEntry absoluteEntry = QFileSystemEngine::absoluteName(entry); - QString absolutePath = absoluteEntry.filePath(); - - if (isDir && !absolutePath.endsWith(QLatin1Char('/'))) - absolutePath.append(QLatin1Char('/')); - - TPtrC ptr(qt_QString2TPtrC(absolutePath)); - TUint attributes; - TInt err = rfs.Att(ptr, attributes); - return (err == KErrNone && (attributes & KEntryAttHidden)); -} -#endif - #if !defined(QWS) && defined(Q_OS_MAC) static inline bool _q_isMacHidden(const char *nativePath) { @@ -113,11 +89,7 @@ static inline bool _q_isMacHidden(const char *nativePath) bool QFileSystemEngine::isCaseSensitive() { -#if defined(Q_OS_SYMBIAN) - return false; -#else return true; -#endif } //static @@ -306,7 +278,6 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) QVarLengthArray buf(size_max); #endif -#if !defined(Q_OS_SYMBIAN) struct group *gr = 0; #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) size_max = sysconf(_SC_GETGR_R_SIZE_MAX); @@ -329,7 +300,6 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) #endif if (gr) return QFile::decodeName(QByteArray(gr->gr_name)); -#endif return QString(); } @@ -360,13 +330,6 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM } #endif -#if defined(Q_OS_SYMBIAN) - if (what & QFileSystemMetaData::HiddenAttribute) { - if (!data.hasFlags(QFileSystemMetaData::LinkType | QFileSystemMetaData::DirectoryType)) - what |= QFileSystemMetaData::LinkType | QFileSystemMetaData::DirectoryType; - } -#endif - #if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if (what & QFileSystemMetaData::HiddenAttribute) { // Mac OS >= 10.5: st_flags & UF_HIDDEN @@ -471,18 +434,10 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM if (what & QFileSystemMetaData::HiddenAttribute && !data.isHidden()) { -#if defined(Q_OS_SYMBIAN) - // In Symbian, all symlinks have hidden attribute for some reason; - // lets make them visible for better compatibility with other platforms. - // If somebody actually wants a hidden link, then they are out of luck. - if (entryExists && !data.isLink() && _q_isSymbianHidden(entry, data.isDirectory())) - data.entryFlags |= QFileSystemMetaData::HiddenAttribute; -#else QString fileName = entry.fileName(); if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.')) || (entryExists && _q_isMacHidden(nativeFilePath))) data.entryFlags |= QFileSystemMetaData::HiddenAttribute; -#endif data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; } @@ -513,9 +468,6 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea QString dirName = entry.filePath(); if (createParents) { dirName = QDir::cleanPath(dirName); -#if defined(Q_OS_SYMBIAN) - dirName = QDir::toNativeSeparators(dirName); -#endif for (int oldslash = -1, slash=0; slash != -1; oldslash = slash) { slash = dirName.indexOf(QDir::separator(), oldslash+1); if (slash == -1) { @@ -548,9 +500,6 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo { if (removeEmptyParents) { QString dirName = QDir::cleanPath(entry.filePath()); -#if defined(Q_OS_SYMBIAN) - dirName = QDir::toNativeSeparators(dirName); -#endif for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) { QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; -- cgit v0.12 From 901fee7e610ec53f744416aeeca89c4605923120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 22 Nov 2010 18:40:05 +0100 Subject: Fix QFile autotest for out-of-source builds --- tests/auto/qfile/tst_qfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index f60ab1e..dbd4302 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -1296,8 +1296,8 @@ void tst_QFile::link() QSKIP("Symbian does not support links", SkipAll); #endif QFile::remove("myLink.lnk"); - QFileInfo info1("tst_qfile.cpp"); - QVERIFY(QFile::link("tst_qfile.cpp", "myLink.lnk")); + QFileInfo info1(SRCDIR "tst_qfile.cpp"); + QVERIFY(QFile::link(SRCDIR "tst_qfile.cpp", "myLink.lnk")); QFileInfo info2("myLink.lnk"); QVERIFY(info2.isSymLink()); QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); -- cgit v0.12 From c8aa3d037ead9a7d1d62dc9ba454de8ff7eae9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 23 Nov 2010 12:32:30 +0100 Subject: Adding #ifdefs/#defines lost in the merge to master The file-engine-refactor moved a lot of code around. So simple merge conflict resolution didn't cut it to finish the merge. Lighthouse on OS X adds Q_WS_QPA, where we were already using QWS. Also introduced QT_NO_CORESERVICES. --- src/corelib/io/qfilesystemengine.cpp | 3 ++- src/corelib/io/qfilesystemengine_p.h | 2 +- src/corelib/io/qfilesystemengine_unix.cpp | 17 +++++++++-------- src/corelib/io/qfilesystemengine_win.cpp | 8 ++++++++ src/corelib/io/qfilesystemmetadata_p.h | 4 ++-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index fe0bad7..1e5914b 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -266,7 +266,8 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer) // Attributes entryFlags |= QFileSystemMetaData::ExistsAttribute; size_ = statBuffer.st_size; -#if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) \ + && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if (statBuffer.st_flags & UF_HIDDEN) { entryFlags |= QFileSystemMetaData::HiddenAttribute; knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; diff --git a/src/corelib/io/qfilesystemengine_p.h b/src/corelib/io/qfilesystemengine_p.h index 63d2a91..a3ec0ab 100644 --- a/src/corelib/io/qfilesystemengine_p.h +++ b/src/corelib/io/qfilesystemengine_p.h @@ -76,7 +76,7 @@ public: static QString resolveGroupName(uint groupId); #endif -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) static QString bundleName(const QFileSystemEntry &entry); #else static QString bundleName(const QFileSystemEntry &entry) { Q_UNUSED(entry) return QString(); } diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 815ff42..40fb0c0 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) static inline bool _q_isMacHidden(const char *nativePath) { OSErr err; @@ -148,7 +148,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link, ret.chop(1); return QFileSystemEntry(ret); } -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) { FSRef fref; if (FSPathMakeRef((const UInt8 *)QFile::encodeName(QDir::cleanPath(link.filePath())).data(), &fref, 0) == noErr) { @@ -178,7 +178,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, return QFileSystemEntry::slowCanonicalName(entry); #else char *ret = 0; -# if defined(Q_OS_MAC) +# if defined(Q_OS_MAC) && !defined(QT_NO_CORESERVICES) // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { ret = realpath(entry.nativeFilePath().constData(), (char*)0); @@ -303,7 +303,7 @@ QString QFileSystemEngine::resolveGroupName(uint groupId) return QString(); } -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) //static QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) { @@ -323,14 +323,15 @@ QString QFileSystemEngine::bundleName(const QFileSystemEntry &entry) bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemMetaData &data, QFileSystemMetaData::MetaDataFlags what) { -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) if (what & QFileSystemMetaData::BundleType) { if (!data.hasFlags(QFileSystemMetaData::DirectoryType)) what |= QFileSystemMetaData::DirectoryType; } #endif -#if !defined(QWS) && defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) \ + && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 if (what & QFileSystemMetaData::HiddenAttribute) { // Mac OS >= 10.5: st_flags & UF_HIDDEN what |= QFileSystemMetaData::PosixStatFlags; @@ -395,7 +396,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM | QFileSystemMetaData::ExistsAttribute; } -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) if (what & QFileSystemMetaData::AliasType) { if (entryExists) { @@ -441,7 +442,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM data.knownFlagsMask |= QFileSystemMetaData::HiddenAttribute; } -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) if (what & QFileSystemMetaData::BundleType) { if (entryExists && data.isDirectory()) { QCFType path = CFStringCreateWithBytes(0, diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index b2afe90..621b631 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -71,6 +71,14 @@ #define SECURITY_WIN32 #include +#ifndef SPI_GETPLATFORMTYPE +#define SPI_GETPLATFORMTYPE 257 +#endif + +#ifndef PATH_MAX +#define PATH_MAX FILENAME_MAX +#endif + #ifndef _INTPTR_T_DEFINED #ifdef _WIN64 typedef __int64 intptr_t; diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 24dfe6b..860b887 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -104,7 +104,7 @@ public: #endif FileType = 0x00020000, DirectoryType = 0x00040000, -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) BundleType = 0x00080000, AliasType = 0x08000000, #else @@ -264,7 +264,7 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QFileSystemMetaData::MetaDataFlags) -#if !defined(QWS) && defined(Q_OS_MAC) +#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) inline bool QFileSystemMetaData::isBundle() const { return (entryFlags & BundleType); } inline bool QFileSystemMetaData::isAlias() const { return (entryFlags & AliasType); } #else -- cgit v0.12 From 5ea5d929144ddf334bf8f47cccec35ee7dcbb10c Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 24 Nov 2010 11:14:23 +0100 Subject: Fix compile error on Windows Reviewed-by: Joao --- src/corelib/io/qfsfileengine_win.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index f3e2c4c..715fe39 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -69,6 +69,10 @@ #define SECURITY_WIN32 #include +#ifndef PATH_MAX +#define PATH_MAX FILENAME_MAX +#endif + QT_BEGIN_NAMESPACE -- cgit v0.12 From 535df2381d4f0e9cef9abab2c52db1ec93929e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 24 Nov 2010 15:03:33 +0100 Subject: Smoke test for QAbstractFileEngine This tests the default file support provided by Qt, together with QFSFileEngine, QResource engine and a reference custom file engine that works on top of a simple virtual in-memory file system. For now, the test is only focusing on QFile I/O functionality, it should be extended to cover QFileInfo, QDir, QDirIterator and file system operations in QFile. The intent for the reference file engine is not to be a fully functional file system, but to ensure that minimal support for custom file engines is working. Reviewed-by: Shane Kearns --- tests/auto/corelib.pro | 1 + .../qabstractfileengine/qabstractfileengine.pro | 6 + .../qabstractfileengine/qabstractfileengine.qrc | 5 + tests/auto/qabstractfileengine/resources/file.txt | 1 + .../tst_qabstractfileengine.cpp | 724 +++++++++++++++++++++ 5 files changed, 737 insertions(+) create mode 100644 tests/auto/qabstractfileengine/qabstractfileengine.pro create mode 100644 tests/auto/qabstractfileengine/qabstractfileengine.qrc create mode 100644 tests/auto/qabstractfileengine/resources/file.txt create mode 100644 tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp diff --git a/tests/auto/corelib.pro b/tests/auto/corelib.pro index 5ac0c81..3451b53 100644 --- a/tests/auto/corelib.pro +++ b/tests/auto/corelib.pro @@ -102,6 +102,7 @@ SUBDIRS=\ selftests \ utf8 \ qfilesystementry \ + qabstractfileengine symbian:SUBDIRS -= \ qtconcurrentfilter \ diff --git a/tests/auto/qabstractfileengine/qabstractfileengine.pro b/tests/auto/qabstractfileengine/qabstractfileengine.pro new file mode 100644 index 0000000..870473a --- /dev/null +++ b/tests/auto/qabstractfileengine/qabstractfileengine.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +QT = core + +SOURCES = tst_qabstractfileengine.cpp +RESOURCES += qabstractfileengine.qrc + diff --git a/tests/auto/qabstractfileengine/qabstractfileengine.qrc b/tests/auto/qabstractfileengine/qabstractfileengine.qrc new file mode 100644 index 0000000..5401b08 --- /dev/null +++ b/tests/auto/qabstractfileengine/qabstractfileengine.qrc @@ -0,0 +1,5 @@ + + + resources/ + + diff --git a/tests/auto/qabstractfileengine/resources/file.txt b/tests/auto/qabstractfileengine/resources/file.txt new file mode 100644 index 0000000..8a03e0e --- /dev/null +++ b/tests/auto/qabstractfileengine/resources/file.txt @@ -0,0 +1 @@ +This is a simple text file. diff --git a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp new file mode 100644 index 0000000..b2003a0 --- /dev/null +++ b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp @@ -0,0 +1,724 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + +class tst_QAbstractFileEngine + : public QObject +{ + Q_OBJECT +public slots: + void cleanupTestCase(); + +private slots: + void customHandler(); + + void fileIO_data(); + void fileIO(); + +private: + QStringList filesForRemoval; +}; + +class ReferenceFileEngine + : public QAbstractFileEngine +{ +public: + ReferenceFileEngine(const QString &fileName) + : fileName_(fileName) + , position_(-1) + , openForRead_(false) + , openForWrite_(false) + { + } + + bool open(QIODevice::OpenMode openMode) + { + Q_ASSERT(!openForRead_); + Q_ASSERT(!openForWrite_); + + openFile_ = resolveFile(openMode & QIODevice::WriteOnly); + if (!openFile_) + return false; + + position_ = 0; + if (openMode & QIODevice::ReadOnly) + openForRead_ = true; + + if (openMode & QIODevice::WriteOnly) { + openForWrite_ = true; + + QMutexLocker lock(&openFile_->mutex); + if (openMode & QIODevice::Truncate + || !(openForRead_ || openMode & QIODevice::Append)) + openFile_->content.clear(); + + if (openMode & QIODevice::Append) + position_ = openFile_->content.size(); + } + + return true; + } + + bool close() + { + openFile_.clear(); + + openForRead_ = false; + openForWrite_ = false; + position_ = -1; + + return true; + } + + qint64 size() const + { + QSharedPointer file = resolveFile(false); + if (!file) + return 0; + + QMutexLocker lock(&file->mutex); + return file->content.size(); + } + + qint64 pos() const + { + Q_ASSERT(openForRead_ || openForWrite_); + return position_; + } + + bool seek(qint64 pos) + { + Q_ASSERT(openForRead_ || openForWrite_); + + if (pos >= 0) { + position_ = pos; + return true; + } + + return false; + } + + bool flush() + { + Q_ASSERT(openForRead_ || openForWrite_); + return true; + } + + bool remove() + { + QMutexLocker lock(&fileSystemMutex); + int count = fileSystem.remove(fileName_); + + return (count == 1); + } + + bool copy(const QString &newName) + { + QMutexLocker lock(&fileSystemMutex); + if (!fileSystem.contains(fileName_) + || fileSystem.contains(newName)) + return false; + + fileSystem.insert(newName, fileSystem.value(fileName_)); + return true; + } + + bool rename(const QString &newName) + { + QMutexLocker lock(&fileSystemMutex); + if (!fileSystem.contains(fileName_) + || fileSystem.contains(newName)) + return false; + + fileSystem.insert(newName, fileSystem.take(fileName_)); + return true; + } + + // bool link(const QString &newName) + // { + // Q_UNUSED(newName) + // return false; + // } + + // bool mkdir(const QString &dirName, bool createParentDirectories) const + // { + // Q_UNUSED(dirName) + // Q_UNUSED(createParentDirectories) + + // return false; + // } + + // bool rmdir(const QString &dirName, bool recurseParentDirectories) const + // { + // Q_UNUSED(dirName) + // Q_UNUSED(recurseParentDirectories) + + // return false; + // } + + bool setSize(qint64 size) + { + if (size < 0) + return false; + + QSharedPointer file = resolveFile(false); + if (!file) + return false; + + QMutexLocker lock(&file->mutex); + file->content.resize(size); + + if (openForRead_ || openForWrite_) + if (position_ > size) + position_ = size; + + return (file->content.size() == size); + } + + FileFlags fileFlags(FileFlags type) const + { + QSharedPointer file = resolveFile(false); + if (file) { + QMutexLocker lock(&file->mutex); + return (file->fileFlags & type); + } + + return FileFlags(); + } + + // bool setPermissions(uint perms) + // { + // Q_UNUSED(perms) + + // return false; + // } + + QString fileName(FileName file) const + { + switch (file) { + case DefaultName: + return QLatin1String("DefaultName"); + case BaseName: + return QLatin1String("BaseName"); + case PathName: + return QLatin1String("PathName"); + case AbsoluteName: + return QLatin1String("AbsoluteName"); + case AbsolutePathName: + return QLatin1String("AbsolutePathName"); + case LinkName: + return QLatin1String("LinkName"); + case CanonicalName: + return QLatin1String("CanonicalName"); + case CanonicalPathName: + return QLatin1String("CanonicalPathName"); + case BundleName: + return QLatin1String("BundleName"); + + default: + break; + } + + return QString(); + } + + uint ownerId(FileOwner owner) const + { + QSharedPointer file = resolveFile(false); + if (file) { + switch (owner) { + case OwnerUser: + { + QMutexLocker lock(&file->mutex); + return file->userId; + } + case OwnerGroup: + { + QMutexLocker lock(&file->mutex); + return file->groupId; + } + } + } + + return -2; + } + + QString owner(FileOwner owner) const + { + QSharedPointer file = resolveFile(false); + if (file) { + uint ownerId; + switch (owner) { + case OwnerUser: + { + QMutexLocker lock(&file->mutex); + ownerId = file->userId; + } + + { + QMutexLocker lock(&fileSystemMutex); + return fileSystemUsers.value(ownerId); + } + + case OwnerGroup: + { + QMutexLocker lock(&file->mutex); + ownerId = file->groupId; + } + + { + QMutexLocker lock(&fileSystemMutex); + return fileSystemGroups.value(ownerId); + } + } + } + + return QString(); + } + + QDateTime fileTime(FileTime time) const + { + QSharedPointer file = resolveFile(false); + if (file) { + QMutexLocker lock(&file->mutex); + switch (time) { + case CreationTime: + return file->creation; + case ModificationTime: + return file->modification; + case AccessTime: + return file->access; + } + } + + return QDateTime(); + } + + void setFileName(const QString &file) + { + Q_ASSERT(!openForRead_); + Q_ASSERT(!openForWrite_); + + fileName_ = file; + } + + // typedef QAbstractFileEngineIterator Iterator; + // Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) + // { + // Q_UNUSED(filters) + // Q_UNUSED(filterNames) + + // return 0; + // } + + // Iterator *endEntryList() + // { + // return 0; + // } + + qint64 read(char *data, qint64 maxLen) + { + Q_ASSERT(openForRead_); + + Q_ASSERT(!openFile_.isNull()); + QMutexLocker lock(&openFile_->mutex); + qint64 readSize = qMin(openFile_->content.size() - position_, maxLen); + if (readSize < 0) + return -1; + + qMemCopy(data, openFile_->content.constData() + position_, readSize); + position_ += readSize; + + return readSize; + } + + qint64 write(const char *data, qint64 length) + { + Q_ASSERT(openForWrite_); + + if (length < 0) + return -1; + + Q_ASSERT(!openFile_.isNull()); + QMutexLocker lock(&openFile_->mutex); + if (openFile_->content.size() == position_) + openFile_->content.append(data, length); + else { + if (position_ + length > openFile_->content.size()) + openFile_->content.resize(position_ + length); + openFile_->content.replace(position_, length, data, length); + } + + qint64 writeSize = qMin(length, openFile_->content.size() - position_); + position_ += writeSize; + + return writeSize; + } + +protected: + // void setError(QFile::FileError error, const QString &str); + + struct File + { + File() + : userId(0) + , groupId(0) + , fileFlags( + ReadOwnerPerm | WriteOwnerPerm | ExeOwnerPerm + | ReadUserPerm | WriteUserPerm | ExeUserPerm + | ReadGroupPerm | WriteGroupPerm | ExeGroupPerm + | ReadOtherPerm | WriteOtherPerm | ExeOtherPerm + | FileType | ExistsFlag) + { + } + + QMutex mutex; + + uint userId, groupId; + QAbstractFileEngine::FileFlags fileFlags; + QDateTime creation, modification, access; + + QByteArray content; + }; + + QSharedPointer resolveFile(bool create) const + { + if (openForRead_ || openForWrite_) { + Q_ASSERT(openFile_); + return openFile_; + } + + QMutexLocker lock(&fileSystemMutex); + if (create) { + QSharedPointer &p = fileSystem[fileName_]; + if (p.isNull()) + p = QSharedPointer(new File); + return p; + } + + return fileSystem.value(fileName_); + } + + static QMutex fileSystemMutex; + static QHash fileSystemUsers, fileSystemGroups; + static QHash > fileSystem; + +private: + QString fileName_; + qint64 position_; + bool openForRead_; + bool openForWrite_; + + mutable QSharedPointer openFile_; +}; + +QMutex ReferenceFileEngine::fileSystemMutex; +QHash ReferenceFileEngine::fileSystemUsers, ReferenceFileEngine::fileSystemGroups; +QHash > ReferenceFileEngine::fileSystem; + +class FileEngineHandler + : QAbstractFileEngineHandler +{ + QAbstractFileEngine *create(const QString &fileName) const + { + if (fileName.startsWith("QFSFileEngine:")) + return new QFSFileEngine(fileName.mid(14)); + if (fileName.startsWith("reference-file-engine:")) + return new ReferenceFileEngine(fileName.mid(22)); + if (fileName.startsWith("resource:")) + return QAbstractFileEngine::create(QLatin1String(":/tst_qabstractfileengine/resources/") + fileName.mid(9)); + return 0; + } +}; + +void tst_QAbstractFileEngine::cleanupTestCase() +{ + bool failed = false; + + FileEngineHandler handler; + Q_FOREACH(QString file, filesForRemoval) + if (!QFile::remove(file) + || QFile::exists(file)) { + failed = true; + qDebug() << "Couldn't remove file:" << file; + } + + QVERIFY(!failed); +} + +void tst_QAbstractFileEngine::customHandler() +{ + QScopedPointer file; + { + file.reset(QAbstractFileEngine::create("resource:file.txt")); + + QVERIFY(file); + } + + { + FileEngineHandler handler; + + QFile file("resource:file.txt"); + QVERIFY(file.exists()); + } + + { + QFile file("resource:file.txt"); + QVERIFY(!file.exists()); + } +} + +void tst_QAbstractFileEngine::fileIO_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("readContent"); + QTest::addColumn("writeContent"); + QTest::addColumn("fileExists"); + + QString resourceTxtFile(":/tst_qabstractfileengine/resources/file.txt"); + QByteArray readContent("This is a simple text file.\n"); + QByteArray writeContent("This contains two lines of text.\n"); + + QTest::newRow("resource") << resourceTxtFile << readContent << QByteArray() << true; + QTest::newRow("native") << "native-file.txt" << readContent << writeContent << false; + QTest::newRow("Forced QFSFileEngine") << "QFSFileEngine:QFSFileEngine-file.txt" << readContent << writeContent << false; + QTest::newRow("Custom FE") << "reference-file-engine:file.txt" << readContent << writeContent << false; + + QTest::newRow("Forced QFSFileEngine (native)") << "QFSFileEngine:native-file.txt" << readContent << writeContent << true; + QTest::newRow("native (Forced QFSFileEngine)") << "QFSFileEngine-file.txt" << readContent << writeContent << true; + QTest::newRow("Custom FE (2)") << "reference-file-engine:file.txt" << readContent << writeContent << true; +} + +void tst_QAbstractFileEngine::fileIO() +{ + QFETCH(QString, fileName); + QFETCH(QByteArray, readContent); + QFETCH(QByteArray, writeContent); + QFETCH(bool, fileExists); + + FileEngineHandler handler; + + + { + QFile file(fileName); + QCOMPARE(file.exists(), fileExists); + + if (!fileExists) { + QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Unbuffered)); + filesForRemoval.append(fileName); + + QCOMPARE(file.write(readContent), qint64(readContent.size())); + } + } + + // + // File content is: readContent + // + + qint64 fileSize = readContent.size(); + { + // Reading + QFile file(fileName); + + QVERIFY(!file.isOpen()); + QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)); + + QVERIFY(file.isOpen()); + QCOMPARE(file.size(), fileSize); + QCOMPARE(file.pos(), qint64(0)); + + QCOMPARE(file.size(), fileSize); + QCOMPARE(file.readAll(), readContent); + QCOMPARE(file.pos(), fileSize); + + file.close(); + QVERIFY(!file.isOpen()); + QCOMPARE(file.size(), fileSize); + } + + if (writeContent.isEmpty()) + return; + + { + // Writing / appending + QFile file(fileName); + + QVERIFY(!file.isOpen()); + QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered)); + + QVERIFY(file.isOpen()); + QCOMPARE(file.size(), fileSize); + QCOMPARE(file.pos(), fileSize); + + QCOMPARE(file.write(writeContent), qint64(writeContent.size())); + + fileSize += writeContent.size(); + QCOMPARE(file.pos(), fileSize); + QCOMPARE(file.size(), fileSize); + + file.close(); + QVERIFY(!file.isOpen()); + QCOMPARE(file.size(), fileSize); + } + + // + // File content is: readContent + writeContent + // + + { + // Reading and Writing + QFile file(fileName); + + QVERIFY(!file.isOpen()); + QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Unbuffered)); + + QVERIFY(file.isOpen()); + QCOMPARE(file.size(), fileSize); + QCOMPARE(file.pos(), qint64(0)); + + QCOMPARE(file.readAll(), readContent + writeContent); + QCOMPARE(file.pos(), fileSize); + QCOMPARE(file.size(), fileSize); + + QVERIFY(file.seek(writeContent.size())); + QCOMPARE(file.pos(), qint64(writeContent.size())); + QCOMPARE(file.size(), fileSize); + + QCOMPARE(file.write(readContent), qint64(readContent.size())); + QCOMPARE(file.pos(), fileSize); + QCOMPARE(file.size(), fileSize); + + QVERIFY(file.seek(0)); + QCOMPARE(file.pos(), qint64(0)); + QCOMPARE(file.size(), fileSize); + + QCOMPARE(file.write(writeContent), qint64(writeContent.size())); + QCOMPARE(file.pos(), qint64(writeContent.size())); + QCOMPARE(file.size(), fileSize); + + QVERIFY(file.seek(0)); + QCOMPARE(file.read(writeContent.size()), writeContent); + QCOMPARE(file.pos(), qint64(writeContent.size())); + QCOMPARE(file.size(), fileSize); + + QCOMPARE(file.readAll(), readContent); + QCOMPARE(file.pos(), fileSize); + QCOMPARE(file.size(), fileSize); + + file.close(); + QVERIFY(!file.isOpen()); + QCOMPARE(file.size(), fileSize); + } + + // + // File content is: writeContent + readContent + // + + { + // Writing + QFile file(fileName); + + QVERIFY(!file.isOpen()); + QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Unbuffered)); + + QVERIFY(file.isOpen()); + QCOMPARE(file.size(), fileSize); + QCOMPARE(file.pos(), qint64(0)); + + QCOMPARE(file.write(writeContent), qint64(writeContent.size())); + QCOMPARE(file.pos(), qint64(writeContent.size())); + QCOMPARE(file.size(), fileSize); + + QVERIFY(file.resize(writeContent.size())); + QCOMPARE(file.size(), qint64(writeContent.size())); + + file.close(); + QVERIFY(!file.isOpen()); + QCOMPARE(file.size(), qint64(writeContent.size())); + + QVERIFY(file.resize(fileSize)); + QCOMPARE(file.size(), fileSize); + } + + // + // File content is: writeContent + + // File size is : (readContent + writeContent).size() + // + + { + // Writing / extending + QFile file(fileName); + + QVERIFY(!file.isOpen()); + QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Unbuffered)); + + QVERIFY(file.isOpen()); + QCOMPARE(file.size(), fileSize); + QCOMPARE(file.pos(), qint64(0)); + + QVERIFY(file.seek(1024)); + QCOMPARE(file.pos(), qint64(1024)); + QCOMPARE(file.size(), fileSize); + + fileSize = 1024 + writeContent.size(); + QCOMPARE(file.write(writeContent), qint64(writeContent.size())); + QCOMPARE(file.pos(), fileSize); + QCOMPARE(file.size(), fileSize); + + QVERIFY(file.seek(1028)); + QCOMPARE(file.pos(), qint64(1028)); + QCOMPARE(file.size(), fileSize); + + fileSize = 1028 + writeContent.size(); + QCOMPARE(file.write(writeContent), qint64(writeContent.size())); + QCOMPARE(file.pos(), fileSize); + QCOMPARE(file.size(), fileSize); + + file.close(); + QVERIFY(!file.isOpen()); + QCOMPARE(file.size(), fileSize); + } + + // + // File content is: writeContent + + writeContent + // File size is : 1024 + writeContent.size() + // + + { + // Writing / truncating + QFile file(fileName); + + QVERIFY(!file.isOpen()); + QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Unbuffered)); + + QVERIFY(file.isOpen()); + QCOMPARE(file.size(), qint64(0)); + QCOMPARE(file.pos(), qint64(0)); + + fileSize = readContent.size(); + QCOMPARE(file.write(readContent), fileSize); + QCOMPARE(file.pos(), fileSize); + QCOMPARE(file.size(), fileSize); + + file.close(); + QVERIFY(!file.isOpen()); + QCOMPARE(file.size(), fileSize); + } + + // + // File content is: readContent + // +} + +QTEST_APPLESS_MAIN(tst_QAbstractFileEngine) +#include "tst_qabstractfileengine.moc" + -- cgit v0.12 From 04c3d2e98cebd16a357923ab71a95882e4667ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Wed, 24 Nov 2010 16:43:58 +0100 Subject: QAbstractFileEngine test case Oops, I let a space character slip... --- tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp index b2003a0..f98adca 100644 --- a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp @@ -236,7 +236,7 @@ public: QSharedPointer file = resolveFile(false); if (file) { switch (owner) { - case OwnerUser: + case OwnerUser: { QMutexLocker lock(&file->mutex); return file->userId; -- cgit v0.12 From 79281991e21bb5bd3a6f3288ac934aa4c2b33fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 25 Nov 2010 10:47:42 +0100 Subject: Let's use engine's understanding of relative path As much as I'd like to have the definition of "relative" be independent of custom engines, the current architecture prevents us from doing that without introducing knowledge about them in QFileSystemEntry. Fixing this specifically for resource files would be possible, but let's not break custom engines... just yet. Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 4 +++- src/corelib/io/qfileinfo.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 22a3baa..e1fed0d 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1544,7 +1544,9 @@ bool QDir::isRoot() const */ bool QDir::isRelative() const { - return d_ptr->dirEntry.isRelative(); + if (d_ptr->fileEngine.isNull()) + return d_ptr->dirEntry.isRelative(); + return d_ptr->fileEngine->isRelativePath(); } diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 471da2e..9041c94 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -623,7 +623,9 @@ bool QFileInfo::isRelative() const Q_D(const QFileInfo); if (d->isDefaultConstructed) return true; - return d->fileEntry.isRelative(); + if (d->fileEngine == 0) + return d->fileEntry.isRelative(); + return d->fileEngine->isRelativePath(); } /*! -- cgit v0.12 From 72fae4bd1bdf5a56632f8ca638f7d1165f6fe1ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 25 Nov 2010 11:05:04 +0100 Subject: Fix QFileDialog autotest Test expects to see a directory in SRCDIR. Copying the resources directory from QAbstractFileEngine autotest shouldn't impact the git repository and serves our purposes well :-) Reviewed-by: Olivier Goffart --- tests/auto/qfiledialog/resources/file.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/auto/qfiledialog/resources/file.txt diff --git a/tests/auto/qfiledialog/resources/file.txt b/tests/auto/qfiledialog/resources/file.txt new file mode 100644 index 0000000..8a03e0e --- /dev/null +++ b/tests/auto/qfiledialog/resources/file.txt @@ -0,0 +1 @@ +This is a simple text file. -- cgit v0.12 From 83c91bb021e9adf86870c498641e329ab7f786c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 25 Nov 2010 11:23:10 +0100 Subject: Fix QFile::link unit test Absolute path for the link target can contain "../" elements and so needs to be cleaned. Really depends on the definition for SRCDIR. Reviewed-by: Prasanth Ullattil --- tests/auto/qfile/tst_qfile.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index dbd4302..ba9a8bf 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -1296,22 +1296,28 @@ void tst_QFile::link() QSKIP("Symbian does not support links", SkipAll); #endif QFile::remove("myLink.lnk"); + QFileInfo info1(SRCDIR "tst_qfile.cpp"); + QString referenceTarget = QDir::cleanPath(info1.absoluteFilePath()); + QVERIFY(QFile::link(SRCDIR "tst_qfile.cpp", "myLink.lnk")); + QFileInfo info2("myLink.lnk"); QVERIFY(info2.isSymLink()); - QCOMPARE(info2.symLinkTarget(), info1.absoluteFilePath()); + QCOMPARE(info2.symLinkTarget(), referenceTarget); QFile link("myLink.lnk"); QVERIFY(link.open(QIODevice::ReadOnly)); - QCOMPARE(link.symLinkTarget(), info1.absoluteFilePath()); + QCOMPARE(link.symLinkTarget(), referenceTarget); link.close(); - QCOMPARE(QFile::symLinkTarget("myLink.lnk"), info1.absoluteFilePath()); + + QCOMPARE(QFile::symLinkTarget("myLink.lnk"), referenceTarget); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath()); - QCOMPARE(QDir::fromNativeSeparators(wd), info1.absolutePath()); + QCOMPARE(QDir::fromNativeSeparators(wd), referenceTarget); #endif + QVERIFY(QFile::remove(info2.absoluteFilePath())); } -- cgit v0.12 From c7f1fdbe9d1c7387b3a72624b428a1d0f19d5b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 25 Nov 2010 17:50:09 +0100 Subject: Flagging some more tests as parallelizable These tests have no GUI nor do they depend on network, so let's see what breaks if they're parallelized :-) Reviewed-by: Olivier Goffart --- tests/auto/qdir/qdir.pro | 1 + tests/auto/qfile/largefile/largefile.pro | 2 ++ tests/auto/qfile/qfile.pro | 1 + tests/auto/qfileinfo/qfileinfo.pro | 2 ++ tests/auto/qfilesystementry/qfilesystementry.pro | 1 + tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro | 2 ++ tests/auto/qsettings/qsettings.pro | 2 ++ tests/auto/qtemporaryfile/qtemporaryfile.pro | 2 ++ 8 files changed, 13 insertions(+) diff --git a/tests/auto/qdir/qdir.pro b/tests/auto/qdir/qdir.pro index 33aee4b..55fd031 100644 --- a/tests/auto/qdir/qdir.pro +++ b/tests/auto/qdir/qdir.pro @@ -21,3 +21,4 @@ wince* { DEFINES += SRCDIR=\\\"$$PWD/\\\" } +CONFIG += parallel_test diff --git a/tests/auto/qfile/largefile/largefile.pro b/tests/auto/qfile/largefile/largefile.pro index d67cb46..6407cb6 100644 --- a/tests/auto/qfile/largefile/largefile.pro +++ b/tests/auto/qfile/largefile/largefile.pro @@ -4,3 +4,5 @@ QT = core SOURCES += tst_largefile.cpp wince*: SOURCES += $$QT_SOURCE_TREE/src/corelib/kernel/qfunctions_wince.cpp + +CONFIG += parallel_test diff --git a/tests/auto/qfile/qfile.pro b/tests/auto/qfile/qfile.pro index 727f660..f41d327 100644 --- a/tests/auto/qfile/qfile.pro +++ b/tests/auto/qfile/qfile.pro @@ -7,3 +7,4 @@ wince*|symbian:{ !symbian:SUBDIRS += largefile +CONFIG += parallel_test diff --git a/tests/auto/qfileinfo/qfileinfo.pro b/tests/auto/qfileinfo/qfileinfo.pro index f3622da..b35b1e0 100644 --- a/tests/auto/qfileinfo/qfileinfo.pro +++ b/tests/auto/qfileinfo/qfileinfo.pro @@ -31,3 +31,5 @@ wince* { } contains(QT_CONFIG, qt3support): QT += qt3support + +CONFIG += parallel_test diff --git a/tests/auto/qfilesystementry/qfilesystementry.pro b/tests/auto/qfilesystementry/qfilesystementry.pro index 9f75388..b9b43e6 100644 --- a/tests/auto/qfilesystementry/qfilesystementry.pro +++ b/tests/auto/qfilesystementry/qfilesystementry.pro @@ -5,3 +5,4 @@ SOURCES += tst_qfilesystementry.cpp \ HEADERS += ../../../src/corelib/io/qfilesystementry_p.h QT = core +CONFIG += parallel_test diff --git a/tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro b/tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro index 8b8616a..75e85a0 100644 --- a/tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro +++ b/tests/auto/qfilesystemwatcher/qfilesystemwatcher.pro @@ -1,3 +1,5 @@ load(qttest_p4) SOURCES += tst_qfilesystemwatcher.cpp QT = core + +CONFIG += parallel_test diff --git a/tests/auto/qsettings/qsettings.pro b/tests/auto/qsettings/qsettings.pro index 19513b3..fe104df 100644 --- a/tests/auto/qsettings/qsettings.pro +++ b/tests/auto/qsettings/qsettings.pro @@ -6,3 +6,5 @@ contains(QT_CONFIG, qt3support):QT += qt3support CONFIG -= debug CONFIG += release win32-msvc*:LIBS += advapi32.lib + +CONFIG += parallel_test diff --git a/tests/auto/qtemporaryfile/qtemporaryfile.pro b/tests/auto/qtemporaryfile/qtemporaryfile.pro index 543c143..64a043b 100644 --- a/tests/auto/qtemporaryfile/qtemporaryfile.pro +++ b/tests/auto/qtemporaryfile/qtemporaryfile.pro @@ -10,3 +10,5 @@ symbian { }else { DEFINES += SRCDIR=\\\"$$PWD/\\\" } + +CONFIG += parallel_test -- cgit v0.12 From b0fb70cd74ef1453a36169088e6f283206818d78 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Fri, 26 Nov 2010 16:32:32 +0100 Subject: Fix link() autotest on Windows This was missed from the previous commit. Reviewed-by: Joao --- tests/auto/qfile/tst_qfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index ba9a8bf..1bbf230 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -1315,7 +1315,7 @@ void tst_QFile::link() #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QString wd = getWorkingDirectoryForLink(info2.absoluteFilePath()); - QCOMPARE(QDir::fromNativeSeparators(wd), referenceTarget); + QCOMPARE(QDir::fromNativeSeparators(wd), QDir::cleanPath(info1.absolutePath())); #endif QVERIFY(QFile::remove(info2.absoluteFilePath())); -- cgit v0.12 From ec1526a73fef7d95268437204fa8534085940fbc Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 23 Nov 2010 14:30:51 +0000 Subject: Fix compile error on symbian Symbian doesn't have file owners, the resolveUserName / resolveGroupName functions have been correctly moved to unix only scope which caused a compile error. This change makes the QFSFileEngine::owner[Id] return -2 / QString() for symbian directly. Reviewed-by: Markus Goetz --- src/corelib/io/qfsfileengine_unix.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 035e78f..55388e6 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -861,9 +861,13 @@ uint QFSFileEngine::ownerId(FileOwner own) const QString QFSFileEngine::owner(FileOwner own) const { +#ifndef Q_OS_SYMBIAN if (own == OwnerUser) return QFileSystemEngine::resolveUserName(ownerId(own)); return QFileSystemEngine::resolveGroupName(ownerId(own)); +#else + return QString(); +#endif } bool QFSFileEngine::setPermissions(uint perms) -- cgit v0.12 From 9120864d7263cd1ed288770314e387de95d14bf3 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 29 Nov 2010 13:48:03 +0000 Subject: Update with def files merged from master This set of def files is good to merge back, if the merge is done soon. Reviewed-by: Trust Me --- src/s60installs/bwins/QtCoreu.def | 105 +++++++++++++++++++++ src/s60installs/bwins/QtGuiu.def | 156 +++++++++++++++++++++++++++++++- src/s60installs/eabi/QtCoreu.def | 80 ++++++++++++++++ src/s60installs/eabi/QtDeclarativeu.def | 4 +- src/s60installs/eabi/QtGuiu.def | 130 +++++++++++++++++++++++++- 5 files changed, 468 insertions(+), 7 deletions(-) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index b0bf2cc..a3c7fbb 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4486,4 +4486,109 @@ EXPORTS ?objectNameChanged@QAbstractDeclarativeData@@2P6AXPAV1@PAVQObject@@@ZA @ 4485 NONAME ; void (*QAbstractDeclarativeData::objectNameChanged)(class QAbstractDeclarativeData *, class QObject *) ?queueDeferredActiveObjectsCompletion@QEventDispatcherSymbian@@QAEXXZ @ 4486 NONAME ; void QEventDispatcherSymbian::queueDeferredActiveObjectsCompletion(void) ?reactivateDeferredActiveObjects@QEventDispatcherSymbian@@UAEXXZ @ 4487 NONAME ; void QEventDispatcherSymbian::reactivateDeferredActiveObjects(void) + ??0QAnimationDriver@@IAE@AAVQAnimationDriverPrivate@@PAVQObject@@@Z @ 4488 NONAME ; QAnimationDriver::QAnimationDriver(class QAnimationDriverPrivate &, class QObject *) + ??0QAnimationDriver@@QAE@PAVQObject@@@Z @ 4489 NONAME ; QAnimationDriver::QAnimationDriver(class QObject *) + ??0QAnimationDriverPrivate@@QAE@XZ @ 4490 NONAME ; QAnimationDriverPrivate::QAnimationDriverPrivate(void) + ??0QCoreApplication@@QAE@AAHPAPADH@Z @ 4491 NONAME ; QCoreApplication::QCoreApplication(int &, char * *, int) + ??0QCoreApplicationPrivate@@QAE@AAHPAPADI@Z @ 4492 NONAME ; QCoreApplicationPrivate::QCoreApplicationPrivate(int &, char * *, unsigned int) + ??0QFileInfo@@QAE@PAVQFileInfoPrivate@@@Z @ 4493 NONAME ; QFileInfo::QFileInfo(class QFileInfoPrivate *) + ??0QSystemError@@QAE@HW4ErrorScope@0@@Z @ 4494 NONAME ; QSystemError::QSystemError(int, enum QSystemError::ErrorScope) + ??0QSystemError@@QAE@XZ @ 4495 NONAME ; QSystemError::QSystemError(void) + ??0QUnifiedTimer@@AAE@XZ @ 4496 NONAME ; QUnifiedTimer::QUnifiedTimer(void) + ??0QXmlStreamAttributes@@QAE@XZ @ 4497 NONAME ; QXmlStreamAttributes::QXmlStreamAttributes(void) + ??1QAnimationDriver@@UAE@XZ @ 4498 NONAME ; QAnimationDriver::~QAnimationDriver(void) + ??1QAnimationDriverPrivate@@UAE@XZ @ 4499 NONAME ; QAnimationDriverPrivate::~QAnimationDriverPrivate(void) + ??1QUnifiedTimer@@UAE@XZ @ 4500 NONAME ; QUnifiedTimer::~QUnifiedTimer(void) + ??_EQAnimationDriver@@UAE@I@Z @ 4501 NONAME ; QAnimationDriver::~QAnimationDriver(unsigned int) + ??_EQAnimationDriverPrivate@@UAE@I@Z @ 4502 NONAME ; QAnimationDriverPrivate::~QAnimationDriverPrivate(unsigned int) + ??_EQUnifiedTimer@@UAE@I@Z @ 4503 NONAME ; QUnifiedTimer::~QUnifiedTimer(unsigned int) + ?advance@QAnimationDriver@@QAEXXZ @ 4504 NONAME ; void QAnimationDriver::advance(void) + ?cast@QMetaObject@@QBEPBVQObject@@PBV2@@Z @ 4505 NONAME ; class QObject const * QMetaObject::cast(class QObject const *) const + ?closestPauseAnimationTimeToFinish@QUnifiedTimer@@AAEHXZ @ 4506 NONAME ; int QUnifiedTimer::closestPauseAnimationTimeToFinish(void) + ?connect@QObject@@SA_NPBV1@ABVQMetaMethod@@01W4ConnectionType@Qt@@@Z @ 4507 NONAME ; bool QObject::connect(class QObject const *, class QMetaMethod const &, class QObject const *, class QMetaMethod const &, enum Qt::ConnectionType) + ?contains@QString@@QBE?AVQBool@@ABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4508 NONAME ; class QBool QString::contains(class QStringRef const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@ABV1@W4CaseSensitivity@Qt@@@Z @ 4509 NONAME ; class QBool QStringRef::contains(class QStringRef const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@ABVQString@@W4CaseSensitivity@Qt@@@Z @ 4510 NONAME ; class QBool QStringRef::contains(class QString const &, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@VQChar@@W4CaseSensitivity@Qt@@@Z @ 4511 NONAME ; class QBool QStringRef::contains(class QChar, enum Qt::CaseSensitivity) const + ?contains@QStringRef@@QBE?AVQBool@@VQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4512 NONAME ; class QBool QStringRef::contains(class QLatin1String, enum Qt::CaseSensitivity) const + ?count@QString@@QBEHABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4513 NONAME ; int QString::count(class QStringRef const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHABV1@W4CaseSensitivity@Qt@@@Z @ 4514 NONAME ; int QStringRef::count(class QStringRef const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHABVQString@@W4CaseSensitivity@Qt@@@Z @ 4515 NONAME ; int QStringRef::count(class QString const &, enum Qt::CaseSensitivity) const + ?count@QStringRef@@QBEHVQChar@@W4CaseSensitivity@Qt@@@Z @ 4516 NONAME ; int QStringRef::count(class QChar, enum Qt::CaseSensitivity) const + ?d_func@QAnimationDriver@@AAEPAVQAnimationDriverPrivate@@XZ @ 4517 NONAME ; class QAnimationDriverPrivate * QAnimationDriver::d_func(void) + ?d_func@QAnimationDriver@@ABEPBVQAnimationDriverPrivate@@XZ @ 4518 NONAME ; class QAnimationDriverPrivate const * QAnimationDriver::d_func(void) const + ?disconnect@QObject@@SA_NPBV1@ABVQMetaMethod@@01@Z @ 4519 NONAME ; bool QObject::disconnect(class QObject const *, class QMetaMethod const &, class QObject const *, class QMetaMethod const &) + ?endsWith@QString@@QBE_NABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4520 NONAME ; bool QString::endsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NABV1@W4CaseSensitivity@Qt@@@Z @ 4521 NONAME ; bool QStringRef::endsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NABVQString@@W4CaseSensitivity@Qt@@@Z @ 4522 NONAME ; bool QStringRef::endsWith(class QString const &, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NVQChar@@W4CaseSensitivity@Qt@@@Z @ 4523 NONAME ; bool QStringRef::endsWith(class QChar, enum Qt::CaseSensitivity) const + ?endsWith@QStringRef@@QBE_NVQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4524 NONAME ; bool QStringRef::endsWith(class QLatin1String, enum Qt::CaseSensitivity) const + ?ensureTimerUpdate@QUnifiedTimer@@SAXXZ @ 4525 NONAME ; void QUnifiedTimer::ensureTimerUpdate(void) + ?error@QSystemError@@QAEHXZ @ 4526 NONAME ; int QSystemError::error(void) + ?getStaticMetaObject@QAnimationDriver@@SAABUQMetaObject@@XZ @ 4527 NONAME ; struct QMetaObject const & QAnimationDriver::getStaticMetaObject(void) + ?indexOf@QString@@QBEHABVQStringRef@@HW4CaseSensitivity@Qt@@@Z @ 4528 NONAME ; int QString::indexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHABV1@HW4CaseSensitivity@Qt@@@Z @ 4529 NONAME ; int QStringRef::indexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHABVQString@@HW4CaseSensitivity@Qt@@@Z @ 4530 NONAME ; int QStringRef::indexOf(class QString const &, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHVQChar@@HW4CaseSensitivity@Qt@@@Z @ 4531 NONAME ; int QStringRef::indexOf(class QChar, int, enum Qt::CaseSensitivity) const + ?indexOf@QStringRef@@QBEHVQLatin1String@@HW4CaseSensitivity@Qt@@@Z @ 4532 NONAME ; int QStringRef::indexOf(class QLatin1String, int, enum Qt::CaseSensitivity) const + ?install@QAnimationDriver@@QAEXXZ @ 4533 NONAME ; void QAnimationDriver::install(void) + ?installAnimationDriver@QUnifiedTimer@@QAEXPAVQAnimationDriver@@@Z @ 4534 NONAME ; void QUnifiedTimer::installAnimationDriver(class QAnimationDriver *) + ?instance@QUnifiedTimer@@SAPAV1@_N@Z @ 4535 NONAME ; class QUnifiedTimer * QUnifiedTimer::instance(bool) + ?isLocalFile@QUrl@@QBE_NXZ @ 4536 NONAME ; bool QUrl::isLocalFile(void) const + ?isRunning@QAnimationDriver@@QBE_NXZ @ 4537 NONAME ; bool QAnimationDriver::isRunning(void) const + ?lastIndexOf@QString@@QBEHABVQStringRef@@HW4CaseSensitivity@Qt@@@Z @ 4538 NONAME ; int QString::lastIndexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHABV1@HW4CaseSensitivity@Qt@@@Z @ 4539 NONAME ; int QStringRef::lastIndexOf(class QStringRef const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHABVQString@@HW4CaseSensitivity@Qt@@@Z @ 4540 NONAME ; int QStringRef::lastIndexOf(class QString const &, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHVQChar@@HW4CaseSensitivity@Qt@@@Z @ 4541 NONAME ; int QStringRef::lastIndexOf(class QChar, int, enum Qt::CaseSensitivity) const + ?lastIndexOf@QStringRef@@QBEHVQLatin1String@@HW4CaseSensitivity@Qt@@@Z @ 4542 NONAME ; int QStringRef::lastIndexOf(class QLatin1String, int, enum Qt::CaseSensitivity) const + ?lockInline@QMutex@@QAEXXZ @ 4543 NONAME ; void QMutex::lockInline(void) + ?lockInternal@QMutex@@AAEXXZ @ 4544 NONAME ; void QMutex::lockInternal(void) + ?metaObject@QAnimationDriver@@UBEPBUQMetaObject@@XZ @ 4545 NONAME ; struct QMetaObject const * QAnimationDriver::metaObject(void) const + ?nativeKey@QSharedMemory@@QBE?AVQString@@XZ @ 4546 NONAME ; class QString QSharedMemory::nativeKey(void) const + ?qt_metacall@QAnimationDriver@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 4547 NONAME ; int QAnimationDriver::qt_metacall(enum QMetaObject::Call, int, void * *) + ?qt_metacast@QAnimationDriver@@UAEPAXPBD@Z @ 4548 NONAME ; void * QAnimationDriver::qt_metacast(char const *) + ?registerAnimation@QUnifiedTimer@@SAXPAVQAbstractAnimation@@_N@Z @ 4549 NONAME ; void QUnifiedTimer::registerAnimation(class QAbstractAnimation *, bool) + ?registerRunningAnimation@QUnifiedTimer@@AAEXPAVQAbstractAnimation@@@Z @ 4550 NONAME ; void QUnifiedTimer::registerRunningAnimation(class QAbstractAnimation *) + ?restartAnimationTimer@QUnifiedTimer@@QAEXXZ @ 4551 NONAME ; void QUnifiedTimer::restartAnimationTimer(void) + ?scope@QSystemError@@QAE?AW4ErrorScope@1@XZ @ 4552 NONAME ; enum QSystemError::ErrorScope QSystemError::scope(void) + ?senderSignalIndex@QObject@@IBEHXZ @ 4553 NONAME ; int QObject::senderSignalIndex(void) const + ?setConsistentTiming@QUnifiedTimer@@QAEX_N@Z @ 4554 NONAME ; void QUnifiedTimer::setConsistentTiming(bool) + ?setNativeKey@QSharedMemory@@QAEXABVQString@@@Z @ 4555 NONAME ; void QSharedMemory::setNativeKey(class QString const &) + ?setSlowModeEnabled@QUnifiedTimer@@QAEX_N@Z @ 4556 NONAME ; void QUnifiedTimer::setSlowModeEnabled(bool) + ?setSlowdownFactor@QUnifiedTimer@@QAEXM@Z @ 4557 NONAME ; void QUnifiedTimer::setSlowdownFactor(float) + ?setTimingInterval@QUnifiedTimer@@QAEXH@Z @ 4558 NONAME ; void QUnifiedTimer::setTimingInterval(int) + ?start@QAnimationDriver@@AAEXXZ @ 4559 NONAME ; void QAnimationDriver::start(void) + ?startsWith@QString@@QBE_NABVQStringRef@@W4CaseSensitivity@Qt@@@Z @ 4560 NONAME ; bool QString::startsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NABV1@W4CaseSensitivity@Qt@@@Z @ 4561 NONAME ; bool QStringRef::startsWith(class QStringRef const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NABVQString@@W4CaseSensitivity@Qt@@@Z @ 4562 NONAME ; bool QStringRef::startsWith(class QString const &, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NVQChar@@W4CaseSensitivity@Qt@@@Z @ 4563 NONAME ; bool QStringRef::startsWith(class QChar, enum Qt::CaseSensitivity) const + ?startsWith@QStringRef@@QBE_NVQLatin1String@@W4CaseSensitivity@Qt@@@Z @ 4564 NONAME ; bool QStringRef::startsWith(class QLatin1String, enum Qt::CaseSensitivity) const + ?stop@QAnimationDriver@@AAEXXZ @ 4565 NONAME ; void QAnimationDriver::stop(void) + ?swap@QBitArray@@QAEXAAV1@@Z @ 4566 NONAME ; void QBitArray::swap(class QBitArray &) + ?swap@QByteArray@@QAEXAAV1@@Z @ 4567 NONAME ; void QByteArray::swap(class QByteArray &) + ?swap@QRegExp@@QAEXAAV1@@Z @ 4568 NONAME ; void QRegExp::swap(class QRegExp &) + ?swap@QString@@QAEXAAV1@@Z @ 4569 NONAME ; void QString::swap(class QString &) + ?swap@QUrl@@QAEXAAV1@@Z @ 4570 NONAME ; void QUrl::swap(class QUrl &) + ?swap@QVariant@@QAEXAAV1@@Z @ 4571 NONAME ; void QVariant::swap(class QVariant &) + ?timerEvent@QUnifiedTimer@@MAEXPAVQTimerEvent@@@Z @ 4572 NONAME ; void QUnifiedTimer::timerEvent(class QTimerEvent *) + ?toAscii@QStringRef@@QBE?AVQByteArray@@XZ @ 4573 NONAME ; class QByteArray QStringRef::toAscii(void) const + ?toLatin1@QStringRef@@QBE?AVQByteArray@@XZ @ 4574 NONAME ; class QByteArray QStringRef::toLatin1(void) const + ?toLocal8Bit@QStringRef@@QBE?AVQByteArray@@XZ @ 4575 NONAME ; class QByteArray QStringRef::toLocal8Bit(void) const + ?toString@QSystemError@@QAE?AVQString@@XZ @ 4576 NONAME ; class QString QSystemError::toString(void) + ?toUcs4@QStringRef@@QBE?AV?$QVector@I@@XZ @ 4577 NONAME ; class QVector QStringRef::toUcs4(void) const + ?toUtf8@QStringRef@@QBE?AVQByteArray@@XZ @ 4578 NONAME ; class QByteArray QStringRef::toUtf8(void) const + ?tr@QAnimationDriver@@SA?AVQString@@PBD0@Z @ 4579 NONAME ; class QString QAnimationDriver::tr(char const *, char const *) + ?tr@QAnimationDriver@@SA?AVQString@@PBD0H@Z @ 4580 NONAME ; class QString QAnimationDriver::tr(char const *, char const *, int) + ?trUtf8@QAnimationDriver@@SA?AVQString@@PBD0@Z @ 4581 NONAME ; class QString QAnimationDriver::trUtf8(char const *, char const *) + ?trUtf8@QAnimationDriver@@SA?AVQString@@PBD0H@Z @ 4582 NONAME ; class QString QAnimationDriver::trUtf8(char const *, char const *, int) + ?tryLockInline@QMutex@@QAE_NXZ @ 4583 NONAME ; bool QMutex::tryLockInline(void) + ?unlockInline@QMutex@@QAEXXZ @ 4584 NONAME ; void QMutex::unlockInline(void) + ?unlockInternal@QMutex@@AAEXXZ @ 4585 NONAME ; void QMutex::unlockInternal(void) + ?unregisterAnimation@QUnifiedTimer@@SAXPAVQAbstractAnimation@@@Z @ 4586 NONAME ; void QUnifiedTimer::unregisterAnimation(class QAbstractAnimation *) + ?unregisterRunningAnimation@QUnifiedTimer@@AAEXPAVQAbstractAnimation@@@Z @ 4587 NONAME ; void QUnifiedTimer::unregisterRunningAnimation(class QAbstractAnimation *) + ?updateAnimationTimer@QUnifiedTimer@@SAXXZ @ 4588 NONAME ; void QUnifiedTimer::updateAnimationTimer(void) + ?updateAnimationsTime@QUnifiedTimer@@QAEXXZ @ 4589 NONAME ; void QUnifiedTimer::updateAnimationsTime(void) + ?waitForDone@QThreadPool@@QAE_NH@Z @ 4590 NONAME ; bool QThreadPool::waitForDone(int) + ?app_compile_version@QCoreApplicationPrivate@@2HA @ 4591 NONAME ; int QCoreApplicationPrivate::app_compile_version + ?staticMetaObject@QAnimationDriver@@2UQMetaObject@@B @ 4592 NONAME ; struct QMetaObject const QAnimationDriver::staticMetaObject diff --git a/src/s60installs/bwins/QtGuiu.def b/src/s60installs/bwins/QtGuiu.def index b4a5dfc..8d8f500 100644 --- a/src/s60installs/bwins/QtGuiu.def +++ b/src/s60installs/bwins/QtGuiu.def @@ -464,7 +464,7 @@ EXPORTS ??0QRadioButton@@QAE@ABVQString@@PAVQWidget@@@Z @ 463 NONAME ; QRadioButton::QRadioButton(class QString const &, class QWidget *) ??0QRadioButton@@QAE@PAVQWidget@@@Z @ 464 NONAME ; QRadioButton::QRadioButton(class QWidget *) ??0QRasterPixmapData@@QAE@W4PixelType@QPixmapData@@@Z @ 465 NONAME ; QRasterPixmapData::QRasterPixmapData(enum QPixmapData::PixelType) - ??0QRasterWindowSurface@@QAE@PAVQWidget@@@Z @ 466 NONAME ; QRasterWindowSurface::QRasterWindowSurface(class QWidget *) + ??0QRasterWindowSurface@@QAE@PAVQWidget@@@Z @ 466 NONAME ABSENT ; QRasterWindowSurface::QRasterWindowSurface(class QWidget *) ??0QRegExpValidator@@QAE@ABVQRegExp@@PAVQObject@@@Z @ 467 NONAME ; QRegExpValidator::QRegExpValidator(class QRegExp const &, class QObject *) ??0QRegExpValidator@@QAE@PAVQObject@@@Z @ 468 NONAME ; QRegExpValidator::QRegExpValidator(class QObject *) ??0QRegion@@QAE@ABV0@@Z @ 469 NONAME ; QRegion::QRegion(class QRegion const &) @@ -845,7 +845,7 @@ EXPORTS ??0QWidgetResizeHandler@@QAE@PAVQWidget@@0@Z @ 844 NONAME ; QWidgetResizeHandler::QWidgetResizeHandler(class QWidget *, class QWidget *) ??0QWindowStateChangeEvent@@QAE@V?$QFlags@W4WindowState@Qt@@@@@Z @ 845 NONAME ; QWindowStateChangeEvent::QWindowStateChangeEvent(class QFlags) ??0QWindowStateChangeEvent@@QAE@V?$QFlags@W4WindowState@Qt@@@@_N@Z @ 846 NONAME ; QWindowStateChangeEvent::QWindowStateChangeEvent(class QFlags, bool) - ??0QWindowSurface@@QAE@PAVQWidget@@@Z @ 847 NONAME ; QWindowSurface::QWindowSurface(class QWidget *) + ??0QWindowSurface@@QAE@PAVQWidget@@@Z @ 847 NONAME ABSENT ; QWindowSurface::QWindowSurface(class QWidget *) ??0QWindowsStyle@@IAE@AAVQWindowsStylePrivate@@@Z @ 848 NONAME ; QWindowsStyle::QWindowsStyle(class QWindowsStylePrivate &) ??0QWindowsStyle@@QAE@XZ @ 849 NONAME ; QWindowsStyle::QWindowsStyle(void) ??0QWizard@@QAE@PAVQWidget@@V?$QFlags@W4WindowType@Qt@@@@@Z @ 850 NONAME ; QWizard::QWizard(class QWidget *, class QFlags) @@ -12898,4 +12898,156 @@ EXPORTS ?qmljsDebugArgumentsString@QApplicationPrivate@@SA?AVQString@@XZ @ 12897 NONAME ; class QString QApplicationPrivate::qmljsDebugArgumentsString(void) ?convertToPostscriptFontFamilyName@QFontEngine@@SA?AVQByteArray@@ABV2@@Z @ 12898 NONAME ; class QByteArray QFontEngine::convertToPostscriptFontFamilyName(class QByteArray const &) ?lastResortFont@QFont@@QBE?AVQString@@XZ @ 12899 NONAME ; class QString QFont::lastResortFont(void) const + ??0QApplicationPrivate@@QAE@AAHPAPADW4Type@QApplication@@H@Z @ 12900 NONAME ; QApplicationPrivate::QApplicationPrivate(int &, char * *, enum QApplication::Type, int) + ??0QBlittable@@QAE@ABVQSize@@V?$QFlags@W4Capability@QBlittable@@@@@Z @ 12901 NONAME ; QBlittable::QBlittable(class QSize const &, class QFlags) + ??0QBlittablePixmapData@@QAE@XZ @ 12902 NONAME ; QBlittablePixmapData::QBlittablePixmapData(void) + ??0QBlitterPaintEngine@@QAE@PAVQBlittablePixmapData@@@Z @ 12903 NONAME ; QBlitterPaintEngine::QBlitterPaintEngine(class QBlittablePixmapData *) + ??0QGlyphs@@QAE@ABV0@@Z @ 12904 NONAME ; QGlyphs::QGlyphs(class QGlyphs const &) + ??0QGlyphs@@QAE@XZ @ 12905 NONAME ; QGlyphs::QGlyphs(void) + ??0QRasterWindowSurface@@QAE@PAVQWidget@@_N@Z @ 12906 NONAME ; QRasterWindowSurface::QRasterWindowSurface(class QWidget *, bool) + ??0QStaticTextItem@@QAE@ABV0@@Z @ 12907 NONAME ; QStaticTextItem::QStaticTextItem(class QStaticTextItem const &) + ??0QWindowSurface@@QAE@PAVQWidget@@_N@Z @ 12908 NONAME ; QWindowSurface::QWindowSurface(class QWidget *, bool) + ??1QBlittable@@UAE@XZ @ 12909 NONAME ; QBlittable::~QBlittable(void) + ??1QBlittablePixmapData@@UAE@XZ @ 12910 NONAME ; QBlittablePixmapData::~QBlittablePixmapData(void) + ??1QBlitterPaintEngine@@UAE@XZ @ 12911 NONAME ; QBlitterPaintEngine::~QBlitterPaintEngine(void) + ??1QGlyphs@@QAE@XZ @ 12912 NONAME ; QGlyphs::~QGlyphs(void) + ??4QGlyphs@@QAEAAV0@ABV0@@Z @ 12913 NONAME ; class QGlyphs & QGlyphs::operator=(class QGlyphs const &) + ??4QStaticTextItem@@QAEXABV0@@Z @ 12914 NONAME ; void QStaticTextItem::operator=(class QStaticTextItem const &) + ??6@YA?AVQDebug@@V0@PBVQSymbianEvent@@@Z @ 12915 NONAME ; class QDebug operator<<(class QDebug, class QSymbianEvent const *) + ??8QGlyphs@@QBE_NABV0@@Z @ 12916 NONAME ; bool QGlyphs::operator==(class QGlyphs const &) const + ??9QGlyphs@@QBE_NABV0@@Z @ 12917 NONAME ; bool QGlyphs::operator!=(class QGlyphs const &) const + ??HQGlyphs@@ABE?AV0@ABV0@@Z @ 12918 NONAME ; class QGlyphs QGlyphs::operator+(class QGlyphs const &) const + ??MQItemSelectionRange@@QBE_NABV0@@Z @ 12919 NONAME ; bool QItemSelectionRange::operator<(class QItemSelectionRange const &) const + ??YQGlyphs@@AAEAAV0@ABV0@@Z @ 12920 NONAME ; class QGlyphs & QGlyphs::operator+=(class QGlyphs const &) + ??_EQBlittable@@UAE@I@Z @ 12921 NONAME ; QBlittable::~QBlittable(unsigned int) + ??_EQBlittablePixmapData@@UAE@I@Z @ 12922 NONAME ; QBlittablePixmapData::~QBlittablePixmapData(unsigned int) + ??_EQBlitterPaintEngine@@UAE@I@Z @ 12923 NONAME ; QBlitterPaintEngine::~QBlitterPaintEngine(unsigned int) + ?alphaMapBoundingBox@QFontEngine@@UAE?AUglyph_metrics_t@@IABVQTransform@@W4GlyphFormat@1@@Z @ 12924 NONAME ; struct glyph_metrics_t QFontEngine::alphaMapBoundingBox(unsigned int, class QTransform const &, enum QFontEngine::GlyphFormat) + ?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@IUQFixed@@@Z @ 12925 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int, struct QFixed) + ?alphaMapForGlyph@QFontEngine@@UAE?AVQImage@@IUQFixed@@ABVQTransform@@@Z @ 12926 NONAME ; class QImage QFontEngine::alphaMapForGlyph(unsigned int, struct QFixed, class QTransform const &) + ?alphaRGBMapForGlyph@QFontEngine@@UAE?AVQImage@@IUQFixed@@HABVQTransform@@@Z @ 12927 NONAME ; class QImage QFontEngine::alphaRGBMapForGlyph(unsigned int, struct QFixed, int, class QTransform const &) + ?begin@QBlitterPaintEngine@@UAE_NPAVQPaintDevice@@@Z @ 12928 NONAME ; bool QBlitterPaintEngine::begin(class QPaintDevice *) + ?blittable@QBlittablePixmapData@@QBEPAVQBlittable@@XZ @ 12929 NONAME ; class QBlittable * QBlittablePixmapData::blittable(void) const + ?brushChanged@QBlitterPaintEngine@@UAEXXZ @ 12930 NONAME ; void QBlitterPaintEngine::brushChanged(void) + ?brushOriginChanged@QBlitterPaintEngine@@UAEXXZ @ 12931 NONAME ; void QBlitterPaintEngine::brushOriginChanged(void) + ?buddy@QAbstractProxyModel@@UBE?AVQModelIndex@@ABV2@@Z @ 12932 NONAME ; class QModelIndex QAbstractProxyModel::buddy(class QModelIndex const &) const + ?buffer@QBlittablePixmapData@@UAEPAVQImage@@XZ @ 12933 NONAME ; class QImage * QBlittablePixmapData::buffer(void) + ?calculateSubPixelPositionCount@QTextureGlyphCache@@IBEHI@Z @ 12934 NONAME ; int QTextureGlyphCache::calculateSubPixelPositionCount(unsigned int) const + ?canFetchMore@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 12935 NONAME ; bool QAbstractProxyModel::canFetchMore(class QModelIndex const &) const + ?capabilities@QBlittable@@QBE?AV?$QFlags@W4Capability@QBlittable@@@@XZ @ 12936 NONAME ; class QFlags QBlittable::capabilities(void) const + ?clear@QGlyphs@@QAEXXZ @ 12937 NONAME ; void QGlyphs::clear(void) + ?clip@QBlitterPaintEngine@@QAEPBVQClipData@@XZ @ 12938 NONAME ; class QClipData const * QBlitterPaintEngine::clip(void) + ?clip@QBlitterPaintEngine@@UAEXABVQRect@@W4ClipOperation@Qt@@@Z @ 12939 NONAME ; void QBlitterPaintEngine::clip(class QRect const &, enum Qt::ClipOperation) + ?clip@QBlitterPaintEngine@@UAEXABVQRegion@@W4ClipOperation@Qt@@@Z @ 12940 NONAME ; void QBlitterPaintEngine::clip(class QRegion const &, enum Qt::ClipOperation) + ?clip@QBlitterPaintEngine@@UAEXABVQVectorPath@@W4ClipOperation@Qt@@@Z @ 12941 NONAME ; void QBlitterPaintEngine::clip(class QVectorPath const &, enum Qt::ClipOperation) + ?clipBoundingRect@QPainter@@QBE?AVQRectF@@XZ @ 12942 NONAME ; class QRectF QPainter::clipBoundingRect(void) const + ?clipEnabledChanged@QBlitterPaintEngine@@UAEXXZ @ 12943 NONAME ; void QBlitterPaintEngine::clipEnabledChanged(void) + ?compositionModeChanged@QBlitterPaintEngine@@UAEXXZ @ 12944 NONAME ; void QBlitterPaintEngine::compositionModeChanged(void) + ?createExplicitFont@QFontEngine@@UBE?AVQFont@@XZ @ 12945 NONAME ; class QFont QFontEngine::createExplicitFont(void) const + ?createExplicitFontWithName@QFontEngine@@IBE?AVQFont@@ABVQString@@@Z @ 12946 NONAME ; class QFont QFontEngine::createExplicitFontWithName(class QString const &) const + ?createState@QBlitterPaintEngine@@UBEPAVQPainterState@@PAV2@@Z @ 12947 NONAME ; class QPainterState * QBlitterPaintEngine::createState(class QPainterState *) const + ?d_func@QBlittable@@AAEPAVQBlittablePrivate@@XZ @ 12948 NONAME ; class QBlittablePrivate * QBlittable::d_func(void) + ?d_func@QBlittable@@ABEPBVQBlittablePrivate@@XZ @ 12949 NONAME ; class QBlittablePrivate const * QBlittable::d_func(void) const + ?d_func@QBlitterPaintEngine@@AAEPAVQBlitterPaintEnginePrivate@@XZ @ 12950 NONAME ; class QBlitterPaintEnginePrivate * QBlitterPaintEngine::d_func(void) + ?d_func@QBlitterPaintEngine@@ABEPBVQBlitterPaintEnginePrivate@@XZ @ 12951 NONAME ; class QBlitterPaintEnginePrivate const * QBlitterPaintEngine::d_func(void) const + ?detach@QGlyphs@@AAEXXZ @ 12952 NONAME ; void QGlyphs::detach(void) + ?drawEllipse@QBlitterPaintEngine@@UAEXABVQRectF@@@Z @ 12953 NONAME ; void QBlitterPaintEngine::drawEllipse(class QRectF const &) + ?drawGlyphs@QPainter@@QAEXABVQPointF@@ABVQGlyphs@@@Z @ 12954 NONAME ; void QPainter::drawGlyphs(class QPointF const &, class QGlyphs const &) + ?drawImage@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQImage@@0V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 12955 NONAME ; void QBlitterPaintEngine::drawImage(class QRectF const &, class QImage const &, class QRectF const &, class QFlags) + ?drawPixmap@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQPixmap@@0@Z @ 12956 NONAME ; void QBlitterPaintEngine::drawPixmap(class QRectF const &, class QPixmap const &, class QRectF const &) + ?drawRects@QBlitterPaintEngine@@UAEXPBVQRect@@H@Z @ 12957 NONAME ; void QBlitterPaintEngine::drawRects(class QRect const *, int) + ?drawRects@QBlitterPaintEngine@@UAEXPBVQRectF@@H@Z @ 12958 NONAME ; void QBlitterPaintEngine::drawRects(class QRectF const *, int) + ?drawStaticTextItem@QBlitterPaintEngine@@UAEXPAVQStaticTextItem@@@Z @ 12959 NONAME ; void QBlitterPaintEngine::drawStaticTextItem(class QStaticTextItem *) + ?drawTextItem@QBlitterPaintEngine@@UAEXABVQPointF@@ABVQTextItem@@@Z @ 12960 NONAME ; void QBlitterPaintEngine::drawTextItem(class QPointF const &, class QTextItem const &) + ?end@QBlitterPaintEngine@@UAE_NXZ @ 12961 NONAME ; bool QBlitterPaintEngine::end(void) + ?fetchMore@QAbstractProxyModel@@UAEXABVQModelIndex@@@Z @ 12962 NONAME ; void QAbstractProxyModel::fetchMore(class QModelIndex const &) + ?fill@QBlittablePixmapData@@UAEXABVQColor@@@Z @ 12963 NONAME ; void QBlittablePixmapData::fill(class QColor const &) + ?fill@QBlitterPaintEngine@@UAEXABVQVectorPath@@ABVQBrush@@@Z @ 12964 NONAME ; void QBlitterPaintEngine::fill(class QVectorPath const &, class QBrush const &) + ?fill@QImage@@QAEXABVQColor@@@Z @ 12965 NONAME ; void QImage::fill(class QColor const &) + ?fill@QImage@@QAEXW4GlobalColor@Qt@@@Z @ 12966 NONAME ; void QImage::fill(enum Qt::GlobalColor) + ?fillInPendingGlyphs@QTextureGlyphCache@@QAEXXZ @ 12967 NONAME ; void QTextureGlyphCache::fillInPendingGlyphs(void) + ?fillRect@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQBrush@@@Z @ 12968 NONAME ; void QBlitterPaintEngine::fillRect(class QRectF const &, class QBrush const &) + ?fillRect@QBlitterPaintEngine@@UAEXABVQRectF@@ABVQColor@@@Z @ 12969 NONAME ; void QBlitterPaintEngine::fillRect(class QRectF const &, class QColor const &) + ?fillTexture@QImageTextureGlyphCache@@UAEXABUCoord@QTextureGlyphCache@@IUQFixed@@@Z @ 12970 NONAME ; void QImageTextureGlyphCache::fillTexture(struct QTextureGlyphCache::Coord const &, unsigned int, struct QFixed) + ?font@QGlyphs@@QBE?AVQFont@@XZ @ 12971 NONAME ; class QFont QGlyphs::font(void) const + ?fontEngine@QStaticTextItem@@QBEPAVQFontEngine@@XZ @ 12972 NONAME ; class QFontEngine * QStaticTextItem::fontEngine(void) const + ?fromImage@QBlittablePixmapData@@UAEXABVQImage@@V?$QFlags@W4ImageConversionFlag@Qt@@@@@Z @ 12973 NONAME ; void QBlittablePixmapData::fromImage(class QImage const &, class QFlags) + ?get@QFontPrivate@@SAPAV1@ABVQFont@@@Z @ 12974 NONAME ; class QFontPrivate * QFontPrivate::get(class QFont const &) + ?getItem@QInputDialog@@SA?AVQString@@PAVQWidget@@ABV2@1ABVQStringList@@H_NPA_NV?$QFlags@W4WindowType@Qt@@@@V?$QFlags@W4InputMethodHint@Qt@@@@@Z @ 12975 NONAME ; class QString QInputDialog::getItem(class QWidget *, class QString const &, class QString const &, class QStringList const &, int, bool, bool *, class QFlags, class QFlags) + ?getText@QInputDialog@@SA?AVQString@@PAVQWidget@@ABV2@1W4EchoMode@QLineEdit@@1PA_NV?$QFlags@W4WindowType@Qt@@@@V?$QFlags@W4InputMethodHint@Qt@@@@@Z @ 12976 NONAME ; class QString QInputDialog::getText(class QWidget *, class QString const &, class QString const &, enum QLineEdit::EchoMode, class QString const &, bool *, class QFlags, class QFlags) + ?glyphIndexes@QGlyphs@@QBE?AV?$QVector@I@@XZ @ 12977 NONAME ; class QVector QGlyphs::glyphIndexes(void) const + ?glyphs@QTextFragment@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 12978 NONAME ; class QList QTextFragment::glyphs(void) const + ?glyphs@QTextLayout@@QBE?AV?$QList@VQGlyphs@@@@XZ @ 12979 NONAME ; class QList QTextLayout::glyphs(void) const + ?glyphs@QTextLine@@ABE?AV?$QList@VQGlyphs@@@@HH@Z @ 12980 NONAME ; class QList QTextLine::glyphs(int, int) const + ?hasAlphaChannel@QBlittablePixmapData@@UBE_NXZ @ 12981 NONAME ; bool QBlittablePixmapData::hasAlphaChannel(void) const + ?hasChildren@QAbstractProxyModel@@UBE_NABVQModelIndex@@@Z @ 12982 NONAME ; bool QAbstractProxyModel::hasChildren(class QModelIndex const &) const + ?hasHeightForWidth@QWidgetPrivate@@UBE_NXZ @ 12983 NONAME ; bool QWidgetPrivate::hasHeightForWidth(void) const + ?hasWidthForHeight@QSizePolicy@@QBE_NXZ @ 12984 NONAME ; bool QSizePolicy::hasWidthForHeight(void) const + ?heightForWidth@QTabWidget@@UBEHH@Z @ 12985 NONAME ; int QTabWidget::heightForWidth(int) const + ?inFontUcs4@QFontMetrics@@QBE_NI@Z @ 12986 NONAME ; bool QFontMetrics::inFontUcs4(unsigned int) const + ?inFontUcs4@QFontMetricsF@@QBE_NI@Z @ 12987 NONAME ; bool QFontMetricsF::inFontUcs4(unsigned int) const + ?lock@QBlittable@@QAEPAVQImage@@XZ @ 12988 NONAME ; class QImage * QBlittable::lock(void) + ?markRasterOverlay@QBlittablePixmapData@@QAEXABVQPointF@@ABVQTextItem@@@Z @ 12989 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QPointF const &, class QTextItem const &) + ?markRasterOverlay@QBlittablePixmapData@@QAEXABVQRectF@@@Z @ 12990 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QRectF const &) + ?markRasterOverlay@QBlittablePixmapData@@QAEXABVQVectorPath@@@Z @ 12991 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QVectorPath const &) + ?markRasterOverlay@QBlittablePixmapData@@QAEXPBVQRect@@H@Z @ 12992 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QRect const *, int) + ?markRasterOverlay@QBlittablePixmapData@@QAEXPBVQRectF@@H@Z @ 12993 NONAME ; void QBlittablePixmapData::markRasterOverlay(class QRectF const *, int) + ?metric@QBlittablePixmapData@@UBEHW4PaintDeviceMetric@QPaintDevice@@@Z @ 12994 NONAME ; int QBlittablePixmapData::metric(enum QPaintDevice::PaintDeviceMetric) const + ?mimeData@QAbstractProxyModel@@UBEPAVQMimeData@@ABV?$QList@VQModelIndex@@@@@Z @ 12995 NONAME ; class QMimeData * QAbstractProxyModel::mimeData(class QList const &) const + ?mimeTypes@QAbstractProxyModel@@UBE?AVQStringList@@XZ @ 12996 NONAME ; class QStringList QAbstractProxyModel::mimeTypes(void) const + ?minimumSizeHint@QCheckBox@@UBE?AVQSize@@XZ @ 12997 NONAME ; class QSize QCheckBox::minimumSizeHint(void) const + ?minimumSizeHint@QRadioButton@@UBE?AVQSize@@XZ @ 12998 NONAME ; class QSize QRadioButton::minimumSizeHint(void) const + ?numberPrefix@QTextListFormat@@QBE?AVQString@@XZ @ 12999 NONAME ; class QString QTextListFormat::numberPrefix(void) const + ?numberSuffix@QTextListFormat@@QBE?AVQString@@XZ @ 13000 NONAME ; class QString QTextListFormat::numberSuffix(void) const + ?opacityChanged@QBlitterPaintEngine@@UAEXXZ @ 13001 NONAME ; void QBlitterPaintEngine::opacityChanged(void) + ?paintEngine@QBlittablePixmapData@@UBEPAVQPaintEngine@@XZ @ 13002 NONAME ; class QPaintEngine * QBlittablePixmapData::paintEngine(void) const + ?penChanged@QBlitterPaintEngine@@UAEXXZ @ 13003 NONAME ; void QBlitterPaintEngine::penChanged(void) + ?positions@QGlyphs@@QBE?AV?$QVector@VQPointF@@@@XZ @ 13004 NONAME ; class QVector QGlyphs::positions(void) const + ?qt_addBitmapToPath@@YAXMMPBEHHHPAVQPainterPath@@@Z @ 13005 NONAME ; void qt_addBitmapToPath(float, float, unsigned char const *, int, int, int, class QPainterPath *) + ?qt_fontdata_from_index@@YA?AVQByteArray@@H@Z @ 13006 NONAME ; class QByteArray qt_fontdata_from_index(int) + ?raster@QBlitterPaintEngine@@ABEPAVQRasterPaintEngine@@XZ @ 13007 NONAME ; class QRasterPaintEngine * QBlitterPaintEngine::raster(void) const + ?reactivateDeferredActiveObjects@QEventDispatcherS60@@UAEXXZ @ 13008 NONAME ; void QEventDispatcherS60::reactivateDeferredActiveObjects(void) + ?removeItem@QGraphicsGridLayout@@QAEXPAVQGraphicsLayoutItem@@@Z @ 13009 NONAME ; void QGraphicsGridLayout::removeItem(class QGraphicsLayoutItem *) + ?renderHintsChanged@QBlitterPaintEngine@@UAEXXZ @ 13010 NONAME ; void QBlitterPaintEngine::renderHintsChanged(void) + ?resetInternalData@QAbstractProxyModel@@IAEXXZ @ 13011 NONAME ; void QAbstractProxyModel::resetInternalData(void) + ?resize@QBlittablePixmapData@@UAEXHH@Z @ 13012 NONAME ; void QBlittablePixmapData::resize(int, int) + ?resizeCache@QTextureGlyphCache@@QAEXHH@Z @ 13013 NONAME ; void QTextureGlyphCache::resizeCache(int, int) + ?setBlittable@QBlittablePixmapData@@QAEXPAVQBlittable@@@Z @ 13014 NONAME ; void QBlittablePixmapData::setBlittable(class QBlittable *) + ?setFont@QGlyphs@@QAEXABVQFont@@@Z @ 13015 NONAME ; void QGlyphs::setFont(class QFont const &) + ?setFontEngine@QStaticTextItem@@QAEXPAVQFontEngine@@@Z @ 13016 NONAME ; void QStaticTextItem::setFontEngine(class QFontEngine *) + ?setGlyphIndexes@QGlyphs@@QAEXABV?$QVector@I@@@Z @ 13017 NONAME ; void QGlyphs::setGlyphIndexes(class QVector const &) + ?setItemData@QAbstractProxyModel@@UAE_NABVQModelIndex@@ABV?$QMap@HVQVariant@@@@@Z @ 13018 NONAME ; bool QAbstractProxyModel::setItemData(class QModelIndex const &, class QMap const &) + ?setNumberPrefix@QTextListFormat@@QAEXABVQString@@@Z @ 13019 NONAME ; void QTextListFormat::setNumberPrefix(class QString const &) + ?setNumberSuffix@QTextListFormat@@QAEXABVQString@@@Z @ 13020 NONAME ; void QTextListFormat::setNumberSuffix(class QString const &) + ?setPositions@QGlyphs@@QAEXABV?$QVector@VQPointF@@@@@Z @ 13021 NONAME ; void QGlyphs::setPositions(class QVector const &) + ?setState@QBlitterPaintEngine@@UAEXPAVQPainterState@@@Z @ 13022 NONAME ; void QBlitterPaintEngine::setState(class QPainterState *) + ?setWidthForHeight@QSizePolicy@@QAEX_N@Z @ 13023 NONAME ; void QSizePolicy::setWidthForHeight(bool) + ?size@QBlittable@@QBE?AVQSize@@XZ @ 13024 NONAME ; class QSize QBlittable::size(void) const + ?sort@QAbstractProxyModel@@UAEXHW4SortOrder@Qt@@@Z @ 13025 NONAME ; void QAbstractProxyModel::sort(int, enum Qt::SortOrder) + ?span@QAbstractProxyModel@@UBE?AVQSize@@ABVQModelIndex@@@Z @ 13026 NONAME ; class QSize QAbstractProxyModel::span(class QModelIndex const &) const + ?state@QBlitterPaintEngine@@QAEPAVQPainterState@@XZ @ 13027 NONAME ; class QPainterState * QBlitterPaintEngine::state(void) + ?state@QBlitterPaintEngine@@QBEPBVQPainterState@@XZ @ 13028 NONAME ; class QPainterState const * QBlitterPaintEngine::state(void) const + ?stroke@QBlitterPaintEngine@@UAEXABVQVectorPath@@ABVQPen@@@Z @ 13029 NONAME ; void QBlitterPaintEngine::stroke(class QVectorPath const &, class QPen const &) + ?subPixelPositionForX@QTextureGlyphCache@@QBE?AUQFixed@@U2@@Z @ 13030 NONAME ; struct QFixed QTextureGlyphCache::subPixelPositionForX(struct QFixed) const + ?supportedDropActions@QAbstractProxyModel@@UBE?AV?$QFlags@W4DropAction@Qt@@@@XZ @ 13031 NONAME ; class QFlags QAbstractProxyModel::supportedDropActions(void) const + ?supportsSubPixelPositions@QFontEngine@@UBE_NXZ @ 13032 NONAME ; bool QFontEngine::supportsSubPixelPositions(void) const + ?swap@QBitmap@@QAEXAAV1@@Z @ 13033 NONAME ; void QBitmap::swap(class QBitmap &) + ?swap@QBrush@@QAEXAAV1@@Z @ 13034 NONAME ; void QBrush::swap(class QBrush &) + ?swap@QIcon@@QAEXAAV1@@Z @ 13035 NONAME ; void QIcon::swap(class QIcon &) + ?swap@QImage@@QAEXAAV1@@Z @ 13036 NONAME ; void QImage::swap(class QImage &) + ?swap@QKeySequence@@QAEXAAV1@@Z @ 13037 NONAME ; void QKeySequence::swap(class QKeySequence &) + ?swap@QPainterPath@@QAEXAAV1@@Z @ 13038 NONAME ; void QPainterPath::swap(class QPainterPath &) + ?swap@QPen@@QAEXAAV1@@Z @ 13039 NONAME ; void QPen::swap(class QPen &) + ?swap@QPicture@@QAEXAAV1@@Z @ 13040 NONAME ; void QPicture::swap(class QPicture &) + ?swap@QPixmap@@QAEXAAV1@@Z @ 13041 NONAME ; void QPixmap::swap(class QPixmap &) + ?swap@QPolygon@@QAEXAAV1@@Z @ 13042 NONAME ; void QPolygon::swap(class QPolygon &) + ?swap@QPolygonF@@QAEXAAV1@@Z @ 13043 NONAME ; void QPolygonF::swap(class QPolygonF &) + ?swap@QRegion@@QAEXAAV1@@Z @ 13044 NONAME ; void QRegion::swap(class QRegion &) + ?textureMapForGlyph@QTextureGlyphCache@@QBE?AVQImage@@IUQFixed@@@Z @ 13045 NONAME ; class QImage QTextureGlyphCache::textureMapForGlyph(unsigned int, struct QFixed) const + ?toImage@QBlittablePixmapData@@UBE?AVQImage@@XZ @ 13046 NONAME ; class QImage QBlittablePixmapData::toImage(void) const + ?transformChanged@QBlitterPaintEngine@@UAEXXZ @ 13047 NONAME ; void QBlitterPaintEngine::transformChanged(void) + ?type@QBlitterPaintEngine@@UBE?AW4Type@QPaintEngine@@XZ @ 13048 NONAME ; enum QPaintEngine::Type QBlitterPaintEngine::type(void) const + ?unlock@QBlittable@@QAEXXZ @ 13049 NONAME ; void QBlittable::unlock(void) + ?unmarkRasterOverlay@QBlittablePixmapData@@QAEXABVQRectF@@@Z @ 13050 NONAME ; void QBlittablePixmapData::unmarkRasterOverlay(class QRectF const &) + ?userData@QStaticTextItem@@QBEPAVQStaticTextUserData@@XZ @ 13051 NONAME ; class QStaticTextUserData * QStaticTextItem::userData(void) const diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 3864914..5939010 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3714,4 +3714,84 @@ EXPORTS _Z26qt_symbian_SetupThreadHeapiR24SStdEpocThreadCreateInfo @ 3713 NONAME _ZN24QAbstractDeclarativeData17objectNameChangedE @ 3714 NONAME DATA 4 _ZN23QEventDispatcherSymbian36queueDeferredActiveObjectsCompletionEv @ 3715 NONAME + _ZN11QThreadPool11waitForDoneEi @ 3716 NONAME + _ZN12QSystemError8toStringEv @ 3717 NONAME + _ZN13QSharedMemory12setNativeKeyERK7QString @ 3718 NONAME + _ZN13QUnifiedTimer10timerEventEP11QTimerEvent @ 3719 NONAME + _ZN13QUnifiedTimer17ensureTimerUpdateEv @ 3720 NONAME + _ZN13QUnifiedTimer17registerAnimationEP18QAbstractAnimationb @ 3721 NONAME + _ZN13QUnifiedTimer17setTimingIntervalEi @ 3722 NONAME + _ZN13QUnifiedTimer19unregisterAnimationEP18QAbstractAnimation @ 3723 NONAME + _ZN13QUnifiedTimer20updateAnimationTimerEv @ 3724 NONAME + _ZN13QUnifiedTimer20updateAnimationsTimeEv @ 3725 NONAME + _ZN13QUnifiedTimer21restartAnimationTimerEv @ 3726 NONAME + _ZN13QUnifiedTimer22installAnimationDriverEP16QAnimationDriver @ 3727 NONAME + _ZN13QUnifiedTimer24registerRunningAnimationEP18QAbstractAnimation @ 3728 NONAME + _ZN13QUnifiedTimer26unregisterRunningAnimationEP18QAbstractAnimation @ 3729 NONAME + _ZN13QUnifiedTimer33closestPauseAnimationTimeToFinishEv @ 3730 NONAME + _ZN13QUnifiedTimer8instanceEb @ 3731 NONAME + _ZN13QUnifiedTimerC1Ev @ 3732 NONAME + _ZN13QUnifiedTimerC2Ev @ 3733 NONAME + _ZN16QAnimationDriver11qt_metacallEN11QMetaObject4CallEiPPv @ 3734 NONAME + _ZN16QAnimationDriver11qt_metacastEPKc @ 3735 NONAME + _ZN16QAnimationDriver16staticMetaObjectE @ 3736 NONAME DATA 16 + _ZN16QAnimationDriver19getStaticMetaObjectEv @ 3737 NONAME + _ZN16QAnimationDriver4stopEv @ 3738 NONAME + _ZN16QAnimationDriver5startEv @ 3739 NONAME + _ZN16QAnimationDriver7advanceEv @ 3740 NONAME + _ZN16QAnimationDriver7installEv @ 3741 NONAME + _ZN16QAnimationDriverC2EP7QObject @ 3742 NONAME + _ZN16QAnimationDriverC2ER23QAnimationDriverPrivateP7QObject @ 3743 NONAME + _ZN16QCoreApplicationC1ERiPPci @ 3744 NONAME + _ZN16QCoreApplicationC2ERiPPci @ 3745 NONAME + _ZN23QCoreApplicationPrivate19app_compile_versionE @ 3746 NONAME DATA 4 + _ZN23QCoreApplicationPrivateC1ERiPPcj @ 3747 NONAME + _ZN23QCoreApplicationPrivateC2ERiPPcj @ 3748 NONAME + _ZN6QMutex12lockInternalEv @ 3749 NONAME + _ZN6QMutex14unlockInternalEv @ 3750 NONAME + _ZN7QObject10disconnectEPKS_RK11QMetaMethodS1_S4_ @ 3751 NONAME + _ZN7QObject7connectEPKS_RK11QMetaMethodS1_S4_N2Qt14ConnectionTypeE @ 3752 NONAME + _ZN9QFileInfoC1EP16QFileInfoPrivate @ 3753 NONAME + _ZN9QFileInfoC2EP16QFileInfoPrivate @ 3754 NONAME + _ZNK10QStringRef10startsWithE13QLatin1StringN2Qt15CaseSensitivityE @ 3755 NONAME + _ZNK10QStringRef10startsWithE5QCharN2Qt15CaseSensitivityE @ 3756 NONAME + _ZNK10QStringRef10startsWithERK7QStringN2Qt15CaseSensitivityE @ 3757 NONAME + _ZNK10QStringRef10startsWithERKS_N2Qt15CaseSensitivityE @ 3758 NONAME + _ZNK10QStringRef11lastIndexOfE13QLatin1StringiN2Qt15CaseSensitivityE @ 3759 NONAME + _ZNK10QStringRef11lastIndexOfE5QChariN2Qt15CaseSensitivityE @ 3760 NONAME + _ZNK10QStringRef11lastIndexOfERK7QStringiN2Qt15CaseSensitivityE @ 3761 NONAME + _ZNK10QStringRef11lastIndexOfERKS_iN2Qt15CaseSensitivityE @ 3762 NONAME + _ZNK10QStringRef11toLocal8BitEv @ 3763 NONAME + _ZNK10QStringRef5countE5QCharN2Qt15CaseSensitivityE @ 3764 NONAME + _ZNK10QStringRef5countERK7QStringN2Qt15CaseSensitivityE @ 3765 NONAME + _ZNK10QStringRef5countERKS_N2Qt15CaseSensitivityE @ 3766 NONAME + _ZNK10QStringRef6toUcs4Ev @ 3767 NONAME + _ZNK10QStringRef6toUtf8Ev @ 3768 NONAME + _ZNK10QStringRef7indexOfE13QLatin1StringiN2Qt15CaseSensitivityE @ 3769 NONAME + _ZNK10QStringRef7indexOfE5QChariN2Qt15CaseSensitivityE @ 3770 NONAME + _ZNK10QStringRef7indexOfERK7QStringiN2Qt15CaseSensitivityE @ 3771 NONAME + _ZNK10QStringRef7indexOfERKS_iN2Qt15CaseSensitivityE @ 3772 NONAME + _ZNK10QStringRef7toAsciiEv @ 3773 NONAME + _ZNK10QStringRef8endsWithE13QLatin1StringN2Qt15CaseSensitivityE @ 3774 NONAME + _ZNK10QStringRef8endsWithE5QCharN2Qt15CaseSensitivityE @ 3775 NONAME + _ZNK10QStringRef8endsWithERK7QStringN2Qt15CaseSensitivityE @ 3776 NONAME + _ZNK10QStringRef8endsWithERKS_N2Qt15CaseSensitivityE @ 3777 NONAME + _ZNK10QStringRef8toLatin1Ev @ 3778 NONAME + _ZNK11QMetaObject4castEPK7QObject @ 3779 NONAME + _ZNK13QSharedMemory9nativeKeyEv @ 3780 NONAME + _ZNK16QAnimationDriver10metaObjectEv @ 3781 NONAME + _ZNK16QAnimationDriver9isRunningEv @ 3782 NONAME + _ZNK4QUrl11isLocalFileEv @ 3783 NONAME + _ZNK7QObject17senderSignalIndexEv @ 3784 NONAME + _ZNK7QString10startsWithERK10QStringRefN2Qt15CaseSensitivityE @ 3785 NONAME + _ZNK7QString11lastIndexOfERK10QStringRefiN2Qt15CaseSensitivityE @ 3786 NONAME + _ZNK7QString5countERK10QStringRefN2Qt15CaseSensitivityE @ 3787 NONAME + _ZNK7QString7indexOfERK10QStringRefiN2Qt15CaseSensitivityE @ 3788 NONAME + _ZNK7QString8endsWithERK10QStringRefN2Qt15CaseSensitivityE @ 3789 NONAME + _ZTI13QUnifiedTimer @ 3790 NONAME + _ZTI16QAnimationDriver @ 3791 NONAME + _ZTI23QAnimationDriverPrivate @ 3792 NONAME + _ZTV13QUnifiedTimer @ 3793 NONAME + _ZTV16QAnimationDriver @ 3794 NONAME + _ZTV23QAnimationDriverPrivate @ 3795 NONAME diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index 1f69061..b0efab4 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -1747,8 +1747,8 @@ EXPORTS _ZN21QDeclarativeListModelC1EPKS_P32QDeclarativeListModelWorkerAgent @ 1746 NONAME ABSENT _ZN21QDeclarativeListModelC2EPKS_P32QDeclarativeListModelWorkerAgent @ 1747 NONAME ABSENT _ZNK21QDeclarativeListModel14inWorkerThreadEv @ 1748 NONAME ABSENT - _ZN23QDeclarativeDebugHelper15getScriptEngineEP18QDeclarativeEngine @ 1749 NONAME ABSENT - _ZN23QDeclarativeDebugHelper26setAnimationSlowDownFactorEf @ 1750 NONAME ABSENT + _ZN23QDeclarativeDebugHelper15getScriptEngineEP18QDeclarativeEngine @ 1749 NONAME + _ZN23QDeclarativeDebugHelper26setAnimationSlowDownFactorEf @ 1750 NONAME _ZN17QDeclarativeTimer10classBeginEv @ 1751 NONAME ABSENT _ZN17QDeclarativeTimer10setRunningEb @ 1752 NONAME ABSENT _ZN17QDeclarativeTimer11qt_metacallEN11QMetaObject4CallEiPPv @ 1753 NONAME ABSENT diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index e2aec1d..d6fbdd3 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -3168,7 +3168,7 @@ EXPORTS _ZN14QWindowSurface6bufferEPK7QWidget @ 3167 NONAME _ZN14QWindowSurface6scrollERK7QRegionii @ 3168 NONAME _ZN14QWindowSurface8endPaintERK7QRegion @ 3169 NONAME - _ZN14QWindowSurfaceC2EP7QWidget @ 3170 NONAME + _ZN14QWindowSurfaceC2EP7QWidget @ 3170 NONAME ABSENT _ZN14QWindowSurfaceD0Ev @ 3171 NONAME _ZN14QWindowSurfaceD1Ev @ 3172 NONAME _ZN14QWindowSurfaceD2Ev @ 3173 NONAME @@ -4768,8 +4768,8 @@ EXPORTS _ZN20QRasterWindowSurface13prepareBufferEN6QImage6FormatEP7QWidget @ 4767 NONAME _ZN20QRasterWindowSurface5flushEP7QWidgetRK7QRegionRK6QPoint @ 4768 NONAME _ZN20QRasterWindowSurface6scrollERK7QRegionii @ 4769 NONAME - _ZN20QRasterWindowSurfaceC1EP7QWidget @ 4770 NONAME - _ZN20QRasterWindowSurfaceC2EP7QWidget @ 4771 NONAME + _ZN20QRasterWindowSurfaceC1EP7QWidget @ 4770 NONAME ABSENT + _ZN20QRasterWindowSurfaceC2EP7QWidget @ 4771 NONAME ABSENT _ZN20QRasterWindowSurfaceD0Ev @ 4772 NONAME _ZN20QRasterWindowSurfaceD1Ev @ 4773 NONAME _ZN20QRasterWindowSurfaceD2Ev @ 4774 NONAME @@ -12105,4 +12105,128 @@ EXPORTS _ZN15QStaticTextItemD1Ev @ 12104 NONAME _ZN15QStaticTextItemD2Ev @ 12105 NONAME _ZN19QEventDispatcherS6031reactivateDeferredActiveObjectsEv @ 12106 NONAME + _Z18qt_addBitmapToPathffPKhiiiP12QPainterPath @ 12107 NONAME + _Z22qt_fontdata_from_indexi @ 12108 NONAME + _ZN10QBlittable4lockEv @ 12109 NONAME + _ZN10QBlittable6unlockEv @ 12110 NONAME + _ZN10QBlittableC2ERK5QSize6QFlagsINS_10CapabilityEE @ 12111 NONAME + _ZN10QBlittableD0Ev @ 12112 NONAME + _ZN10QBlittableD1Ev @ 12113 NONAME + _ZN10QBlittableD2Ev @ 12114 NONAME + _ZN11QFontEngine16alphaMapForGlyphEj6QFixed @ 12115 NONAME + _ZN11QFontEngine16alphaMapForGlyphEj6QFixedRK10QTransform @ 12116 NONAME + _ZN11QFontEngine19alphaRGBMapForGlyphEj6QFixediRK10QTransform @ 12117 NONAME + _ZN12QInputDialog7getItemEP7QWidgetRK7QStringS4_RK11QStringListibPb6QFlagsIN2Qt10WindowTypeEES9_INSA_15InputMethodHintEE @ 12118 NONAME + _ZN12QInputDialog7getTextEP7QWidgetRK7QStringS4_N9QLineEdit8EchoModeES4_Pb6QFlagsIN2Qt10WindowTypeEES8_INS9_15InputMethodHintEE @ 12119 NONAME + _ZN14QWindowSurfaceC2EP7QWidgetb @ 12120 NONAME + _ZN18QTextureGlyphCache19fillInPendingGlyphsEv @ 12121 NONAME + _ZN19QAbstractProxyModel11setItemDataERK11QModelIndexRK4QMapIi8QVariantE @ 12122 NONAME + _ZN19QAbstractProxyModel17resetInternalDataEv @ 12123 NONAME + _ZN19QAbstractProxyModel4sortEiN2Qt9SortOrderE @ 12124 NONAME + _ZN19QAbstractProxyModel9fetchMoreERK11QModelIndex @ 12125 NONAME + _ZN19QApplicationPrivateC1ERiPPcN12QApplication4TypeEi @ 12126 NONAME + _ZN19QApplicationPrivateC2ERiPPcN12QApplication4TypeEi @ 12127 NONAME + _ZN19QBlitterPaintEngine10drawPixmapERK6QRectFRK7QPixmapS2_ @ 12128 NONAME + _ZN19QBlitterPaintEngine10penChangedEv @ 12129 NONAME + _ZN19QBlitterPaintEngine11drawEllipseERK6QRectF @ 12130 NONAME + _ZN19QBlitterPaintEngine12brushChangedEv @ 12131 NONAME + _ZN19QBlitterPaintEngine12drawTextItemERK7QPointFRK9QTextItem @ 12132 NONAME + _ZN19QBlitterPaintEngine14opacityChangedEv @ 12133 NONAME + _ZN19QBlitterPaintEngine16transformChangedEv @ 12134 NONAME + _ZN19QBlitterPaintEngine18brushOriginChangedEv @ 12135 NONAME + _ZN19QBlitterPaintEngine18clipEnabledChangedEv @ 12136 NONAME + _ZN19QBlitterPaintEngine18drawStaticTextItemEP15QStaticTextItem @ 12137 NONAME + _ZN19QBlitterPaintEngine18renderHintsChangedEv @ 12138 NONAME + _ZN19QBlitterPaintEngine22compositionModeChangedEv @ 12139 NONAME + _ZN19QBlitterPaintEngine3endEv @ 12140 NONAME + _ZN19QBlitterPaintEngine4clipERK11QVectorPathN2Qt13ClipOperationE @ 12141 NONAME + _ZN19QBlitterPaintEngine4clipERK5QRectN2Qt13ClipOperationE @ 12142 NONAME + _ZN19QBlitterPaintEngine4clipERK7QRegionN2Qt13ClipOperationE @ 12143 NONAME + _ZN19QBlitterPaintEngine4fillERK11QVectorPathRK6QBrush @ 12144 NONAME + _ZN19QBlitterPaintEngine5beginEP12QPaintDevice @ 12145 NONAME + _ZN19QBlitterPaintEngine6strokeERK11QVectorPathRK4QPen @ 12146 NONAME + _ZN19QBlitterPaintEngine8fillRectERK6QRectFRK6QBrush @ 12147 NONAME + _ZN19QBlitterPaintEngine8fillRectERK6QRectFRK6QColor @ 12148 NONAME + _ZN19QBlitterPaintEngine8setStateEP13QPainterState @ 12149 NONAME + _ZN19QBlitterPaintEngine9drawImageERK6QRectFRK6QImageS2_6QFlagsIN2Qt19ImageConversionFlagEE @ 12150 NONAME + _ZN19QBlitterPaintEngine9drawRectsEPK5QRecti @ 12151 NONAME + _ZN19QBlitterPaintEngine9drawRectsEPK6QRectFi @ 12152 NONAME + _ZN19QBlitterPaintEngineC1EP20QBlittablePixmapData @ 12153 NONAME + _ZN19QBlitterPaintEngineC2EP20QBlittablePixmapData @ 12154 NONAME + _ZN19QBlitterPaintEngineD0Ev @ 12155 NONAME + _ZN19QBlitterPaintEngineD1Ev @ 12156 NONAME + _ZN19QBlitterPaintEngineD2Ev @ 12157 NONAME + _ZN19QGraphicsGridLayout10removeItemEP19QGraphicsLayoutItem @ 12158 NONAME + _ZN20QBlittablePixmapData12setBlittableEP10QBlittable @ 12159 NONAME + _ZN20QBlittablePixmapData4fillERK6QColor @ 12160 NONAME + _ZN20QBlittablePixmapData6bufferEv @ 12161 NONAME + _ZN20QBlittablePixmapData6resizeEii @ 12162 NONAME + _ZN20QBlittablePixmapData9fromImageERK6QImage6QFlagsIN2Qt19ImageConversionFlagEE @ 12163 NONAME + _ZN20QBlittablePixmapDataC2Ev @ 12164 NONAME + _ZN20QBlittablePixmapDataD0Ev @ 12165 NONAME + _ZN20QBlittablePixmapDataD1Ev @ 12166 NONAME + _ZN20QBlittablePixmapDataD2Ev @ 12167 NONAME + _ZN20QRasterWindowSurfaceC1EP7QWidgetb @ 12168 NONAME + _ZN20QRasterWindowSurfaceC2EP7QWidgetb @ 12169 NONAME + _ZN23QImageTextureGlyphCache11fillTextureERKN18QTextureGlyphCache5CoordEj6QFixed @ 12170 NONAME + _ZN6QImage4fillEN2Qt11GlobalColorE @ 12171 NONAME + _ZN6QImage4fillERK6QColor @ 12172 NONAME + _ZN7QGlyphs12setPositionsERK7QVectorI7QPointFE @ 12173 NONAME + _ZN7QGlyphs15setGlyphIndexesERK7QVectorIjE @ 12174 NONAME + _ZN7QGlyphs5clearEv @ 12175 NONAME + _ZN7QGlyphs6detachEv @ 12176 NONAME + _ZN7QGlyphs7setFontERK5QFont @ 12177 NONAME + _ZN7QGlyphsC1ERKS_ @ 12178 NONAME + _ZN7QGlyphsC1Ev @ 12179 NONAME + _ZN7QGlyphsC2ERKS_ @ 12180 NONAME + _ZN7QGlyphsC2Ev @ 12181 NONAME + _ZN7QGlyphsD1Ev @ 12182 NONAME + _ZN7QGlyphsD2Ev @ 12183 NONAME + _ZN7QGlyphsaSERKS_ @ 12184 NONAME + _ZN7QGlyphspLERKS_ @ 12185 NONAME + _ZN8QPainter10drawGlyphsERK7QPointFRK7QGlyphs @ 12186 NONAME + _ZNK10QBlittable12capabilitiesEv @ 12187 NONAME + _ZNK10QBlittable4sizeEv @ 12188 NONAME + _ZNK10QTabWidget14heightForWidthEi @ 12189 NONAME + _ZNK11QFontEngine18createExplicitFontEv @ 12190 NONAME + _ZNK11QFontEngine26createExplicitFontWithNameERK7QString @ 12191 NONAME + _ZNK11QTextLayout6glyphsEv @ 12192 NONAME + _ZNK12QFontMetrics10inFontUcs4Ej @ 12193 NONAME + _ZNK12QRadioButton15minimumSizeHintEv @ 12194 NONAME + _ZNK13QFontMetricsF10inFontUcs4Ej @ 12195 NONAME + _ZNK13QTextFragment6glyphsEv @ 12196 NONAME + _ZNK14QWidgetPrivate17hasHeightForWidthEv @ 12197 NONAME + _ZNK16QFileSystemModel5rmdirERK11QModelIndex @ 12198 NONAME + _ZNK18QTextureGlyphCache18textureMapForGlyphEj6QFixed @ 12199 NONAME + _ZNK18QTextureGlyphCache20subPixelPositionForXE6QFixed @ 12200 NONAME + _ZNK18QTextureGlyphCache30calculateSubPixelPositionCountEj @ 12201 NONAME + _ZNK19QAbstractProxyModel11hasChildrenERK11QModelIndex @ 12202 NONAME + _ZNK19QAbstractProxyModel12canFetchMoreERK11QModelIndex @ 12203 NONAME + _ZNK19QAbstractProxyModel20supportedDropActionsEv @ 12204 NONAME + _ZNK19QAbstractProxyModel4spanERK11QModelIndex @ 12205 NONAME + _ZNK19QAbstractProxyModel5buddyERK11QModelIndex @ 12206 NONAME + _ZNK19QAbstractProxyModel8mimeDataERK5QListI11QModelIndexE @ 12207 NONAME + _ZNK19QAbstractProxyModel9mimeTypesEv @ 12208 NONAME + _ZNK19QBlitterPaintEngine11createStateEP13QPainterState @ 12209 NONAME + _ZNK20QBlittablePixmapData11paintEngineEv @ 12210 NONAME + _ZNK20QBlittablePixmapData15hasAlphaChannelEv @ 12211 NONAME + _ZNK20QBlittablePixmapData6metricEN12QPaintDevice17PaintDeviceMetricE @ 12212 NONAME + _ZNK20QBlittablePixmapData7toImageEv @ 12213 NONAME + _ZNK20QBlittablePixmapData9blittableEv @ 12214 NONAME + _ZNK7QGlyphs12glyphIndexesEv @ 12215 NONAME + _ZNK7QGlyphs4fontEv @ 12216 NONAME + _ZNK7QGlyphs9positionsEv @ 12217 NONAME + _ZNK7QGlyphseqERKS_ @ 12218 NONAME + _ZNK7QGlyphsneERKS_ @ 12219 NONAME + _ZNK7QGlyphsplERKS_ @ 12220 NONAME + _ZNK8QPainter16clipBoundingRectEv @ 12221 NONAME + _ZNK9QCheckBox15minimumSizeHintEv @ 12222 NONAME + _ZNK9QTextLine6glyphsEii @ 12223 NONAME + _ZTI10QBlittable @ 12224 NONAME + _ZTI19QBlitterPaintEngine @ 12225 NONAME + _ZTI20QBlittablePixmapData @ 12226 NONAME + _ZTV10QBlittable @ 12227 NONAME + _ZTV19QBlitterPaintEngine @ 12228 NONAME + _ZTV20QBlittablePixmapData @ 12229 NONAME + _Zls6QDebugPK13QSymbianEvent @ 12230 NONAME -- cgit v0.12 From cd3e03f5e70fa6d973949516f50ea05f201aac20 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 29 Nov 2010 13:55:18 +0000 Subject: Fix buffered/unbuffered mode issues on symbian Due to a bug in the symbian file server, files in /resource can't be opened for unbuffered read, only for default mode read. (it doesn't mask the cache control flags when doing the security check) So read will always be done in default mode. Symptom of this was that QML plugin loading failed as the plugin description in /resource could not be read. Buffered or unbuffered writes (i.e. whether the cache should be write through or write behind) are controlled by the QIODevice::Unbuffered flag, therefore it needs to be passed through to the file engine. An optimisation for unix and windows to force unbuffered mode in the file engine is inappropriate (as that is referring to buffering in the standard library, which is bypassed entirely by using the low level RFile to open files on symbian) Reviewed-by: joao --- src/corelib/io/qfile.cpp | 8 +++++++- src/corelib/io/qfsfileengine_unix.cpp | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index fac4ac6..85e78a6 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -993,8 +993,14 @@ bool QFile::open(OpenMode mode) return false; } +#ifdef Q_OS_SYMBIAN + // For symbian, the unbuffered flag is used to control write-behind cache behaviour + if (fileEngine()->open(mode)) +#else // QIODevice provides the buffering, so there's no need to request it from the file engine. - if (fileEngine()->open(mode | QIODevice::Unbuffered)) { + if (fileEngine()->open(mode | QIODevice::Unbuffered)) +#endif + { QIODevice::open(mode); if (mode & Append) seek(size()); diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 55388e6..1e1b35b 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -196,8 +196,8 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode) if (openMode & QFile::Unbuffered) { if (openMode & QIODevice::WriteOnly) symbianMode |= 0x00001000; //EFileWriteDirectIO; - if (openMode & QIODevice::ReadOnly) - symbianMode |= 0x00004000; //EFileReadDirectIO; + // ### Unbuffered read is not used, because it prevents file open in /resource + // ### and has no obvious benefits } else { if (openMode & QIODevice::WriteOnly) symbianMode |= 0x00000800; //EFileWriteBuffered; -- cgit v0.12 From f417baad9235e90b5e9aae2fd06d664635c68bec Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 29 Nov 2010 16:48:17 +0000 Subject: Add symbian platform security and case sensitivity test cases On symbian, check that opening files in protected locations either succeeds or fails cleanly as expected by the capabilities the test is compiled with. This acts as a regression test for opening files in /resource, and also checks the other locations behave as expected. On all platforms, check file created with a mixed case filename can be accessed by it's aliases that differ only in case (or not) depending on the OS case sensitivity. For Windows/Symbian, file should be accessible by altered case aliases For other OS, it should not (other OS supported by Qt are unix like) Reviewed-by: mread --- tests/auto/qfile/tst_qfile.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 1bbf230..4421f0d 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -215,6 +215,11 @@ private slots: void resize(); void objectConstructors(); +#ifdef Q_OS_SYMBIAN + void platformSecurity_data(); + void platformSecurity(); +#endif + void caseSensitivity(); // --- Task related tests below this line void task167217(); @@ -400,6 +405,7 @@ void tst_QFile::cleanupTestCase() QFile::remove("qfile_map_testfile"); QFile::remove("readAllBuffer.txt"); QFile::remove("qt_file.tmp"); + QFile::remove("File.txt"); } //------------------------------------------ @@ -3135,5 +3141,91 @@ void tst_QFile::objectConstructors() QVERIFY(!file2->exists()); } +#ifdef Q_OS_SYMBIAN +void tst_QFile::platformSecurity_data() +{ + QTest::addColumn("file"); + QTest::addColumn("readable"); + QTest::addColumn("writable"); + + QString selfname = QCoreApplication::applicationFilePath(); + QString ownprivate = QCoreApplication::applicationDirPath(); + QString owndrive = selfname.left(2); + bool amiprivileged = RProcess().HasCapability(ECapabilityAllFiles); + QTest::newRow("resource") << owndrive + "/resource/apps/tst_qfile.rsc" << true << amiprivileged; + QTest::newRow("sys") << selfname << amiprivileged << false; + QTest::newRow("own private") << ownprivate + "/testfile.txt" << true << true; + QTest::newRow("other private") << owndrive + "/private/10003a3f/import/apps/tst_qfile_reg.rsc" << amiprivileged << amiprivileged; +} + +void tst_QFile::platformSecurity() +{ + QFETCH(QString,file); + QFETCH(bool,readable); + QFETCH(bool,writable); + + { + QFile f(file); + QCOMPARE(f.open(QIODevice::ReadOnly), readable); + } + + { + QFile f(file); + QCOMPARE(f.open(QIODevice::ReadOnly | QIODevice::Unbuffered), readable); + } + + //append mode used to avoid truncating the files. + { + QFile f(file); + QCOMPARE(f.open(QIODevice::WriteOnly | QIODevice::Append), writable); + } + + { + QFile f(file); + QCOMPARE(f.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered), writable); + } + + { + QFile f(file); + QCOMPARE(f.open(QIODevice::ReadWrite), writable); + } + + { + QFile f(file); + QCOMPARE(f.open(QIODevice::ReadWrite | QIODevice::Unbuffered), writable); + } +} +#endif + +void tst_QFile::caseSensitivity() +{ +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WIN) + const bool caseSensitive = false; +#else + const bool caseSensitive = true; +#endif + QByteArray testData("a little test"); + QString filename("File.txt"); + { + QFile f(filename); + QVERIFY(f.open(QIODevice::WriteOnly)); + QVERIFY(f.write(testData)); + f.close(); + } + QStringList alternates; + QFileInfo fi(filename); + QVERIFY(fi.exists()); + alternates << "file.txt" << "File.TXT" << "fIlE.TxT" << fi.absoluteFilePath().toUpper() << fi.absoluteFilePath().toLower(); + foreach (QString alt, alternates) { + QFileInfo fi2(alt); + QCOMPARE(fi2.exists(), !caseSensitive); + QCOMPARE(fi.size() == fi2.size(), !caseSensitive); + QFile f2(alt); + QCOMPARE(f2.open(QIODevice::ReadOnly), !caseSensitive); + if (caseSensitive) + QCOMPARE(f2.readAll(), testData); + } +} + QTEST_MAIN(tst_QFile) #include "tst_qfile.moc" -- cgit v0.12 From 1555eed6c27a843e0ecb09c15a915c0a3f76fd1e Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Mon, 29 Nov 2010 17:45:12 +0000 Subject: QtDeclarative: make autotests compile on symbian Move tests for private classes inside private_tests scope Add missing libraries Add QT_NO_CONCURRENT ifdef around a test case Define Q_DECLARATIVE_PRIVATE_EXPORT as Q_AUTOTEST_EXPORT, so the classes are exported for autotests, previously they were exported on every OS except symbian. (this doesn't affect exports for production builds) Reviewed-by: Miikka Heikkinen --- src/declarative/qml/qdeclarativeglobal_p.h | 2 +- tests/auto/declarative/declarative.pro | 44 ++++++++++++---------- tests/auto/declarative/examples/examples.pro | 2 + .../tst_qdeclarativepixmapcache.cpp | 4 ++ .../qdeclarativeviewer/qdeclarativeviewer.pro | 2 + tests/auto/declarative/qmlvisual/qmlvisual.pro | 1 - tests/auto/declarative/symbianlibs.pri | 9 +++++ 7 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 tests/auto/declarative/symbianlibs.pri diff --git a/src/declarative/qml/qdeclarativeglobal_p.h b/src/declarative/qml/qdeclarativeglobal_p.h index 31fbb1e..b8428b8 100644 --- a/src/declarative/qml/qdeclarativeglobal_p.h +++ b/src/declarative/qml/qdeclarativeglobal_p.h @@ -65,7 +65,7 @@ QT_MODULE(Declarative) } #ifdef Q_OS_SYMBIAN -#define Q_DECLARATIVE_PRIVATE_EXPORT +#define Q_DECLARATIVE_PRIVATE_EXPORT Q_AUTOTEST_EXPORT #else #define Q_DECLARATIVE_PRIVATE_EXPORT Q_DECLARATIVE_EXPORT #endif diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index f0fcfa9..499c155 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -8,74 +8,78 @@ SUBDIRS += \ SUBDIRS += \ examples \ parserstress \ + qdeclarativecomponent \ + qdeclarativecontext \ + qdeclarativeengine \ + qdeclarativeerror \ + qdeclarativefolderlistmodel \ + qdeclarativeinfo \ + qdeclarativelayoutitem \ + qdeclarativelistreference \ + qdeclarativemoduleplugin \ + qdeclarativeparticles \ + qdeclarativepixmapcache \ + qdeclarativeqt \ + qdeclarativeview \ + qdeclarativeviewer \ + qdeclarativexmlhttprequest \ + qmlvisual \ + moduleqt47 + +contains(QT_CONFIG, private_tests) { + SUBDIRS += \ qdeclarativeanchors \ qdeclarativeanimatedimage \ qdeclarativeanimations \ qdeclarativebehaviors \ qdeclarativebinding \ qdeclarativeborderimage \ - qdeclarativecomponent \ qdeclarativeconnection \ - qdeclarativecontext \ qdeclarativedebug \ qdeclarativedebugclient \ qdeclarativedebugservice \ qdeclarativedom \ qdeclarativeecmascript \ - qdeclarativeengine \ - qdeclarativeerror \ - qdeclarativefolderlistmodel \ - qdeclarativefontloader \ qdeclarativeflickable \ qdeclarativeflipable \ qdeclarativefocusscope \ + qdeclarativefontloader \ qdeclarativegridview \ qdeclarativeimage \ qdeclarativeimageprovider \ - qdeclarativeinfo \ qdeclarativeinstruction \ qdeclarativeitem \ qdeclarativelanguage \ - qdeclarativelayoutitem \ qdeclarativelistmodel \ - qdeclarativelistreference \ qdeclarativelistview \ qdeclarativeloader \ - qdeclarativemoduleplugin \ qdeclarativemousearea \ - qdeclarativeparticles \ qdeclarativepathview \ - qdeclarativepixmapcache \ qdeclarativepositioners \ qdeclarativeproperty \ qdeclarativepropertymap \ - qdeclarativeqt \ qdeclarativerepeater \ qdeclarativesmoothedanimation \ qdeclarativespringanimation \ + qdeclarativestyledtext \ qdeclarativesqldatabase \ qdeclarativestates \ - qdeclarativestyledtext \ qdeclarativesystempalette \ qdeclarativetext \ qdeclarativetextedit \ qdeclarativetextinput \ qdeclarativetimer \ qdeclarativevaluetypes \ - qdeclarativeview \ - qdeclarativeviewer \ qdeclarativevisualdatamodel \ qdeclarativeworkerscript \ - qdeclarativexmlhttprequest \ qdeclarativexmllistmodel \ - qmlvisual \ - qpacketprotocol \ - moduleqt47 + qpacketprotocol contains(QT_CONFIG, webkit) { SUBDIRS += \ qdeclarativewebview } +} # Tests which should run in Pulse PULSE_TESTS = $$SUBDIRS diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index 97f02af..dafc146 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -6,6 +6,8 @@ SOURCES += tst_examples.cpp include(../../../../tools/qml/qml.pri) +include(../symbianlibs.pri) + symbian: { importFiles.files = data importFiles.path = . diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index 50d0731..1a38e87 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -74,7 +74,9 @@ private slots: void massive(); void cancelcrash(); void shrinkcache(); +#ifndef QT_NO_CONCURRENT void networkCrash(); +#endif private: QDeclarativeEngine engine; QUrl thisfile; @@ -363,6 +365,7 @@ void createNetworkServer() eventLoop.exec(); } +#ifndef QT_NO_CONCURRENT // QT-3957 void tst_qdeclarativepixmapcache::networkCrash() { @@ -377,6 +380,7 @@ void tst_qdeclarativepixmapcache::networkCrash() } future.cancel(); } +#endif QTEST_MAIN(tst_qdeclarativepixmapcache) diff --git a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro index a94992b..8d4b410 100644 --- a/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro +++ b/tests/auto/declarative/qdeclarativeviewer/qdeclarativeviewer.pro @@ -6,6 +6,8 @@ include(../../../../tools/qml/qml.pri) SOURCES += tst_qdeclarativeviewer.cpp +include(../symbianlibs.pri) + symbian: { importFiles.files = data importFiles.path = . diff --git a/tests/auto/declarative/qmlvisual/qmlvisual.pro b/tests/auto/declarative/qmlvisual/qmlvisual.pro index d9fce44..84df15c 100644 --- a/tests/auto/declarative/qmlvisual/qmlvisual.pro +++ b/tests/auto/declarative/qmlvisual/qmlvisual.pro @@ -19,7 +19,6 @@ symbian: { qdeclarativepathview \ qdeclarativepositioners \ qdeclarativesmoothedanimation \ - qdeclarativespringfollow \ qdeclarativetext \ qdeclarativetextedit \ qdeclarativetextinput \ diff --git a/tests/auto/declarative/symbianlibs.pri b/tests/auto/declarative/symbianlibs.pri new file mode 100644 index 0000000..4452f67 --- /dev/null +++ b/tests/auto/declarative/symbianlibs.pri @@ -0,0 +1,9 @@ +#additional libs required for orientation sensor +symbian { + !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { + LIBS += -lsensrvclient -lsensrvutil + } + contains(QT_CONFIG, s60): { + LIBS += -lavkon -lcone + } +} -- cgit v0.12 From 173e6954e13871606a685229af279a2038f9d939 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 30 Nov 2010 14:21:12 +0000 Subject: Fix compile error for qdir autotest on symbian3 Header file is in a different location compared to previous SDK versions Reviewed-by: Miikka Heikkinen --- tests/auto/qdir/qdir.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qdir/qdir.pro b/tests/auto/qdir/qdir.pro index 55fd031..472e646 100644 --- a/tests/auto/qdir/qdir.pro +++ b/tests/auto/qdir/qdir.pro @@ -16,6 +16,7 @@ wince* { TARGET.UID3 = 0xE0340002 DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) LIBS += -lefsrv + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE } else { contains(QT_CONFIG, qt3support):QT += qt3support DEFINES += SRCDIR=\\\"$$PWD/\\\" -- cgit v0.12 From 7380e973a5e8dd8633e955792f219f6231b9513e Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 30 Nov 2010 14:24:59 +0000 Subject: Add test generated files to .gitignore The tests/.gitignore, did not inherit from the main one, which causes git to show hundreds of new files when running tests on symbian. Reviewed-by: Markus Goetz --- .gitignore | 14 +++++++++++++- tests/.gitignore | 6 ------ 2 files changed, 13 insertions(+), 7 deletions(-) delete mode 100644 tests/.gitignore diff --git a/.gitignore b/.gitignore index af52197..521cea2 100644 --- a/.gitignore +++ b/.gitignore @@ -119,6 +119,14 @@ translations/*.qm translations/*_untranslated.ts qrc_*.cpp +# Test generated files +QObject.log +tst_* +!tst_*.* +tst_*.log +tst_*.debug +tst_*~ + # xemacs temporary files *.flc @@ -203,7 +211,7 @@ doc-build # --------------------- ABLD.BAT -bld.inf +bld.inf* *.mmp *.mk *.rss @@ -221,6 +229,10 @@ plugin_commonu.def *.sym *.lib +# runonphone crash dumps +d_exc_*.txt +d_exc_*.stk + # Generated by abldfast.bat from devtools. .abldsteps.* diff --git a/tests/.gitignore b/tests/.gitignore deleted file mode 100644 index b203473..0000000 --- a/tests/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -QObject.log -tst_* -!tst_*.* -tst_*.log -tst_*.debug -tst_*~ -- cgit v0.12 From be03dc12478085b3d8ec92a87fe12234169dce3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 30 Nov 2010 20:37:07 +0100 Subject: Fix typo in QFile test If file system isn't case sensitive, open succeeds as should reading, with the read data matching testData. --- tests/auto/qfile/tst_qfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index 4421f0d..d561f53 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -3222,7 +3222,7 @@ void tst_QFile::caseSensitivity() QCOMPARE(fi.size() == fi2.size(), !caseSensitive); QFile f2(alt); QCOMPARE(f2.open(QIODevice::ReadOnly), !caseSensitive); - if (caseSensitive) + if (!caseSensitive) QCOMPARE(f2.readAll(), testData); } } -- cgit v0.12 From 16252a59afa58b0cb4b0ffb02a330dcf002c9750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Tue, 30 Nov 2010 20:50:48 +0100 Subject: Fix tst_QFile::caseSensitivity test on Mac Mac's default file system is case-preserving, but case-insensitive, otherwise. --- tests/auto/qfile/tst_qfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index d561f53..a8715e2 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -3199,7 +3199,7 @@ void tst_QFile::platformSecurity() void tst_QFile::caseSensitivity() { -#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WIN) +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WIN) || defined(Q_OS_MAC) const bool caseSensitive = false; #else const bool caseSensitive = true; -- cgit v0.12 From 63a2c0a429674506c5a5d9e37571033608e9704b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 2 Dec 2010 14:24:03 +0000 Subject: Update def files refreeze on top of master def files (we have added some exports to QtCore) Reviewed-by: Trust Me --- src/s60installs/bwins/QtCoreu.def | 7 ++++++- src/s60installs/eabi/QtCoreu.def | 4 ++++ src/s60installs/eabi/QtDeclarativeu.def | 2 +- src/s60installs/eabi/QtGuiu.def | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index b678b4e..84aa246 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4585,4 +4585,9 @@ EXPORTS ?advance@QAnimationDriver@@QAEXXZ @ 4584 NONAME ; void QAnimationDriver::advance(void) ?start@QAnimationDriver@@AAEXXZ @ 4585 NONAME ; void QAnimationDriver::start(void) ?unlockInline@QMutex@@QAEXXZ @ 4586 NONAME ; void QMutex::unlockInline(void) - + ??0QSystemError@@QAE@HW4ErrorScope@0@@Z @ 4587 NONAME ; QSystemError::QSystemError(int, enum QSystemError::ErrorScope) + ??0QSystemError@@QAE@XZ @ 4588 NONAME ; QSystemError::QSystemError(void) + ?error@QSystemError@@QAEHXZ @ 4589 NONAME ; int QSystemError::error(void) + ?scope@QSystemError@@QAE?AW4ErrorScope@1@XZ @ 4590 NONAME ; enum QSystemError::ErrorScope QSystemError::scope(void) + ?toString@QSystemError@@QAE?AVQString@@XZ @ 4591 NONAME ; class QString QSystemError::toString(void) + ??0QFileInfo@@QAE@PAVQFileInfoPrivate@@@Z @ 4592 NONAME ; QFileInfo::QFileInfo(class QFileInfoPrivate *) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 02e72a1..130d9c0 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3791,4 +3791,8 @@ EXPORTS _ZTV13QUnifiedTimer @ 3790 NONAME _ZTV16QAnimationDriver @ 3791 NONAME _ZTV23QAnimationDriverPrivate @ 3792 NONAME + _ZN12QSystemError8toStringEv @ 3793 NONAME + _ZN5QChar21currentUnicodeVersionEv @ 3794 NONAME + _ZN9QFileInfoC1EP16QFileInfoPrivate @ 3795 NONAME + _ZN9QFileInfoC2EP16QFileInfoPrivate @ 3796 NONAME diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index bb0bd5a..b0efab4 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -1883,6 +1883,6 @@ EXPORTS _ZThn8_N29QDeclarativeAbstractAnimation9setTargetERK20QDeclarativeProperty @ 1882 NONAME ABSENT _ZThn8_N29QDeclarativeAbstractAnimationD0Ev @ 1883 NONAME ABSENT _ZThn8_N29QDeclarativeAbstractAnimationD1Ev @ 1884 NONAME ABSENT - _ZN23QDeclarativeDebugHelper15enableDebuggingEv @ 1885 NONAME ABSENT + _ZN23QDeclarativeDebugHelper15enableDebuggingEv @ 1885 NONAME _ZN27QDeclarativePropertyPrivate7connectEPK7QObjectiS2_iiPi @ 1886 NONAME ABSENT diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 703d11b..926ed52 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -12105,7 +12105,7 @@ EXPORTS _ZN15QStaticTextItemD1Ev @ 12104 NONAME _ZN15QStaticTextItemD2Ev @ 12105 NONAME _ZN19QEventDispatcherS6031reactivateDeferredActiveObjectsEv @ 12106 NONAME - _Z18qt_addBitmapToPathffPKhiiiP12QPainterPath @ 12107 NONAME ABSENT + _Z18qt_addBitmapToPathffPKhiiiP12QPainterPath @ 12107 NONAME _Z22qt_fontdata_from_indexi @ 12108 NONAME _ZN10QBlittable4lockEv @ 12109 NONAME _ZN10QBlittable6unlockEv @ 12110 NONAME -- cgit v0.12 From 9988c66e0bc1877d27bb89fbf034bb0e05091a52 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 3 Dec 2010 10:44:54 +0000 Subject: Fix compile error Missing QT_BEGIN_NAMESPACE caused error when the namespace macros are defined. Reviewed-by: mread --- src/corelib/kernel/qsystemerror.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index d2350b5..953ed95 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -51,6 +51,8 @@ #include #endif +QT_BEGIN_NAMESPACE + #if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L namespace { -- cgit v0.12 From b9a029d7abaf46353b7b428eba29c3612661743e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sat, 4 Dec 2010 08:55:10 +0100 Subject: Add missing include --- src/corelib/io/qfilesystemengine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 1e5914b..d9d802e 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -42,6 +42,7 @@ #include "qfilesystemengine_p.h" #include #include +#include #include #ifdef QT_BUILD_CORE_LIB #include -- cgit v0.12 From 684a61aa3da00b04f44eea0e92dbcb6183f505bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sat, 4 Dec 2010 17:04:33 +0100 Subject: More missing includes --- src/corelib/io/qfilesystemiterator_win.cpp | 2 ++ src/corelib/io/qfilesystemmetadata_p.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 9181789..095a46a 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -43,6 +43,8 @@ #include "qfilesystemengine_p.h" #include "qplatformdefs.h" +#include + QT_BEGIN_NAMESPACE bool done = true; diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 860b887..50c1b61 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -60,6 +60,7 @@ // Platform-specific includes #if defined(Q_OS_WIN) +#include #elif defined(Q_OS_SYMBIAN) #include #include -- cgit v0.12 From 72db8d3075f91cac831de590dd6748c6bbc9a52f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sat, 4 Dec 2010 20:31:06 +0100 Subject: Set minimum target Windows version to 2000 Required for FindFirstFileEx. --- src/corelib/io/qfilesystemiterator_win.cpp | 4 ++++ src/corelib/io/qfilesystemmetadata_p.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 095a46a..96c7fdb 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -43,6 +43,10 @@ #include "qfilesystemengine_p.h" #include "qplatformdefs.h" +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#endif + #include QT_BEGIN_NAMESPACE diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 50c1b61..03bb7f6 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -60,6 +60,10 @@ // Platform-specific includes #if defined(Q_OS_WIN) +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 +#endif + #include #elif defined(Q_OS_SYMBIAN) #include -- cgit v0.12 From 07de3abf3785248160fbd42c449b0832ea97c320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sat, 4 Dec 2010 20:55:13 +0100 Subject: No symbolic links in Windows CE --- src/corelib/io/qfilesystemmetadata_p.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 03bb7f6..5b5587b 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -370,11 +370,13 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo if (setLinkType) { knownFlagsMask |= LinkType; entryFlags &= ~LinkType; +#if !defined(Q_OS_WINCE) if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { entryFlags |= LinkType; } +#endif } } -- cgit v0.12 From e2498cf6e6c193df849f6dbbaab3a827ca3e3a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sun, 5 Dec 2010 01:25:02 +0100 Subject: Removing unused duplicate definitions These functions have been forked in qfilesystemengine_win.cpp and are no longer used in this file. Cleaning up. --- src/corelib/io/qfsfileengine_win.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 715fe39..3b6e80c 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -75,15 +75,6 @@ QT_BEGIN_NAMESPACE - - -#if defined(Q_OS_WINCE) -static QString qfsPrivateCurrentDir = QLatin1String(""); -// As none of the functions we try to resolve do exist on Windows CE -// we use QT_NO_LIBRARY to shorten everything up a little bit. -#define QT_NO_LIBRARY 1 -#endif - #if !defined(Q_OS_WINCE) static inline bool isUncPath(const QString &path) { @@ -114,24 +105,6 @@ QString QFSFileEnginePrivate::longFileName(const QString &path) #endif } -static inline bool getFindData(QString path, WIN32_FIND_DATA &findData) -{ - // path should not end with a trailing slash - while (path.endsWith(QLatin1Char('\\'))) - path.chop(1); - - // can't handle drives - if (!path.endsWith(QLatin1Char(':'))) { - HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData); - if (hFind != INVALID_HANDLE_VALUE) { - ::FindClose(hFind); - return true; - } - } - - return false; -} - /* \internal */ -- cgit v0.12 From e37ca76dc70269017eaa7a32c4fae97c9e153ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sun, 5 Dec 2010 01:28:48 +0100 Subject: New attempt at fixing compilation failure Including windows.h and defining _WIN32_WINNT didn't cut it. Instead, fall back to explicitly #defining IO_REPARSE_TAG_SYMLINK in metadata header, since it's all that's needed there. In windows-specific iterator implementation ensure _WIN32_WINNT >= 0x0500. --- src/corelib/io/qfilesystemiterator_win.cpp | 3 ++- src/corelib/io/qfilesystemmetadata_p.h | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 96c7fdb..6608a9e 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -43,7 +43,8 @@ #include "qfilesystemengine_p.h" #include "qplatformdefs.h" -#ifndef _WIN32_WINNT +#if _WIN32_WINNT < 0x0500 +#undef _WIN32_WINNT #define _WIN32_WINNT 0x0500 #endif diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h index 5b5587b..c4e11d9 100644 --- a/src/corelib/io/qfilesystemmetadata_p.h +++ b/src/corelib/io/qfilesystemmetadata_p.h @@ -60,15 +60,12 @@ // Platform-specific includes #if defined(Q_OS_WIN) -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0500 +#ifndef IO_REPARSE_TAG_SYMLINK +#define IO_REPARSE_TAG_SYMLINK (0xA000000CL) #endif - -#include #elif defined(Q_OS_SYMBIAN) #include #include -#else #endif QT_BEGIN_NAMESPACE -- cgit v0.12 From 364e9d4ff5056f36fbff436ba9539a69ae45c5d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sun, 5 Dec 2010 03:05:40 +0100 Subject: Define _WIN32_WINNT before any includes ... to ensure it's properly defined before is ever included. --- src/corelib/io/qfilesystemiterator_win.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 6608a9e..b5fce12 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -39,15 +39,15 @@ ** ****************************************************************************/ -#include "qfilesystemiterator_p.h" -#include "qfilesystemengine_p.h" -#include "qplatformdefs.h" - #if _WIN32_WINNT < 0x0500 #undef _WIN32_WINNT #define _WIN32_WINNT 0x0500 #endif +#include "qfilesystemiterator_p.h" +#include "qfilesystemengine_p.h" +#include "qplatformdefs.h" + #include QT_BEGIN_NAMESPACE -- cgit v0.12 From dcc7df8ed32d900a616d415c0eb2565e559f6435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sun, 5 Dec 2010 11:12:37 +0100 Subject: Add missing license header to test case --- .../tst_qabstractfileengine.cpp | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp index f98adca..5952252 100644 --- a/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/qabstractfileengine/tst_qabstractfileengine.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include #include -- cgit v0.12 From 9371ba70ac747484b1300d96c2a80dcdbc872fe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Sun, 5 Dec 2010 11:28:28 +0100 Subject: Fix spelling in comments --- src/corelib/io/qfilesystemengine_symbian.cpp | 2 +- src/corelib/io/qfilesystemengine_win.cpp | 2 +- tests/auto/qdir/tst_qdir.cpp | 2 +- tests/auto/qfile/tst_qfile.cpp | 4 ++-- tests/auto/qfiledialog/tst_qfiledialog.cpp | 8 ++++---- tests/auto/qfileinfo/tst_qfileinfo.cpp | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_symbian.cpp b/src/corelib/io/qfilesystemengine_symbian.cpp index 3659a39..84c3aa1 100644 --- a/src/corelib/io/qfilesystemengine_symbian.cpp +++ b/src/corelib/io/qfilesystemengine_symbian.cpp @@ -378,7 +378,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry) if(!abspath.endsWith(QLatin1Char('\\'))) abspath.append(QLatin1Char('\\')); TInt r = fs.SetSessionPath(qt_QString2TPtrC(abspath)); - //SetSessionPath succeeds for non existant directory, which is why it's checked above + //SetSessionPath succeeds for non existent directory, which is why it's checked above if (r == KErrNone) { __ASSERT_COMPILE(sizeof(wchar_t) == sizeof(unsigned short)); //attempt to set open C to the same path diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 621b631..39fce97 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -378,7 +378,7 @@ static QString readLink(const QFileSystemEntry &link) static bool uncShareExists(const QString &server) { - // This code asumes the UNC path is always like \\?\UNC\server... + // This code assumes the UNC path is always like \\?\UNC\server... QStringList parts = server.split(QLatin1Char('\\'), QString::SkipEmptyParts); if (parts.count() >= 3) { QStringList shares; diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 6a81da6..dc46f52 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -928,7 +928,7 @@ void tst_QDir::current() if (!path.isEmpty()) { bool b = QDir::setCurrent(path); - // If path is non existant, then setCurrent should be false (currentDir is empty in testData) + // If path is non existent, then setCurrent should be false (currentDir is empty in testData) QVERIFY(b == !currentDir.isEmpty()); } if (!currentDir.isEmpty()) { diff --git a/tests/auto/qfile/tst_qfile.cpp b/tests/auto/qfile/tst_qfile.cpp index a8715e2..c19079f 100644 --- a/tests/auto/qfile/tst_qfile.cpp +++ b/tests/auto/qfile/tst_qfile.cpp @@ -414,7 +414,7 @@ void tst_QFile::cleanupTestCase() // attributes and the contents itself // will be changed as far as we have a // proper way to handle files in the -// testing enviroment. +// testing environment. //------------------------------------------ void tst_QFile::exists() @@ -1702,7 +1702,7 @@ void tst_QFile::seekAfterEndOfFile() void tst_QFile::FILEReadWrite() { - // Tests modifing a file. First creates it then reads in 4 bytes and then overwrites these + // Tests modifying a file. First creates it then reads in 4 bytes and then overwrites these // 4 bytes with new values. At the end check to see the file contains the new values. QFile::remove("FILEReadWrite.txt"); diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index ec244c5..668a3e0 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -187,7 +187,7 @@ public: QSize sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { return QSize(); } }; -// emited any time the selection model emits current changed +// emitted any time the selection model emits current changed void tst_QFiledialog::currentChangedSignal() { QNonNativeFileDialog fd; @@ -212,7 +212,7 @@ void tst_QFiledialog::currentChangedSignal() QCOMPARE(spyCurrentChanged.count(), 1); } -// only emited from the views, sidebar, or lookin combo +// only emitted from the views, sidebar, or lookin combo void tst_QFiledialog::directoryEnteredSignal() { #if defined QT_BUILD_INTERNAL @@ -273,7 +273,7 @@ void tst_QFiledialog::filesSelectedSignal_data() QTest::newRow("existingFiles") << QFileDialog::ExistingFiles; } -// emited when the dialog closes with the selected files +// emitted when the dialog closes with the selected files void tst_QFiledialog::filesSelectedSignal() { QNonNativeFileDialog fd; @@ -317,7 +317,7 @@ void tst_QFiledialog::filesSelectedSignal() QCOMPARE(spyFilesSelected.count(), 1); } -// only emited when the combo box is activated +// only emitted when the combo box is activated void tst_QFiledialog::filterSelectedSignal() { QNonNativeFileDialog fd; diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 79c5184..3bbe2ca 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1653,8 +1653,8 @@ void tst_QFileInfo::owner() DWORD bufSize = 1024; if (GetUserNameW(usernameBuf, &bufSize)) { userName = QString::fromWCharArray(usernameBuf, bufSize); - // Special case : If the user is a member of Adminstrators group, all files - // created by the current user are owned by the Admistrators group. + // Special case : If the user is a member of Administrators group, all files + // created by the current user are owned by the Administrators group. LPLOCALGROUP_USERS_INFO_0 pBuf = NULL; DWORD dwLevel = 0; DWORD dwFlags = LG_INCLUDE_INDIRECT ; @@ -1664,7 +1664,7 @@ void tst_QFileInfo::owner() NET_API_STATUS nStatus; nStatus = NetUserGetLocalGroups(0, usernameBuf, dwLevel, dwFlags, (LPBYTE *) &pBuf, dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries); - // Check if the current user is a member of Adminstrators group + // Check if the current user is a member of Administrators group if (nStatus == NERR_Success && pBuf){ for (int i = 0; i < dwEntriesRead; i++) { QString groupName = QString::fromWCharArray(pBuf[i].lgrui0_name); -- cgit v0.12 From fb43ea28e2712073de06644d78ed5a97a40f016b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 6 Dec 2010 13:46:35 +0100 Subject: Fix QDir::relativeFilePath We used to call cleanPath on the result of absolutePath, before returning it to the user, but stopped doing that. relativeFilePath actually depended on that and broke. Fixed now. Reviewed-by: Prasanth Ullattil --- src/corelib/io/qdir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index e1fed0d..2f97c3a 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -711,7 +711,7 @@ QString QDir::absoluteFilePath(const QString &fileName) const */ QString QDir::relativeFilePath(const QString &fileName) const { - QString dir = absolutePath(); + QString dir = cleanPath(absolutePath()); QString file = cleanPath(fileName); if (isRelativePath(file) || isRelativePath(dir)) -- cgit v0.12 From 5bdc4ec60655aba2972f0e6cb2b09ee5f012690b Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 6 Dec 2010 14:24:58 +0100 Subject: Fix tst_QFileInfo::canonicalFilePath failure on Windows When the test application is running without administrative privilages, the CreateSymbolicLink() can incorrectly return success. To handle this we need to check whether GetLastError() returns ERROR_PRIVILEGE_NOT_HELD or not. Reviewed-by: Joao --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 3bbe2ca..96a0d77 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -621,18 +621,27 @@ void tst_QFileInfo::canonicalFilePath() PtrCreateSymbolicLink ptrCreateSymbolicLink = (PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLinkW"); - if (!ptrCreateSymbolicLink || - ptrCreateSymbolicLink((wchar_t*)QString("res").utf16(), (wchar_t*)QString("resources").utf16(), 1) == 0) { + if (!ptrCreateSymbolicLink) { QSKIP("Symbolic links aren't supported by FS", SkipAll); + } else { + // CreateSymbolicLink can return TRUE & still fail to create the link, + // the error code in that case is ERROR_PRIVILEGE_NOT_HELD (1314) + SetLastError(0); + BOOL ret = ptrCreateSymbolicLink((wchar_t*)QString("res").utf16(), (wchar_t*)QString("resources").utf16(), 1); + DWORD dwErr = GetLastError(); + if (!ret) + QSKIP("Symbolic links aren't supported by FS", SkipAll); + QString currentPath = QDir::currentPath(); + bool is_res_Current = QDir::setCurrent("res"); + if (!is_res_Current && dwErr == 1314) + QSKIP("Not enough privilages to create Symbolic links", SkipAll); + QCOMPARE(is_res_Current, true); + + QCOMPARE(QFileInfo("file1").canonicalFilePath(), currentPath + "/resources/file1"); + + QCOMPARE(QDir::setCurrent(currentPath), true); + QDir::current().rmdir("res"); } - - QString currentPath = QDir::currentPath(); - QCOMPARE(QDir::setCurrent("res"), true); - - QCOMPARE(QFileInfo("file1").canonicalFilePath(), currentPath + "/resources/file1"); - - QCOMPARE(QDir::setCurrent(currentPath), true); - QDir::current().rmdir("res"); #endif } -- cgit v0.12 From 37fdb437084a7a4acefefbe1d55adee4e7723b7a Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Mon, 6 Dec 2010 14:46:22 +0100 Subject: Fix tst_QFileInfo owner() & group() failure on Windows. The ownership of newly created files are transferred to the Administrator group only if the application is running with Admin privilages. This will happen only on Windows 7 & Vista, on XP user has the ownership. Reviewed-by: Joao --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 63 +++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 96a0d77..70ed842 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1648,6 +1648,27 @@ void tst_QFileInfo::detachingOperations() } #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) +BOOL IsUserAdmin() +{ + BOOL b; + SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; + PSID AdministratorsGroup; + b = AllocateAndInitializeSid( + &NtAuthority, + 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, + &AdministratorsGroup); + if (b) { + if (!CheckTokenMembership( NULL, AdministratorsGroup, &b)) + b = FALSE; + FreeSid(AdministratorsGroup); + } + + return(b); +} + void tst_QFileInfo::owner() { QString userName; @@ -1661,28 +1682,30 @@ void tst_QFileInfo::owner() wchar_t usernameBuf[1024]; DWORD bufSize = 1024; if (GetUserNameW(usernameBuf, &bufSize)) { - userName = QString::fromWCharArray(usernameBuf, bufSize); - // Special case : If the user is a member of Administrators group, all files - // created by the current user are owned by the Administrators group. - LPLOCALGROUP_USERS_INFO_0 pBuf = NULL; - DWORD dwLevel = 0; - DWORD dwFlags = LG_INCLUDE_INDIRECT ; - DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH; - DWORD dwEntriesRead = 0; - DWORD dwTotalEntries = 0; - NET_API_STATUS nStatus; - nStatus = NetUserGetLocalGroups(0, usernameBuf, dwLevel, dwFlags, (LPBYTE *) &pBuf, - dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries); - // Check if the current user is a member of Administrators group - if (nStatus == NERR_Success && pBuf){ - for (int i = 0; i < dwEntriesRead; i++) { - QString groupName = QString::fromWCharArray(pBuf[i].lgrui0_name); - if (!groupName.compare(QLatin1String("Administrators"))) - userName = groupName; + userName = QString::fromWCharArray(usernameBuf); + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && IsUserAdmin()) { + // Special case : If the user is a member of Administrators group, all files + // created by the current user are owned by the Administrators group. + LPLOCALGROUP_USERS_INFO_0 pBuf = NULL; + DWORD dwLevel = 0; + DWORD dwFlags = LG_INCLUDE_INDIRECT ; + DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH; + DWORD dwEntriesRead = 0; + DWORD dwTotalEntries = 0; + NET_API_STATUS nStatus; + nStatus = NetUserGetLocalGroups(0, usernameBuf, dwLevel, dwFlags, (LPBYTE *) &pBuf, + dwPrefMaxLen, &dwEntriesRead, &dwTotalEntries); + // Check if the current user is a member of Administrators group + if (nStatus == NERR_Success && pBuf){ + for (int i = 0; i < dwEntriesRead; i++) { + QString groupName = QString::fromWCharArray(pBuf[i].lgrui0_name); + if (!groupName.compare(QLatin1String("Administrators"))) + userName = groupName; + } } + if (pBuf != NULL) + NetApiBufferFree(pBuf); } - if (pBuf != NULL) - NetApiBufferFree(pBuf); } extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; qt_ntfs_permission_lookup = 1; -- cgit v0.12 From 84fa2a82ea90ad2c554b54bd08db1f41d85484ea Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 7 Dec 2010 11:07:39 +0100 Subject: Fix compile error in tst_qfileinfo on Mac/Linux Reviewed-by: Shane Kearns --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 70ed842..2e1ab39 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1648,6 +1648,7 @@ void tst_QFileInfo::detachingOperations() } #if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) +#if defined (Q_OS_WIN) BOOL IsUserAdmin() { BOOL b; @@ -1668,6 +1669,7 @@ BOOL IsUserAdmin() return(b); } +#endif void tst_QFileInfo::owner() { -- cgit v0.12