summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfsfileengine_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qfsfileengine_win.cpp')
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 1cb3c03c30..23ab507dad 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -198,15 +198,25 @@ bool QFSFileEnginePrivate::nativeFlush()
return true;
}
- // Windows native mode; flushing is
- // unnecessary. FlushFileBuffers(), the equivalent of sync() or
- // fsync() on Unix, does a low-level flush to the disk, and we
- // don't expose an API for this.
+ // Windows native mode; flushing is unnecessary.
return true;
}
/*
\internal
+ \since 5.1
+*/
+bool QFSFileEnginePrivate::nativeSyncToDisk()
+{
+ if (fh || fd != -1) {
+ // stdlib / stdio mode. No API available.
+ return false;
+ }
+ return FlushFileBuffers(fileHandle);
+}
+
+/*
+ \internal
*/
qint64 QFSFileEnginePrivate::nativeSize() const
{
@@ -507,6 +517,17 @@ bool QFSFileEngine::rename(const QString &newName)
return ret;
}
+bool QFSFileEngine::renameOverwrite(const QString &newName)
+{
+ Q_D(QFSFileEngine);
+ bool ret = ::MoveFileEx((wchar_t*)d->fileEntry.nativeFilePath().utf16(),
+ (wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(),
+ MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED) != 0;
+ if (!ret)
+ setError(QFile::RenameError, QSystemError(::GetLastError(), QSystemError::NativeError).toString());
+ return ret;
+}
+
bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const
{
return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories);
@@ -900,7 +921,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
return 0;
}
- if (mapHandle == INVALID_HANDLE_VALUE) {
+ if (mapHandle == NULL) {
// get handle to the file
HANDLE handle = fileHandle;
@@ -933,7 +954,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
// first create the file mapping handle
DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY;
mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0);
- if (mapHandle == INVALID_HANDLE_VALUE) {
+ if (mapHandle == NULL) {
q->setError(QFile::PermissionsError, qt_error_string());
#ifdef Q_USE_DEPRECATED_MAP_API
::CloseHandle(handle);
@@ -976,6 +997,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
}
::CloseHandle(mapHandle);
+ mapHandle = NULL;
return 0;
}
@@ -995,7 +1017,7 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr)
maps.remove(ptr);
if (maps.isEmpty()) {
::CloseHandle(mapHandle);
- mapHandle = INVALID_HANDLE_VALUE;
+ mapHandle = NULL;
}
return true;