summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp13
-rw-r--r--src/corelib/io/qfilesystemwatcher_kqueue.cpp3
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp9
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp14
-rw-r--r--src/corelib/io/qsavefile.cpp6
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp10
6 files changed, 31 insertions, 24 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 24050dbbf8..5a9864edb2 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -541,13 +541,20 @@ QByteArray fileIdWin8(HANDLE handle)
QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
{
QByteArray result;
- const HANDLE handle =
+
#ifndef Q_OS_WINRT
+ const HANDLE handle =
CreateFile((wchar_t*)entry.nativeFilePath().utf16(), 0,
- FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, NULL);
#else // !Q_OS_WINRT
+ CREATEFILE2_EXTENDED_PARAMETERS params;
+ params.dwSize = sizeof(params);
+ params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
+ params.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
+ const HANDLE handle =
CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), 0,
- FILE_SHARE_READ, OPEN_EXISTING, NULL);
+ FILE_SHARE_READ, OPEN_EXISTING, &params);
#endif // Q_OS_WINRT
if (handle != INVALID_HANDLE_VALUE) {
result = id(handle);
diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp
index 4f6c83ebcf..c33fba2d1f 100644
--- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp
+++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp
@@ -111,13 +111,12 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths,
continue;
}
if (fd >= (int)FD_SETSIZE / 2 && fd < (int)FD_SETSIZE) {
- int fddup = fcntl(fd, F_DUPFD, FD_SETSIZE);
+ int fddup = qt_safe_dup(fd, FD_SETSIZE);
if (fddup != -1) {
::close(fd);
fd = fddup;
}
}
- fcntl(fd, F_SETFD, FD_CLOEXEC);
QT_STATBUF st;
if (QT_FSTAT(fd, &st) == -1) {
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index ff0d45935c..2b5cb63282 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -113,7 +113,8 @@ public:
signals:
void driveAdded();
- void driveRemoved(const QString &);
+ void driveRemoved(); // Some drive removed
+ void driveRemoved(const QString &); // Watched/known drive removed
void driveLockForRemoval(const QString &);
void driveLockForRemovalFailed(const QString &);
@@ -252,7 +253,8 @@ inline void QWindowsRemovableDriveListener::handleDbtDriveArrivalRemoval(const M
case DBT_DEVICEARRIVAL:
emit driveAdded();
break;
- case DBT_DEVICEREMOVECOMPLETE: // handled by DBT_DEVTYP_HANDLE above
+ case DBT_DEVICEREMOVECOMPLETE: // See above for handling of drives registered with watchers
+ emit driveRemoved();
break;
}
}
@@ -348,7 +350,8 @@ QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent
this, &QWindowsFileSystemWatcherEngine::driveLockForRemoval);
QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveLockForRemovalFailed,
this, &QWindowsFileSystemWatcherEngine::driveLockForRemovalFailed);
- QObject::connect(m_driveListener, &QWindowsRemovableDriveListener::driveRemoved,
+ QObject::connect(m_driveListener,
+ QOverload<const QString &>::of(&QWindowsRemovableDriveListener::driveRemoved),
this, &QWindowsFileSystemWatcherEngine::driveRemoved);
#endif // !Q_OS_WINRT
}
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 5a7057aa80..0decd26179 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -141,20 +141,6 @@ 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;
diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp
index 0283c5f31f..3f45ca5f91 100644
--- a/src/corelib/io/qsavefile.cpp
+++ b/src/corelib/io/qsavefile.cpp
@@ -232,7 +232,11 @@ bool QSaveFile::open(OpenMode mode)
}
d->fileEngine = new QTemporaryFileEngine;
- static_cast<QTemporaryFileEngine *>(d->fileEngine)->initialize(d->finalFileName, 0666);
+ // if the target file exists, we'll copy its permissions below,
+ // but until then, let's ensure the temporary file is not accessible
+ // to a third party
+ int perm = (existingFile.exists() ? 0600 : 0666);
+ static_cast<QTemporaryFileEngine *>(d->fileEngine)->initialize(d->finalFileName, perm);
// Same as in QFile: QIODevice provides the buffering, so there's no need to request it from the file engine.
if (!d->fileEngine->open(mode | QIODevice::Unbuffered)) {
QFileDevice::FileError err = d->fileEngine->error();
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index 8e3de2d620..75cb8a7ede 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -197,7 +197,15 @@ bool QWindowsPipeWriter::write(const QByteArray &ba)
overlapped, &writeFileCompleted)) {
writeSequenceStarted = false;
buffer.clear();
- qErrnoWarning("QWindowsPipeWriter::write failed.");
+
+ const DWORD errorCode = GetLastError();
+ switch (errorCode) {
+ case ERROR_NO_DATA: // "The pipe is being closed."
+ // The other end has closed the pipe. This can happen in QLocalSocket. Do not warn.
+ break;
+ default:
+ qErrnoWarning(errorCode, "QWindowsPipeWriter::write failed.");
+ }
return false;
}