Warning, file /frameworks/kservice/src/sycoca/ksycocadevices.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the KDE project 0003 SPDX-FileCopyrightText: 2009 David Faure <faure@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #include "kmemfile_p.h" 0009 #include "ksycocadevices_p.h" 0010 #include <QBuffer> 0011 #include <QDataStream> 0012 #include <QFile> 0013 #include <fcntl.h> 0014 0015 KSycocaAbstractDevice::~KSycocaAbstractDevice() 0016 { 0017 delete m_stream; 0018 } 0019 0020 QDataStream *&KSycocaAbstractDevice::stream() 0021 { 0022 if (!m_stream) { 0023 m_stream = new QDataStream(device()); 0024 m_stream->setVersion(QDataStream::Qt_5_3); 0025 } 0026 return m_stream; 0027 } 0028 0029 #if HAVE_MMAP 0030 KSycocaMmapDevice::KSycocaMmapDevice(const char *sycoca_mmap, size_t sycoca_size) 0031 { 0032 m_buffer = new QBuffer; 0033 m_buffer->setData(QByteArray::fromRawData(sycoca_mmap, sycoca_size)); 0034 } 0035 0036 KSycocaMmapDevice::~KSycocaMmapDevice() 0037 { 0038 delete m_buffer; 0039 } 0040 0041 QIODevice *KSycocaMmapDevice::device() 0042 { 0043 return m_buffer; 0044 } 0045 #endif 0046 0047 KSycocaFileDevice::KSycocaFileDevice(const QString &path) 0048 { 0049 m_database = new QFile(path); 0050 #ifndef Q_OS_WIN 0051 (void)fcntl(m_database->handle(), F_SETFD, FD_CLOEXEC); 0052 #endif 0053 } 0054 0055 KSycocaFileDevice::~KSycocaFileDevice() 0056 { 0057 delete m_database; 0058 } 0059 0060 QIODevice *KSycocaFileDevice::device() 0061 { 0062 return m_database; 0063 } 0064 0065 #ifndef QT_NO_SHAREDMEMORY 0066 KSycocaMemFileDevice::KSycocaMemFileDevice(const QString &path) 0067 { 0068 m_database = new KMemFile(path); 0069 } 0070 0071 KSycocaMemFileDevice::~KSycocaMemFileDevice() 0072 { 0073 delete m_database; 0074 } 0075 0076 QIODevice *KSycocaMemFileDevice::device() 0077 { 0078 return m_database; 0079 } 0080 #endif 0081 0082 KSycocaBufferDevice::KSycocaBufferDevice() 0083 { 0084 m_buffer = new QBuffer; 0085 } 0086 0087 KSycocaBufferDevice::~KSycocaBufferDevice() 0088 { 0089 delete m_buffer; 0090 } 0091 0092 QIODevice *KSycocaBufferDevice::device() 0093 { 0094 return m_buffer; 0095 }