summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-03-20 08:44:28 +0100
committerLiang Qi <liang.qi@qt.io>2017-03-20 09:00:44 +0100
commitae2695535a2f1abbd4c6596a22dd33319b9388dd (patch)
tree91df41df365a13ea71b1361d909535e5b7a7360a /src/corelib/io
parent8066ae49433ed7604e710eef7b15d15de171608e (diff)
parentc1a2f97a3b3a8c058b1760b57e5c83bf7815b84a (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/corelib/io/qfilesystemengine_win.cpp src/gui/text/qdistancefield.cpp src/plugins/platforms/xcb/qxcbconnection.h Change-Id: I1be4a6f440ccb7599991159e3cb9de60990e4b1e
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/forkfd_qt.cpp1
-rw-r--r--src/corelib/io/io.pri18
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp29
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp20
-rw-r--r--src/corelib/io/qprocess.cpp9
-rw-r--r--src/corelib/io/qprocess.h8
-rw-r--r--src/corelib/io/qprocess_p.h9
-rw-r--r--src/corelib/io/qprocess_unix.cpp6
-rw-r--r--src/corelib/io/qprocess_win.cpp6
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h2
10 files changed, 59 insertions, 49 deletions
diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp
index 141efeb08c..dce0ebb4da 100644
--- a/src/corelib/io/forkfd_qt.cpp
+++ b/src/corelib/io/forkfd_qt.cpp
@@ -39,7 +39,6 @@
// these might be defined via precompiled headers
#include <QtCore/qatomic.h>
-#include "qprocess_p.h"
#define FORKFD_NO_SPAWNFD
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 78416cdf5e..b0cac59f42 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -22,8 +22,6 @@ HEADERS += \
io/qlockfile.h \
io/qlockfile_p.h \
io/qnoncontiguousbytedevice_p.h \
- io/qprocess.h \
- io/qprocess_p.h \
io/qtextstream.h \
io/qtextstream_p.h \
io/qtemporarydir.h \
@@ -72,7 +70,6 @@ SOURCES += \
io/qiodevice.cpp \
io/qlockfile.cpp \
io/qnoncontiguousbytedevice.cpp \
- io/qprocess.cpp \
io/qstorageinfo.cpp \
io/qtextstream.cpp \
io/qtemporarydir.cpp \
@@ -96,6 +93,19 @@ SOURCES += \
io/qloggingcategory.cpp \
io/qloggingregistry.cpp
+qtConfig(processenvironment) {
+ SOURCES += \
+ io/qprocess.cpp
+ HEADERS += \
+ io/qprocess.h \
+ io/qprocess_p.h
+
+ win32:!winrt: \
+ SOURCES += io/qprocess_win.cpp
+ else: unix: \
+ SOURCES += io/qprocess_unix.cpp
+}
+
win32 {
SOURCES += io/qfsfileengine_win.cpp
SOURCES += io/qlockfile_win.cpp
@@ -112,7 +122,6 @@ win32 {
io/qwinoverlappedionotifier_p.h
SOURCES += \
- io/qprocess_win.cpp \
io/qsettings_win.cpp \
io/qstandardpaths_win.cpp \
io/qstorageinfo_win.cpp \
@@ -132,7 +141,6 @@ win32 {
io/qfsfileengine_unix.cpp \
io/qfilesystemengine_unix.cpp \
io/qlockfile_unix.cpp \
- io/qprocess_unix.cpp \
io/qfilesystemiterator_unix.cpp
!integrity:!uikit {
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 48c72bb9ec..d95a6de777 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -151,14 +151,15 @@ QT_BEGIN_NAMESPACE
Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0;
#if defined(Q_OS_WINRT)
-// As none of the functions we try to resolve do exist on WinRT
-// we use QT_NO_LIBRARY to shorten everything up a little bit.
-# ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY 1
-# endif
+// As none of the functions we try to resolve do exist on WinRT we
+// avoid library loading on WinRT in general to shorten everything
+// up a little bit.
+# define QT_FEATURE_fslibs -1
+#else
+# define QT_FEATURE_fslibs QT_FEATURE_library
#endif // Q_OS_WINRT
-#if !defined(QT_NO_LIBRARY)
+#if QT_CONFIG(fslibs)
QT_BEGIN_INCLUDE_NAMESPACE
typedef DWORD (WINAPI *PtrGetNamedSecurityInfoW)(LPWSTR, SE_OBJECT_TYPE, SECURITY_INFORMATION, PSID*, PSID*, PACL*, PACL*, PSECURITY_DESCRIPTOR*);
static PtrGetNamedSecurityInfoW ptrGetNamedSecurityInfoW = 0;
@@ -255,7 +256,7 @@ struct LibResolver
Q_GLOBAL_STATIC(LibResolver, resolveLibs)
} // anonymous namespace
-#endif // QT_NO_LIBRARY
+#endif // QT_CONFIG(fslibs)
QT_BEGIN_INCLUDE_NAMESPACE
typedef DWORD (WINAPI *PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE*, DWORD, LPDWORD, LPDWORD, LPDWORD);
@@ -327,7 +328,7 @@ static QString readSymLink(const QFileSystemEntry &link)
free(rdb);
CloseHandle(handle);
-#if !defined(QT_NO_LIBRARY)
+#if QT_CONFIG(fslibs)
resolveLibs();
QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
if (matchVolName.indexIn(result) == 0) {
@@ -337,7 +338,7 @@ static QString readSymLink(const QFileSystemEntry &link)
if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0)
result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
}
-#endif // !Q_OS_WINRT
+#endif // QT_CONFIG(fslibs)
}
#else
Q_UNUSED(link);
@@ -347,7 +348,7 @@ static QString readSymLink(const QFileSystemEntry &link)
static QString readLink(const QFileSystemEntry &link)
{
-#if !defined(QT_NO_LIBRARY)
+#if QT_CONFIG(fslibs)
QString ret;
bool neededCoInit = false;
@@ -386,7 +387,7 @@ static QString readLink(const QFileSystemEntry &link)
#else
Q_UNUSED(link);
return QString();
-#endif // QT_NO_LIBRARY
+#endif // QT_CONFIG(fslibs)
}
static bool uncShareExists(const QString &server)
@@ -619,7 +620,7 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEngine::FileOwner own)
{
QString name;
-#if !defined(QT_NO_LIBRARY)
+#if QT_CONFIG(fslibs)
extern int qt_ntfs_permission_lookup;
if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) {
resolveLibs();
@@ -669,7 +670,7 @@ QString QFileSystemEngine::owner(const QFileSystemEntry &entry, QAbstractFileEng
bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSystemMetaData &data,
QFileSystemMetaData::MetaDataFlags what)
{
-#if !defined(QT_NO_LIBRARY)
+#if QT_CONFIG(fslibs)
if((qt_ntfs_permission_lookup > 0) && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) {
resolveLibs();
if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) {
@@ -1133,7 +1134,7 @@ QString QFileSystemEngine::rootPath()
QString QFileSystemEngine::homePath()
{
QString ret;
-#if !defined(QT_NO_LIBRARY)
+#if QT_CONFIG(fslibs)
resolveLibs();
if (ptrGetUserProfileDirectoryW) {
HANDLE hnd = ::GetCurrentProcess();
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 2ebc98e0de..4a477b8429 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -108,6 +108,20 @@ bool QFSFileEnginePrivate::nativeOpen(QIODevice::OpenMode openMode)
{
Q_Q(QFSFileEngine);
+ // Check if the file name is valid:
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
+ const QString fileName = fileEntry.fileName();
+ for (QString::const_iterator it = fileName.constBegin(), end = fileName.constEnd();
+ it != end; ++it) {
+ const QChar c = *it;
+ if (c == QLatin1Char('<') || c == QLatin1Char('>') || c == QLatin1Char(':') ||
+ c == QLatin1Char('\"') || c == QLatin1Char('/') || c == QLatin1Char('\\') ||
+ c == QLatin1Char('|') || c == QLatin1Char('?') || c == QLatin1Char('*')) {
+ q->setError(QFile::OpenError, QStringLiteral("Invalid file name"));
+ return false;
+ }
+ }
+
// All files are opened in share mode (both read and write).
DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
@@ -589,7 +603,7 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons
bool QFSFileEngine::link(const QString &newName)
{
#if !defined(Q_OS_WINRT)
-# if !defined(QT_NO_LIBRARY)
+# if QT_CONFIG(library)
bool ret = false;
QString linkName = newName;
@@ -630,10 +644,10 @@ bool QFSFileEngine::link(const QString &newName)
CoUninitialize();
return ret;
-# else // QT_NO_LIBRARY
+# else // QT_CONFIG(library)
Q_UNUSED(newName);
return false;
-# endif // QT_NO_LIBRARY
+# endif // QT_CONFIG(library)
#else // !Q_OS_WINRT
Q_UNUSED(newName);
Q_UNIMPLEMENTED();
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index c27484acbe..c0ec35ff32 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -99,8 +99,6 @@ QT_END_NAMESPACE
#include <private/qcore_unix_p.h>
#endif
-#if QT_CONFIG(processenvironment)
-
QT_BEGIN_NAMESPACE
/*!
@@ -430,8 +428,6 @@ void QProcessEnvironment::insert(const QProcessEnvironment &e)
d->insert(*e.d);
}
-#endif // QT_CONFIG(processenvironment)
-
#if QT_CONFIG(process)
void QProcessPrivate::Channel::clear()
@@ -2605,9 +2601,8 @@ QString QProcess::nullDevice()
\sa QProcess::pid()
*/
+#endif // QT_CONFIG(process)
+
QT_END_NAMESPACE
#include "moc_qprocess.cpp"
-
-#endif // QT_NO_PROCESS
-
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 37e71aef5d..19157bdd02 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -46,12 +46,12 @@
#include <functional>
+QT_REQUIRE_CONFIG(processenvironment);
+
QT_BEGIN_NAMESPACE
class QProcessPrivate;
-#if QT_CONFIG(processenvironment)
-
#if !defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
typedef qint64 Q_PID;
#else
@@ -105,8 +105,6 @@ private:
Q_DECLARE_SHARED(QProcessEnvironment)
-#endif // QT_CONFIG(processenvironment)
-
#if QT_CONFIG(process)
class Q_CORE_EXPORT QProcess : public QIODevice
@@ -302,7 +300,7 @@ private:
friend class QProcessManager;
};
-#endif // QT_NO_PROCESS
+#endif // QT_CONFIG(process)
QT_END_NAMESPACE
diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h
index 92b747f6ba..6e0630eb66 100644
--- a/src/corelib/io/qprocess_p.h
+++ b/src/corelib/io/qprocess_p.h
@@ -57,6 +57,9 @@
#include "QtCore/qhash.h"
#include "QtCore/qshareddata.h"
#include "private/qiodevice_p.h"
+
+QT_REQUIRE_CONFIG(processenvironment);
+
#ifdef Q_OS_UNIX
#include <QtCore/private/qorderedmutexlocker_p.h>
#endif
@@ -78,8 +81,6 @@ class QWindowsPipeWriter;
class QWinEventNotifier;
class QTimer;
-#if QT_CONFIG(processenvironment)
-
#ifdef Q_OS_WIN
class QProcEnvKey : public QString
{
@@ -233,8 +234,6 @@ template<> Q_INLINE_TEMPLATE void QSharedDataPointer<QProcessEnvironmentPrivate>
d = x;
}
-#endif // QT_CONFIG(processenvironment)
-
#if QT_CONFIG(process)
class QProcessPrivate : public QIODevicePrivate
@@ -390,7 +389,7 @@ public:
void setErrorAndEmit(QProcess::ProcessError error, const QString &description = QString());
};
-#endif // QT_NO_PROCESS
+#endif // QT_CONFIG(process)
QT_END_NAMESPACE
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index deca5c50ff..795229419c 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -119,7 +119,7 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
-#if QT_CONFIG(processenvironment) && !defined(Q_OS_DARWIN)
+#if !defined(Q_OS_DARWIN)
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
@@ -138,7 +138,7 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment()
return env;
}
-#endif // QT_CONFIG(processenvironment) && !defined(Q_OS_DARWIN)
+#endif // !defined(Q_OS_DARWIN)
#if QT_CONFIG(process)
@@ -1040,6 +1040,6 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
return success;
}
-#endif // QT_NO_PROCESS
+#endif // QT_CONFIG(process)
QT_END_NAMESPACE
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index aa69e9e1db..329d1842f0 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -62,8 +62,6 @@
QT_BEGIN_NAMESPACE
-#if QT_CONFIG(processenvironment)
-
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
@@ -86,8 +84,6 @@ QProcessEnvironment QProcessEnvironment::systemEnvironment()
return env;
}
-#endif // QT_CONFIG(processenvironment)
-
#if QT_CONFIG(process)
static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe)
@@ -895,6 +891,6 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
return success;
}
-#endif // QT_NO_PROCESS
+#endif // QT_CONFIG(process)
QT_END_NAMESPACE
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h
index 5a0d04855f..c43e986f34 100644
--- a/src/corelib/io/qwindowspipewriter_p.h
+++ b/src/corelib/io/qwindowspipewriter_p.h
@@ -156,4 +156,4 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_PROCESS
+#endif // QWINDOWSPIPEWRITER_P_H