diff options
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 42739097f2..01aed7ad14 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -44,6 +44,7 @@ #include "qfile.h" #include "qstorageinfo.h" #include "qtextstream.h" +#include "qurl.h" #include <QtCore/qoperatingsystemversion.h> #include <QtCore/private/qcore_unix_p.h> @@ -1392,6 +1393,16 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, const QString targetPath = trashDir.filePath(filesDir) + uniqueTrashedName; const QFileSystemEntry target(targetPath); + QString infoPath; + const QStorageInfo storageInfo(sourcePath); + if (storageInfo.isValid() && storageInfo.rootPath() != rootPath() && storageInfo != QStorageInfo(QDir::home())) { + infoPath = sourcePath.mid(storageInfo.rootPath().length()); + if (infoPath.front() == u'/') + infoPath = infoPath.mid(1); + } else { + infoPath = sourcePath; + } + /* We might fail to rename if source and target are on different file systems. In that case, we don't try further, i.e. copying and removing the original @@ -1408,7 +1419,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, out.setCodec("UTF-8"); #endif out << "[Trash Info]" << Qt::endl; - out << "Path=" << sourcePath << Qt::endl; + out << "Path=" << QUrl::toPercentEncoding(infoPath, "/") << Qt::endl; out << "DeletionDate=" << QDateTime::currentDateTime().toString(QLatin1String("yyyy-MM-ddThh:mm:ss")) << Qt::endl; infoFile.close(); |