CTF: Use wfopen in windows
Change-Id: If54fe2b0af32a097cac6f485900ec5e353d92dd9 Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> (cherry picked from commit cc3f18e5e91c3c378ade45ec4c13d756bb9b5ae9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
687415e10c
commit
4f5b6967bb
@ -38,6 +38,15 @@ static QByteArray &operator<<(QByteArray &arr, T val)
|
||||
return arr;
|
||||
}
|
||||
|
||||
static FILE *openFile(const QString &filename, const QString &mode)
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
return _wfopen(qUtf16Printable(filename), qUtf16Printable(mode));
|
||||
#else
|
||||
return fopen(qPrintable(filename), qPrintable(mode));
|
||||
#endif
|
||||
}
|
||||
|
||||
QCtfLibImpl *QCtfLibImpl::s_instance = nullptr;
|
||||
|
||||
QCtfLib *QCtfLibImpl::instance()
|
||||
@ -68,7 +77,7 @@ QCtfLibImpl::QCtfLibImpl()
|
||||
}
|
||||
|
||||
const QString filename = location + QStringLiteral("/session.json");
|
||||
FILE *file = fopen(qPrintable(filename), "rb");
|
||||
FILE *file = openFile(qPrintable(filename), "rb"_L1);
|
||||
if (!file) {
|
||||
qCWarning(lcDebugTrace) << "unable to open session file: "
|
||||
<< filename << ", " << qt_error_string();
|
||||
@ -134,7 +143,7 @@ QCtfLibImpl::QCtfLibImpl()
|
||||
void QCtfLibImpl::writeMetadata(const QString &metadata, bool overwrite)
|
||||
{
|
||||
FILE *file = nullptr;
|
||||
file = fopen(qPrintable(m_location + "/metadata"_L1), overwrite ? "w+b": "ab");
|
||||
file = openFile(qPrintable(m_location + "/metadata"_L1), overwrite ? "w+b"_L1: "ab"_L1);
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
@ -150,7 +159,7 @@ void QCtfLibImpl::writeMetadata(const QString &metadata, bool overwrite)
|
||||
void QCtfLibImpl::writeCtfPacket(QCtfLibImpl::Channel &ch)
|
||||
{
|
||||
FILE *file = nullptr;
|
||||
file = fopen(ch.channelName, "ab");
|
||||
file = openFile(ch.channelName, "ab"_L1);
|
||||
if (file) {
|
||||
/* Each packet contains header and context, which are defined in the metadata.txt */
|
||||
QByteArray packet;
|
||||
@ -273,7 +282,7 @@ void QCtfLibImpl::doTracepoint(const QCtfTracePointEvent &point, const QByteArra
|
||||
m_threadIndices.insert(thread, m_threadIndices.size());
|
||||
sprintf(ch.channelName, "%s/channel_%d", qPrintable(m_location), m_threadIndices[thread]);
|
||||
FILE *f = nullptr;
|
||||
f = fopen(ch.channelName, "wb");
|
||||
f = openFile(ch.channelName, "wb"_L1);
|
||||
if (f)
|
||||
fclose(f);
|
||||
ch.minTimestamp = ch.maxTimestamp = timestamp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user