CTF: Use access to check if location is writable

Pick-to: 6.5
Change-Id: Ic6afcf74432f176374d47e828b480e4d2499c670
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
This commit is contained in:
Antti Määttä 2023-05-29 09:02:16 +03:00
parent 0006a564c8
commit 5e2b4c401d

View File

@ -62,16 +62,13 @@ QCtfLibImpl::QCtfLibImpl()
}
// Check if the location is writable
FILE *file = nullptr;
file = fopen(qPrintable(location + "/metadata"_L1), "w+b");
if (!file) {
if (QT_ACCESS(qPrintable(location), W_OK) != 0) {
qCWarning (lcDebugTrace) << "Unable to write to location";
return;
}
fclose(file);
const QString filename = location + QStringLiteral("/session.json");
file = fopen(qPrintable(filename), "rb");
FILE *file = fopen(qPrintable(filename), "rb");
if (!file) {
qCWarning (lcDebugTrace) << "unable to open session file: " << filename;
m_location = location;