diff options
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 4 | ||||
-rw-r--r-- | tests/auto/corelib/io/qfile/tst_qfile.cpp | 20 |
2 files changed, 14 insertions, 10 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 75ad5d3cc5..a4f47cbf24 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1548,8 +1548,8 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, QFileSystemEntry &newLocation, QSystemError &error) { #ifndef Q_OS_WINRT - // we need the "display name" of the file, so can't use nativeFilePath - const QString sourcePath = QDir::toNativeSeparators(source.filePath()); + // we need the "display name" of the file, so can't use nativeAbsoluteFilePath + const QString sourcePath = QDir::toNativeSeparators(absoluteName(source).filePath()); /* Windows 7 insists on showing confirmation dialogs and ignores the respective diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 2e4ed2fba1..624ab39188 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -3714,13 +3714,6 @@ void tst_QFile::moveToTrash() QFETCH(bool, create); QFETCH(bool, result); - /* This test makes assumptions about the file system layout - which might be wrong - moveToTrash may fail if the file lives - on a file system that is different from the home file system, and - has no .Trash directory. - */ - const bool mayFail = QStorageInfo(source) != QStorageInfo(QDir::home()); - #if defined(Q_OS_WINRT) QSKIP("WinRT does not have a trash", SkipAll); #endif @@ -3749,9 +3742,20 @@ void tst_QFile::moveToTrash() sourceFile.remove(); } }; + + ensureFile(source, create); + + /* This test makes assumptions about the file system layout + which might be wrong - moveToTrash may fail if the file lives + on a file system that is different from the home file system, and + has no .Trash directory. + */ + const QStorageInfo sourceStorage(source); + const bool mayFail = sourceStorage.isValid() + && QStorageInfo(source) != QStorageInfo(QDir::home()); + // non-static version { - ensureFile(source, create); QFile sourceFile(source); const bool success = sourceFile.moveToTrash(); |