summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 4a5860d0b1b..c67cfdb966e 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -1298,9 +1298,15 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
error = QSystemError(ENOENT, QSystemError::StandardLibraryError);
return false;
}
- const QString sourcePath = sourceInfo.absoluteFilePath();
+ const QFileSystemEntry sourcePath = [&] {
+ if (QString path = source.filePath(); path.size() > 1 && path.endsWith(u'/')) {
+ path.chop(1);
+ return absoluteName(QFileSystemEntry(path));
+ }
+ return absoluteName(source);
+ }();
- QDir trashDir(freeDesktopTrashLocation(sourcePath));
+ QDir trashDir(freeDesktopTrashLocation(sourcePath.filePath()));
if (!trashDir.exists())
return false;
/*
@@ -1324,15 +1330,12 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
file with the same name and location gets trashed many times, each subsequent
trashing must not overwrite a previous copy."
*/
- const QString trashedName = sourceInfo.isDir()
- ? QDir(sourcePath).dirName()
- : sourceInfo.fileName();
- QString uniqueTrashedName = u'/' + trashedName;
+ QString uniqueTrashedName = u'/' + sourcePath.fileName();
QString infoFileName;
int counter = 0;
QFile infoFile;
- auto makeUniqueTrashedName = [trashedName, &counter]() -> QString {
- return QString::asprintf("/%ls-%04d", qUtf16Printable(trashedName), ++counter);
+ auto makeUniqueTrashedName = [sourcePath, &counter]() -> QString {
+ return QString::asprintf("/%ls-%04d", qUtf16Printable(sourcePath.fileName()), ++counter);
};
do {
while (QFile::exists(trashDir.filePath(filesDir) + uniqueTrashedName))
@@ -1356,14 +1359,12 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
uniqueTrashedName = makeUniqueTrashedName();
} while (!infoFile.isOpen());
- QString pathForInfo;
- const QStorageInfo storageInfo(sourcePath);
+ QString pathForInfo = sourcePath.filePath();
+ const QStorageInfo storageInfo(pathForInfo);
if (storageInfo.isValid() && storageInfo.rootPath() != rootPath() && storageInfo != QStorageInfo(QDir::home())) {
- pathForInfo = sourcePath.mid(storageInfo.rootPath().length());
+ pathForInfo = std::move(pathForInfo).mid(storageInfo.rootPath().length());
if (pathForInfo.front() == u'/')
pathForInfo = pathForInfo.mid(1);
- } else {
- pathForInfo = sourcePath;
}
/*