9#include "ksycocadict_p.h"
10#include "ksycocaentry.h"
11#include "ksycocaentry_p.h"
12#include "ksycocafactory_p.h"
13#include "ksycocatype.h"
14#include "sycocadebug.h"
21class KSycocaFactoryPrivate
24 KSycocaFactoryPrivate()
27 ~KSycocaFactoryPrivate()
33 int m_sycocaDictOffset = 0;
34 int m_beginEntryOffset = 0;
35 int m_endEntryOffset = 0;
36 KSycocaDict *m_sycocaDict =
nullptr;
41 , d(new KSycocaFactoryPrivate)
43 if (!m_sycoca->isBuilding() && (m_str = m_sycoca->findFactory(factory_id))) {
47 d->m_sycocaDictOffset = i;
49 d->m_beginEntryOffset = i;
51 d->m_endEntryOffset = i;
53 QDataStream *str = stream();
54 qint64 saveOffset = str->device()->pos();
56 d->m_sycocaDict = new KSycocaDict(str, d->m_sycocaDictOffset);
57 saveOffset = str->device()->seek(saveOffset);
60 m_entryDict = new KSycocaEntryDict;
61 d->m_sycocaDict = new KSycocaDict;
62 d->m_beginEntryOffset = 0;
63 d->m_endEntryOffset = 0;
67 m_sycoca->addFactory(
this);
70KSycocaFactory::~KSycocaFactory()
79 str << qint32(d->m_sycocaDictOffset);
80 str << qint32(d->m_beginEntryOffset);
81 str << qint32(d->m_endEntryOffset);
89 if (!d->m_sycocaDict) {
94 d->m_sycocaDictOffset = 0;
99 d->m_beginEntryOffset = str.
device()->
pos();
104 entry->d_ptr->save(str);
108 d->m_endEntryOffset = str.
device()->
pos();
112 str << qint32(entryCount);
114 str << qint32(entry.data()->offset());
118 d->m_sycocaDictOffset = str.
device()->
pos();
119 d->m_sycocaDict->save(str);
121 qint64 endOfFactoryData = str.
device()->
pos();
137 if (!d->m_sycocaDict) {
152 removeEntry(newEntry->storageId());
156 m_entryDict->insert(name, newEntry);
157 d->m_sycocaDict->add(name, newEntry);
160void KSycocaFactory::removeEntry(
const QString &entryName)
167 if (!d->m_sycocaDict) {
171 m_entryDict->remove(entryName);
172 d->m_sycocaDict->remove(entryName);
187 (*str) >> entryCount;
189 if (entryCount > 8192) {
196 qint32 *offsetList =
new qint32[entryCount];
197 for (
int i = 0; i < entryCount; i++) {
198 (*str) >> offsetList[i];
201 for (
int i = 0; i < entryCount; i++) {
211int KSycocaFactory::offset()
const
216const KSycocaResourceList &KSycocaFactory::resourceList()
const
218 return m_resourceList;
221const KSycocaDict *KSycocaFactory::sycocaDict()
const
223 return d->m_sycocaDict;
226bool KSycocaFactory::isEmpty()
const
228 return d->m_beginEntryOffset == d->m_endEntryOffset;
240 for (
auto &dir : topDirs) {
246void KSycocaFactory::virtual_hook(
int ,
void * )
Base class for all Sycoca entries.
static void flagError()
A read error occurs.
KSycocaFactoryId
A KSycocaFactoryId is a code (out of the KSycocaFactoryId enum) assigned to each class type derived f...
KIOCORE_EXPORT QString dir(const QString &fileClass)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QString name(StandardAction id)
QIODevice * device() const const
virtual qint64 pos() const const
virtual bool seek(qint64 pos)
void append(QList< T > &&value)
QStringList standardLocations(StandardLocation type)
QThread * currentThread()