moveToTrash/Unix: reorganize the #ifdef

Change-Id: I9d43e5b91eb142d6945cfffd178708f58b71e7ef
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Thiago Macieira 2023-09-21 15:00:35 -07:00
parent 1033780b3c
commit fa97531952

View File

@ -1178,13 +1178,22 @@ bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSy
return false;
}
#ifndef Q_OS_DARWIN
#ifdef Q_OS_DARWIN
// see qfilesystemengine_mac.mm
#elif defined(QT_BOOTSTRAPPED)
// bootstrapped tools don't need this, and we don't want QStorageInfo
//static
bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &, QFileSystemEntry &,
QSystemError &error)
{
error = QSystemError(ENOSYS, QSystemError::StandardLibraryError);
return false;
}
#else
/*
Implementing as per https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html
*/
// bootstrapped tools don't need this, and we don't want QStorageInfo
#ifndef QT_BOOTSTRAPPED
static QString freeDesktopTrashLocation(const QString &sourcePath)
{
auto makeTrashDir = [](const QDir &topDir, const QString &trashDir = QString()) {
@ -1279,18 +1288,11 @@ static QString freeDesktopTrashLocation(const QString &sourcePath)
return trash;
}
#endif // QT_BOOTSTRAPPED
//static
bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
QFileSystemEntry &newLocation, QSystemError &error)
{
#ifdef QT_BOOTSTRAPPED
Q_UNUSED(source);
Q_UNUSED(newLocation);
error = QSystemError(ENOSYS, QSystemError::StandardLibraryError);
return false;
#else
const QFileInfo sourceInfo(source.filePath());
if (!sourceInfo.exists()) {
error = QSystemError(ENOENT, QSystemError::StandardLibraryError);
@ -1386,9 +1388,8 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
newLocation = std::move(target);
return true;
#endif // QT_BOOTSTRAPPED
}
#endif // Q_OS_DARWIN
#endif // !Q_OS_DARWIN && !QT_BOOTSTRAPPED
//static
bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)