Krita Source Code Documentation
Loading...
Searching...
No Matches
KoStorePrivate Class Reference

#include <KoStore_p.h>

Public Member Functions

bool enterDirectoryInternal (const QString &directory)
 
bool extractFile (const QString &sourceName, QIODevice &buffer)
 
 KoStorePrivate (KoStore *qq, KoStore::Mode _mode, bool _writeMimetype)
 
QString toExternalNaming (const QString &internalNaming) const
 

Public Attributes

QStringList currentPath
 The "current directory" (path)
 
QStack< QString > directoryStack
 
QString fileName
 Current filename (between an open() and a close())
 
QStringList filesList
 Store the filenames (with full path inside the archive) when writing, to avoid duplicates.
 
bool finalized
 
bool good
 Must be set by the constructor.
 
bool isOpen
 
QString localFileName
 
KoStore::Mode mode
 
KoStoreq
 
qint64 size
 Current size of the file named m_sName.
 
QIODevice * stream
 The stream for the current read or write operation.
 
QString substituteThis
 
QString substituteWith
 
QUrl url
 
QWidget * window
 
bool writeMimetype
 true if the backend is allowed to create "mimetype" automatically.
 

Detailed Description

Definition at line 20 of file KoStore_p.h.

Constructor & Destructor Documentation

◆ KoStorePrivate()

KoStorePrivate::KoStorePrivate ( KoStore * qq,
KoStore::Mode _mode,
bool _writeMimetype )
inlineexplicit

Definition at line 23 of file KoStore_p.h.

24 : q(qq),
25 window(0),
26 mode(_mode),
27 size(0),
28 stream(0),
29 isOpen(false),
30 good(false),
31 finalized(false),
32 writeMimetype(_writeMimetype)
33 {
34 }
QWidget * window
Definition KoStore_p.h:62
bool writeMimetype
true if the backend is allowed to create "mimetype" automatically.
Definition KoStore_p.h:87
KoStore * q
Definition KoStore_p.h:59
bool good
Must be set by the constructor.
Definition KoStore_p.h:82
KoStore::Mode mode
Definition KoStore_p.h:64
QIODevice * stream
The stream for the current read or write operation.
Definition KoStore_p.h:78
qint64 size
Current size of the file named m_sName.
Definition KoStore_p.h:75

Member Function Documentation

◆ enterDirectoryInternal()

bool KoStorePrivate::enterDirectoryInternal ( const QString & directory)

Enter one single directory. Nothing like foo/bar/bleh allowed. Performs some checking when in Read mode

Definition at line 375 of file KoStore.cpp.

376{
377 if (q->enterRelativeDirectory(directory)) {
378 currentPath.append(directory);
379 return true;
380 }
381 return false;
382}
QStringList currentPath
The "current directory" (path)
Definition KoStore_p.h:70
virtual bool enterRelativeDirectory(const QString &dirName)=0

References currentPath, KoStore::enterRelativeDirectory(), and q.

◆ extractFile()

bool KoStorePrivate::extractFile ( const QString & sourceName,
QIODevice & buffer )

Definition at line 315 of file KoStore.cpp.

316{
317 if (!q->open(srcName))
318 return false;
319
320 if (!buffer.open(QIODevice::WriteOnly)) {
321 q->close();
322 return false;
323 }
324
325 QByteArray data;
326 data.resize(8 * 1024);
327 uint total = 0;
328 for (int block = 0; (block = q->read(data.data(), data.size())) > 0; total += block) {
329 buffer.write(data.data(), block);
330 }
331
332 if (q->size() != static_cast<qint64>(-1))
333 Q_ASSERT(total == q->size());
334
335 buffer.close();
336 q->close();
337
338 return true;
339}
unsigned int uint
bool close()
Definition KoStore.cpp:156
qint64 size() const
Definition KoStore.cpp:239
bool open(const QString &name)
Definition KoStore.cpp:109
QByteArray read(qint64 max)
Definition KoStore.cpp:181

References KoStore::close(), KoStore::open(), q, KoStore::read(), and KoStore::size().

◆ toExternalNaming()

QString KoStorePrivate::toExternalNaming ( const QString & internalNaming) const

Conversion routine

Parameters
internalNamingname used internally : "root", "tar:/0", ...
Returns
the name used in the file, more user-friendly ("maindoc.xml", "part0/maindoc.xml", ...) Examples:

tar:/0 is saved as part0/maindoc.xml tar:/0/1 is saved as part0/part1/maindoc.xml tar:/0/1/pictures/picture0.png is saved as part0/part1/pictures/picture0.png

see specification (calligra/lib/store/SPEC) for details.

Definition at line 360 of file KoStore.cpp.

361{
362 if (_internalNaming == ROOTPART)
363 return q->currentPath() + MAINNAME;
364
365 QString intern;
366 if (_internalNaming.startsWith("tar:/")) // absolute reference
367 intern = _internalNaming.mid(5); // remove protocol
368 else
369 intern = q->currentPath() + _internalNaming;
370
371 return intern;
372}
QString currentPath() const
Definition KoStore.cpp:281

References KoStore::currentPath(), and q.

Member Data Documentation

◆ currentPath

QStringList KoStorePrivate::currentPath

The "current directory" (path)

Definition at line 70 of file KoStore_p.h.

◆ directoryStack

QStack<QString> KoStorePrivate::directoryStack

Definition at line 85 of file KoStore_p.h.

◆ fileName

QString KoStorePrivate::fileName

Current filename (between an open() and a close())

Definition at line 73 of file KoStore_p.h.

◆ filesList

QStringList KoStorePrivate::filesList

Store the filenames (with full path inside the archive) when writing, to avoid duplicates.

Definition at line 67 of file KoStore_p.h.

◆ finalized

bool KoStorePrivate::finalized

Definition at line 83 of file KoStore_p.h.

◆ good

bool KoStorePrivate::good

Must be set by the constructor.

Definition at line 82 of file KoStore_p.h.

◆ isOpen

bool KoStorePrivate::isOpen

Definition at line 80 of file KoStore_p.h.

◆ localFileName

QString KoStorePrivate::localFileName

Definition at line 61 of file KoStore_p.h.

◆ mode

KoStore::Mode KoStorePrivate::mode

Definition at line 64 of file KoStore_p.h.

◆ q

KoStore* KoStorePrivate::q

Definition at line 59 of file KoStore_p.h.

◆ size

qint64 KoStorePrivate::size

Current size of the file named m_sName.

Definition at line 75 of file KoStore_p.h.

◆ stream

QIODevice* KoStorePrivate::stream

The stream for the current read or write operation.

Definition at line 78 of file KoStore_p.h.

◆ substituteThis

QString KoStorePrivate::substituteThis

Definition at line 89 of file KoStore_p.h.

◆ substituteWith

QString KoStorePrivate::substituteWith

Definition at line 90 of file KoStore_p.h.

◆ url

QUrl KoStorePrivate::url

Definition at line 92 of file KoStore_p.h.

◆ window

QWidget* KoStorePrivate::window

Definition at line 62 of file KoStore_p.h.

◆ writeMimetype

bool KoStorePrivate::writeMimetype

true if the backend is allowed to create "mimetype" automatically.

Definition at line 87 of file KoStore_p.h.


The documentation for this class was generated from the following files: