Fix CTF with Integrity

Do not use filesystem functions with Integrity.

Change-Id: I992f560bead00df7d2783359fcb9f38326a0072b
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
This commit is contained in:
Antti Määttä 2023-10-05 14:46:23 +03:00
parent 0f2558470d
commit 33b714c64a

View File

@ -14,7 +14,10 @@
#include <qendian.h> #include <qendian.h>
#include <qplatformdefs.h> #include <qplatformdefs.h>
#include "qctflib_p.h" #include "qctflib_p.h"
#ifndef Q_OS_INTEGRITY
#include <filesystem> #include <filesystem>
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -118,6 +121,10 @@ QCtfLibImpl::QCtfLibImpl()
m_session.tracepoints.append(allLiteral()); m_session.tracepoints.append(allLiteral());
m_session.name = defaultLiteral(); m_session.name = defaultLiteral();
} else { } else {
#ifdef Q_OS_INTEGRITY
qCWarning(lcDebugTrace) << "Unable to use filesystem";
return;
#endif
// Check if the location is writable // Check if the location is writable
if (QT_ACCESS(qPrintable(location), W_OK) != 0) { if (QT_ACCESS(qPrintable(location), W_OK) != 0) {
qCWarning(lcDebugTrace) << "Unable to write to location"; qCWarning(lcDebugTrace) << "Unable to write to location";
@ -161,7 +168,9 @@ QCtfLibImpl::QCtfLibImpl()
m_session.name = defaultLiteral(); m_session.name = defaultLiteral();
} }
m_location = location + u"/ust"; m_location = location + u"/ust";
#ifndef Q_OS_INTEGRITY
std::filesystem::create_directory(qPrintable(m_location), qPrintable(location)); std::filesystem::create_directory(qPrintable(m_location), qPrintable(location));
#endif
} }
clearLocation(); clearLocation();
} }
@ -176,6 +185,7 @@ QCtfLibImpl::QCtfLibImpl()
void QCtfLibImpl::clearLocation() void QCtfLibImpl::clearLocation()
{ {
#ifndef Q_OS_INTEGRITY
const std::filesystem::path location{qUtf16Printable(m_location)}; const std::filesystem::path location{qUtf16Printable(m_location)};
for (auto const& dirEntry : std::filesystem::directory_iterator{location}) for (auto const& dirEntry : std::filesystem::directory_iterator{location})
{ {
@ -196,6 +206,7 @@ void QCtfLibImpl::clearLocation()
} }
} }
} }
#endif
} }
void QCtfLibImpl::writeMetadata(const QString &metadata, bool overwrite) void QCtfLibImpl::writeMetadata(const QString &metadata, bool overwrite)