From d3dc0f21225845f404262ea563870044cbbbe53f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 9 Jan 2013 09:11:17 +0100 Subject: Fix renaming of files that differ only in case. This currently fails on case-insensitive file systems since the check for existence then triggered and indicated "file already exists". Check on the file id (inode or file id) whether the target file is really a different file for a case-changing rename. Task-number: QTBUG-3570 Change-Id: I1b2d40850692e02142ee23d2c753428de00aedc6 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 61a1fea343..f523225ef1 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -51,6 +51,7 @@ #include #include +#include #ifdef Q_OS_WIN QT_BEGIN_NAMESPACE @@ -2418,6 +2419,7 @@ void tst_QFile::rename_data() #endif QTest::newRow("renamefile -> renamedfile") << QString::fromLatin1(renameSourceFile) << QString("renamedfile") << true; QTest::newRow("renamefile -> ..") << QString::fromLatin1(renameSourceFile) << QString("..") << false; + QTest::newRow("renamefile -> rEnAmEfIlE") << QString::fromLatin1(renameSourceFile) << QStringLiteral("rEnAmEfIlE") << true; } void tst_QFile::rename() @@ -2435,7 +2437,8 @@ void tst_QFile::rename() } #endif - QFile sourceFile(QString::fromLatin1(renameSourceFile)); + const QString sourceFileName = QString::fromLatin1(renameSourceFile); + QFile sourceFile(sourceFileName); QVERIFY2(sourceFile.open(QFile::WriteOnly | QFile::Text), qPrintable(sourceFile.errorString())); QVERIFY2(sourceFile.write(content), qPrintable(sourceFile.errorString())); sourceFile.close(); @@ -2445,7 +2448,10 @@ void tst_QFile::rename() if (result) { QVERIFY2(success, qPrintable(file.errorString())); QCOMPARE(file.error(), QFile::NoError); - QVERIFY(!sourceFile.exists()); + // This will report the source file still existing for a rename changing the case + // on Windows, Mac. + if (sourceFileName.compare(destination, Qt::CaseInsensitive)) + QVERIFY(!sourceFile.exists()); QFile destinationFile(destination); QVERIFY2(destinationFile.open(QFile::ReadOnly | QFile::Text), qPrintable(destinationFile.errorString())); QCOMPARE(destinationFile.readAll(), content); -- cgit v1.2.3