summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfsfileengine_win.cpp
diff options
context:
space:
mode:
authorDavid Faure <faure+bluesystems@kde.org>2013-01-14 09:34:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-14 23:44:15 +0100
commit7e7b65c370207fa849ac0ec69fe9209f08d8f2e3 (patch)
treec3e45fa2fcfe34eb5eefdfe6a70aa32eeaa27851 /src/corelib/io/qfsfileengine_win.cpp
parent18c916517f3004d34482c20ed66bf09ec274d385 (diff)
Add renameOverwrite() to QAbstractFileEngine.
QFSFileEngine::rename() on Windows doesn't overwrite the existing destination. Keep that unchanged (it's the desired behavior in QFile::rename), and provide cross-platform rename-overwrite behavior in the new method. This is needed by QSaveFile. Change-Id: I5e753d289d8a53692530a48a1783d62e26169cdc Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qfsfileengine_win.cpp')
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index d12a95f98a..86e9bf971d 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -507,6 +507,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);