summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/io.pri4
-rw-r--r--src/corelib/io/qfilesystemengine.cpp7
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp7
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp8
-rw-r--r--src/corelib/io/qprocess.cpp4
-rw-r--r--src/corelib/io/qstandardpaths.cpp2
-rw-r--r--src/corelib/io/qstandardpaths_json.cpp258
-rw-r--r--src/corelib/io/qwindowspipereader.cpp8
8 files changed, 30 insertions, 268 deletions
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 9e89f9fdc0..f57dcebe33 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -118,15 +118,13 @@ win32 {
} else {
SOURCES += io/qstandardpaths_unix.cpp
}
- } else:standardpathsjson {
- SOURCES += io/qstandardpaths_json.cpp
} else:blackberry {
SOURCES += io/qstandardpaths_blackberry.cpp
} else {
SOURCES += io/qstandardpaths_unix.cpp
}
- linux-* {
+ linux-*|if(qnx:contains(QT_CONFIG, inotify)) {
SOURCES += io/qfilesystemwatcher_inotify.cpp
HEADERS += io/qfilesystemwatcher_inotify_p.h
}
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index fe06210fb9..8707aec0b8 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -300,6 +300,13 @@ void QFileSystemMetaData::fillFromDirEnt(const QT_DIRENT &entry)
const struct dirent_extra_stat * const extra_stat =
reinterpret_cast<struct dirent_extra_stat *>(extra);
+ // Remember whether this was a link or not, this saves an lstat() call later.
+ if (extra->d_type == _DTYPE_LSTAT) {
+ knownFlagsMask |= QFileSystemMetaData::LinkType;
+ if (S_ISLNK(extra_stat->d_stat.st_mode))
+ entryFlags |= QFileSystemMetaData::LinkType;
+ }
+
// For symlinks, the extra type _DTYPE_LSTAT doesn't work for filling out the meta data,
// as we need the stat() information there, not the lstat() information.
// In this case, don't use the extra information.
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index 77a5959f8f..449be9b7b5 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -51,11 +51,14 @@
#include <qset.h>
#include <qtimer.h>
+#if defined(Q_OS_LINUX) || (defined(Q_OS_QNX) && !defined(QT_NO_INOTIFY))
+#define USE_INOTIFY
+#endif
#include "qfilesystemwatcher_polling_p.h"
#if defined(Q_OS_WIN)
# include "qfilesystemwatcher_win_p.h"
-#elif defined(Q_OS_LINUX)
+#elif defined(USE_INOTIFY)
# include "qfilesystemwatcher_inotify_p.h"
#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC)
# include "qfilesystemwatcher_kqueue_p.h"
@@ -67,7 +70,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
{
#if defined(Q_OS_WIN)
return new QWindowsFileSystemWatcherEngine(parent);
-#elif defined(Q_OS_LINUX)
+#elif defined(USE_INOTIFY)
// there is a chance that inotify may fail on Linux pre-2.6.13 (August
// 2005), so we can't just new inotify directly.
return QInotifyFileSystemWatcherEngine::create(parent);
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp
index 390a280ff2..11ac0e5b5d 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify.cpp
+++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp
@@ -52,12 +52,20 @@
#include <qsocketnotifier.h>
#include <qvarlengtharray.h>
+#if defined(Q_OS_LINUX)
#include <sys/syscall.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
+#endif
#if defined(QT_NO_INOTIFY)
+
+#if defined(Q_OS_QNX)
+// These files should only be compiled on QNX if the inotify headers are found
+#error "Should not get here."
+#endif
+
#include <linux/types.h>
#if defined(__i386__)
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 395effaff9..c52053000d 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -458,8 +458,8 @@ void QProcessPrivate::Channel::clear()
are supplied as individual strings in a QStringList.
For example, the following code snippet runs the analog clock
- example in the Motif style on X11 platforms by passing strings
- containing "-style" and "motif" as two items in the list of
+ example in the Fusion style on X11 platforms by passing strings
+ containing "-style" and "fusion" as two items in the list of
arguments:
\snippet qprocess/qprocess-simpleexecution.cpp 0
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 91e343b021..4d7e359117 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -272,7 +272,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
searchPaths.reserve(rawPaths.size());
foreach (const QString &rawPath, rawPaths) {
QString cleanPath = QDir::cleanPath(rawPath);
- if (cleanPath.size() > 1 && cleanPath.endsWith('/'))
+ if (cleanPath.size() > 1 && cleanPath.endsWith(QLatin1Char('/')))
cleanPath.truncate(cleanPath.size() - 1);
searchPaths.push_back(cleanPath);
}
diff --git a/src/corelib/io/qstandardpaths_json.cpp b/src/corelib/io/qstandardpaths_json.cpp
deleted file mode 100644
index 839cd9e873..0000000000
--- a/src/corelib/io/qstandardpaths_json.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** 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, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qstandardpaths.h"
-
-#include <QString>
-#include <QJsonDocument>
-#include <QJsonObject>
-#include <QJsonValue>
-#include <QJsonArray>
-#include <QFile>
-#include <QDir>
-#include <QAtomicPointer>
-#include <QCoreApplication>
-#include <QRegularExpression>
-#include <QRegularExpressionMatchIterator>
-#include <QRegularExpressionMatch>
-
-#ifndef QT_NO_STANDARDPATHS
-
-QT_BEGIN_NAMESPACE
-
-class QStandardPathsPrivate {
-public:
- QStandardPathsPrivate() : object(0){}
- ~QStandardPathsPrivate() { delete object.load(); }
- QAtomicPointer<QJsonObject> object;
-};
-
-Q_GLOBAL_STATIC(QStandardPathsPrivate, configCache);
-
-/*!
- \internal
- Substitute environment variables in the form ${name}
-
- The JSON QStandardPaths implementation can be configured on a per user
- (or per application) basis through the use of environment variables,
- which are evaluated each time a location is queried. This function
- performs that evaluation on \a value. No substitution is performed
- for undefined variables.
-
- This slightly underselects according to the 2009-09-20 version of
- the GNU setenv(3) manual page: It disallows '}' within the variable
- name. ${var}} will look for a variable named "var", not "var}".
- */
-static QString substituteEnvVars(const QJsonValue & value)
-{
- QString str = value.toString();
- if (str.isEmpty() || !str.contains(QLatin1String("${")))
- return str;
-
- // optimize for a common case
- str.replace(QLatin1String("${HOME}"), QDir::homePath());
-
- // Do ${} format environment variable substitution if necessary
- // repeat this test because ${HOME} might expand to the empty string
- if (!str.isEmpty() && str.contains(QLatin1String("${"))) {
- QRegularExpression varRegExp(QLatin1String("\\$\\{([^\\}=]*)\\}"));
- QRegularExpressionMatchIterator matchIterator =
- varRegExp.globalMatch(str);
- while (matchIterator.hasNext()) {
- QRegularExpressionMatch match = matchIterator.next();
- QByteArray envValue =
- qgetenv(match.captured(1).toLatin1().data());
- if (!envValue.isNull()) {
- QString replacement =
- QFile::decodeName(envValue);
- str.replace(match.captured(0), replacement);
- }
- }
- }
- return str;
-}
-
-static void appendOrganizationAndApp(QString &path)
-{
- const QString org = QCoreApplication::organizationName();
- if (!org.isEmpty())
- path += QLatin1Char('/') + org;
- const QString appName = QCoreApplication::applicationName();
- if (!appName.isEmpty())
- path += QLatin1Char('/') + appName;
-}
-
-QString QStandardPaths::writableLocation(StandardLocation type)
-{
- QStringList locations = QStandardPaths::standardLocations(type);
- if (locations.isEmpty())
- return QString();
- return locations.first();
-}
-
-QStringList QStandardPaths::standardLocations(StandardLocation type)
-{
- switch (type) {
- case HomeLocation:
- return QStringList(QDir::homePath()); // set $HOME
- case TempLocation:
- return QStringList(QDir::tempPath()); // set $TMPDIR
- default:
- break;
- }
-
- if (isTestModeEnabled()) {
- const QString qttestDir = QDir::homePath() + QLatin1String("/.qttest");
- QString path;
- switch (type) {
- case GenericDataLocation:
- case DataLocation:
- path = qttestDir + QLatin1String("/share");
- if (type == DataLocation)
- appendOrganizationAndApp(path);
- return QStringList(path);
- case GenericCacheLocation:
- case CacheLocation:
- path = qttestDir + QLatin1String("/cache");
- if (type == CacheLocation)
- appendOrganizationAndApp(path);
- return QStringList(path);
- case ConfigLocation:
- return QStringList(qttestDir + QLatin1String("/config"));
- default:
- break;
- }
- }
-
-
- QJsonObject * localConfigObject = configCache()->object.loadAcquire();
- if (localConfigObject == 0) {
- QString configHome = QFile::decodeName(qgetenv("PATH_CONFIG_HOME"));
- if (configHome.isEmpty())
- configHome = QLatin1String("/etc/user-dirs.json");
- QFile file(configHome);
- if (file.open(QIODevice::ReadOnly)) {
- QJsonDocument configDoc = QJsonDocument::fromJson(file.readAll());
- if (configDoc.isNull())
- return QStringList();
-
- QJsonObject myConfigObject = configDoc.object();
- localConfigObject = new QJsonObject(myConfigObject);
- if (!configCache()->object.testAndSetRelease(0, localConfigObject)) {
- delete localConfigObject;
- localConfigObject = configCache()->object.loadAcquire();
- }
- } else {
- return QStringList();
- }
- }
-
- QLatin1String key("");
-
- switch (type) {
- case DocumentsLocation:
- key = QLatin1String("DOCUMENTS");
- break;
- case PicturesLocation:
- key = QLatin1String("PICTURES");
- break;
- case MusicLocation:
- key = QLatin1String("MUSIC");
- break;
- case MoviesLocation:
- key = QLatin1String("VIDEOS");
- break;
- case DownloadLocation:
- key = QLatin1String("DOWNLOAD");
- break;
- case ApplicationsLocation:
- key = QLatin1String("APPLICATIONS");
- break;
- case CacheLocation:
- key = QLatin1String("CACHE");
- break;
- case GenericCacheLocation:
- key = QLatin1String("GENERIC_CACHE");
- break;
- case DataLocation:
- key = QLatin1String("DATA");
- break;
- case GenericDataLocation:
- key = QLatin1String("GENERIC_DATA");
- break;
- case ConfigLocation:
- key = QLatin1String("CONFIG");
- break;
- case RuntimeLocation:
- key = QLatin1String("RUNTIME");
- break;
- case DesktopLocation:
- key = QLatin1String("DESKTOP");
- break;
- case FontsLocation:
- key = QLatin1String("FONTS");
- break;
-
- default:
- return QStringList();
- }
-
- QJsonObject::const_iterator iter = localConfigObject->constFind(key);
- if (iter == localConfigObject->constEnd())
- return QStringList();
-
- switch (iter.value().type()) {
- case QJsonValue::Array: {
- QStringList resultList;
- foreach (const QJsonValue &item, iter.value().toArray())
- resultList.append(substituteEnvVars(item));
- return resultList;
- }
- case QJsonValue::String:
- return QStringList(substituteEnvVars(iter.value()));
- default:
- break;
- }
- return QStringList();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_STANDARDPATHS
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index cca6e80810..bef6097043 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -213,7 +213,8 @@ void QWindowsPipeReader::startAsyncRead()
// We get notified by the QWinOverlappedIoNotifier - even in the synchronous case.
return;
} else {
- switch (GetLastError()) {
+ const DWORD dwError = GetLastError();
+ switch (dwError) {
case ERROR_IO_PENDING:
// This is not an error. We're getting notified, when data arrives.
return;
@@ -223,16 +224,19 @@ void QWindowsPipeReader::startAsyncRead()
// didn't fit into the pipe's system buffer.
// We're getting notified by the QWinOverlappedIoNotifier.
break;
+ case ERROR_BROKEN_PIPE:
case ERROR_PIPE_NOT_CONNECTED:
{
// It may happen, that the other side closes the connection directly
// after writing data. Then we must set the appropriate socket state.
+ readSequenceStarted = false;
pipeBroken = true;
emit pipeClosed();
return;
}
default:
- emit winError(GetLastError(), QLatin1String("QWindowsPipeReader::startAsyncRead"));
+ readSequenceStarted = false;
+ emit winError(dwError, QLatin1String("QWindowsPipeReader::startAsyncRead"));
return;
}
}