File indexing completed on 2024-04-14 03:51:42

0001 /*
0002     SPDX-FileCopyrightText: 2016-2021 Harald Sitter <sitter@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "coreconfig_p.h"
0008 
0009 #include <QFile>
0010 
0011 #include <config-kcrash.h>
0012 namespace KCrash
0013 {
0014 CoreConfig::CoreConfig(const QString &path)
0015 {
0016 #if !KCRASH_CORE_PATTERN_RAISE
0017     return; // Leave everything false unless enabled.
0018 #endif
0019     QFile file(path);
0020     if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
0021         return;
0022     }
0023     char first = 0;
0024     if (!file.getChar(&first)) {
0025         return;
0026     }
0027     m_supported = true;
0028     m_process = first == '|';
0029 
0030     if (file.readLine().contains(QByteArrayLiteral("systemd-coredump"))) {
0031         m_coredumpd = true;
0032     }
0033 }
0034 
0035 bool CoreConfig::isProcess() const
0036 {
0037     return m_supported && m_process;
0038 }
0039 
0040 bool CoreConfig::isCoredumpd() const
0041 {
0042     return m_coredumpd;
0043 }
0044 
0045 } // namespace KCrash