Also prevent use of std::filesystem in macOS 10.14

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-03-28 18:21:19 +08:00 committed by Claudio Cambra
parent 42504d0a0f
commit f13a0fc732
2 changed files with 10 additions and 0 deletions

View File

@ -17,7 +17,9 @@
#include <QJsonValue> #include <QJsonValue>
#include <memory> #include <memory>
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
#include <filesystem> #include <filesystem>
#endif
PathComponents::PathComponents(const char *path) PathComponents::PathComponents(const char *path)
: PathComponents { QString::fromUtf8(path) } : PathComponents { QString::fromUtf8(path) }
@ -50,9 +52,11 @@ void DiskFileModifier::remove(const QString &relativePath)
if (fi.isFile()) { if (fi.isFile()) {
QVERIFY(_rootDir.remove(relativePath)); QVERIFY(_rootDir.remove(relativePath));
} else { } else {
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
const auto pathToDelete = fi.filePath().toStdWString(); const auto pathToDelete = fi.filePath().toStdWString();
std::filesystem::permissions(pathToDelete, std::filesystem::perms::owner_exec, std::filesystem::perm_options::add); std::filesystem::permissions(pathToDelete, std::filesystem::perms::owner_exec, std::filesystem::perm_options::add);
QVERIFY(std::filesystem::remove_all(pathToDelete)); QVERIFY(std::filesystem::remove_all(pathToDelete));
#endif
} }
} }

View File

@ -11,7 +11,9 @@
#include <QtTest> #include <QtTest>
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
#include <filesystem> #include <filesystem>
#endif
#include <iostream> #include <iostream>
using namespace OCC; using namespace OCC;
@ -77,6 +79,7 @@ private slots:
Logger::instance()->setLogDebug(true); Logger::instance()->setLogDebug(true);
} }
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
void t7pl() void t7pl()
{ {
FakeFolder fakeFolder{ FileInfo() }; FakeFolder fakeFolder{ FileInfo() };
@ -384,6 +387,7 @@ private slots:
QCOMPARE(count, 2); QCOMPARE(count, 2);
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
} }
#endif
static void setAllPerm(FileInfo *fi, OCC::RemotePermissions perm) static void setAllPerm(FileInfo *fi, OCC::RemotePermissions perm)
{ {
@ -592,6 +596,7 @@ private slots:
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
} }
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
static void demo_perms(std::filesystem::perms p) static void demo_perms(std::filesystem::perms p)
{ {
using std::filesystem::perms; using std::filesystem::perms;
@ -741,6 +746,7 @@ private slots:
QVERIFY(testFolderStatus.permissions() & std::filesystem::perms::owner_read); QVERIFY(testFolderStatus.permissions() & std::filesystem::perms::owner_read);
QVERIFY(!static_cast<bool>(testFolderStatus.permissions() & std::filesystem::perms::owner_write)); QVERIFY(!static_cast<bool>(testFolderStatus.permissions() & std::filesystem::perms::owner_write));
} }
#endif
}; };
QTEST_GUILESS_MAIN(TestPermissions) QTEST_GUILESS_MAIN(TestPermissions)