|
Krita Source Code Documentation
|
#include <KoStore.h>
Inheritance diagram for KoStore:Public Types | |
| enum | Backend { Auto , Zip , Directory } |
| enum | Mode { Read , Write } |
Public Member Functions | |
| bool | atEnd () const |
| bool | bad () const |
| bool | close () |
| QString | currentPath () const |
| QIODevice * | device () const |
| virtual QStringList | directoryList () const |
| virtual bool | enterDirectory (const QString &directory) |
| bool | extractFile (const QString &sourceName, QByteArray &data) |
| bool | finalize () |
| bool | hasDirectory (const QString &directoryName) |
| bool | hasFile (const QString &fileName) const |
| bool | isOpen () const |
| bool | leaveDirectory () |
| Mode | mode () const |
| bool | open (const QString &name) |
| void | popDirectory () |
| qint64 | pos () const |
| void | pushDirectory () |
| qint64 | read (char *buffer, qint64 length) |
| QByteArray | read (qint64 max) |
| bool | seek (qint64 pos) |
| See QIODevice. | |
| virtual void | setCompressionEnabled (bool e) |
| void | setSubstitution (const QString &name, const QString &substitution) |
| When reading, in the paths in the store where name occurs, substitution is used. | |
| qint64 | size () const |
| virtual qint64 | write (const char *data, qint64 length) |
| qint64 | write (const QByteArray &data) |
| virtual | ~KoStore () |
Static Public Member Functions | |
| static KoStore * | createStore (const QString &fileName, Mode mode, const QByteArray &appIdentification=QByteArray(), Backend backend=Auto, bool writeMimetype=true) |
| static KoStore * | createStore (QIODevice *device, Mode mode, const QByteArray &appIdentification=QByteArray(), Backend backend=Auto, bool writeMimetype=true) |
Protected Member Functions | |
| virtual bool | closeRead ()=0 |
| virtual bool | closeWrite ()=0 |
| virtual bool | doFinalize () |
| virtual bool | enterAbsoluteDirectory (const QString &path)=0 |
| virtual bool | enterRelativeDirectory (const QString &dirName)=0 |
| virtual bool | fileExists (const QString &absPath) const =0 |
| KoStore (Mode mode, bool writeMimetype=true) | |
| virtual bool | openRead (const QString &name)=0 |
| virtual bool | openWrite (const QString &name)=0 |
Protected Attributes | |
| KoStorePrivate * | d_ptr |
Private Member Functions | |
| KoStore (const KoStore &store) | |
| don't copy | |
| KoStore & | operator= (const KoStore &store) |
| don't assign | |
Saves and loads Krita documents using various backends. Currently supported backends are zip and directory. We call a "store" the file on the hard disk (the one the users sees) and call a "file" a file inside the store.
| enum KoStore::Backend |
| enum KoStore::Mode |
|
virtual |
Destroys the store (i.e. closes the file on the hard disk)
Definition at line 102 of file KoStore.cpp.
References d_ptr.
|
protected |
Definition at line 98 of file KoStore.cpp.
|
private |
don't copy
| bool KoStore::atEnd | ( | ) | const |
Definition at line 353 of file KoStore.cpp.
| bool KoStore::bad | ( | ) | const |
Definition at line 414 of file KoStore.cpp.
| bool KoStore::close | ( | ) |
Close the file inside the store
Definition at line 156 of file KoStore.cpp.
References closeRead(), closeWrite(), warnStore, and Write.
|
protectedpure virtual |
Implemented in KoDirectoryStore, and KoQuaZipStore.
|
protectedpure virtual |
Implemented in KoDirectoryStore, and KoQuaZipStore.
|
static |
Open a store (i.e. the representation on disk of a Krita document).
| fileName | the name of the file to open |
| mode | if KoStore::Read, open an existing store to read it. if KoStore::Write, create or replace a store. |
| backend | the backend to use for the data storage. Auto means automatically-determined for reading, and the current format (now Zip) for writing. |
| appIdentification | the application's mimetype, to be written in the file for "mime-magic" identification. Only meaningful if mode is Write, and if backend!=Directory. |
| writeMimetype | If true, some backends (notably the Zip store) will write a file called 'mimetype' automatically and fill it with data from the appIdentification. This is only applicable if Mode is set to Write. |
Definition at line 39 of file KoStore.cpp.
References Auto, DefaultFormat, determineBackend(), Directory, mode(), warnStore, Write, and Zip.
|
static |
Create a store for any kind of QIODevice: file, memory buffer... KoStore will take care of opening the QIODevice. This method doesn't support the Directory store!
Definition at line 68 of file KoStore.cpp.
References Auto, DefaultFormat, determineBackend(), device(), Directory, errorStore, mode(), warnStore, Write, and Zip.
| QString KoStore::currentPath | ( | ) | const |
Returns the current path including a trailing slash. Note: Returns a path in "internal name" style
Definition at line 281 of file KoStore.cpp.
| QIODevice * KoStore::device | ( | ) | const |
Get a device for reading a file from the store directly (slightly faster than read() calls) You need to call open first, and close afterwards.
Definition at line 171 of file KoStore.cpp.
|
virtual |
If an store is opened for reading, then the directories of the store can be accessed via this function.
Reimplemented in KoQuaZipStore.
Definition at line 426 of file KoStore.cpp.
|
inlineprotectedvirtual |
Finalize store - called by finalize.
Reimplemented in KoQuaZipStore.
Definition at line 230 of file KoStore.h.
|
protectedpure virtual |
Enter a directory where we've been before. It is guaranteed to always exist.
Implemented in KoDirectoryStore, and KoQuaZipStore.
|
virtual |
Enters one or multiple directories. In Read mode this actually checks whether the specified directories exist and returns false if they don't. In Write mode we don't create the directory, we just use the "current directory" to generate the absolute path if you pass a relative path (one not starting with tar:/) when opening a stream. Note: Operates on internal names
Definition at line 253 of file KoStore.cpp.
References pos().
|
protectedpure virtual |
Enter a subdirectory of the current directory. The directory might not exist yet in Write mode.
Implemented in KoDirectoryStore, and KoQuaZipStore.
| bool KoStore::extractFile | ( | const QString & | sourceName, |
| QByteArray & | data ) |
Extracts a file out of the store to a buffer
| sourceName | file in the store |
| data | memory buffer |
Definition at line 308 of file KoStore.cpp.
|
protectedpure virtual |
Check if a file exists inside the store.
| absPath | the absolute path inside the store, i.e. not relative to the current directory |
Implemented in KoDirectoryStore, and KoQuaZipStore.
| bool KoStore::finalize | ( | ) |
Call this before destroying the store, to be able to catch errors (e.g. from ksavefile)
Definition at line 395 of file KoStore.cpp.
References doFinalize().
| bool KoStore::hasDirectory | ( | const QString & | directoryName | ) |
Definition at line 390 of file KoStore.cpp.
References enterAbsoluteDirectory().
| bool KoStore::hasFile | ( | const QString & | fileName | ) | const |
Definition at line 384 of file KoStore.cpp.
References fileExists().
| bool KoStore::isOpen | ( | ) | const |
Check whether a file inside the store is currently opened with open(), ready to be read or written.
Definition at line 150 of file KoStore.cpp.
| bool KoStore::leaveDirectory | ( | ) |
Leaves a directory. Equivalent to "cd .."
Definition at line 270 of file KoStore.cpp.
References currentPath(), and enterAbsoluteDirectory().
| KoStore::Mode KoStore::mode | ( | ) | const |
Definition at line 420 of file KoStore.cpp.
| bool KoStore::open | ( | const QString & | name | ) |
Open a new file inside the store
| name | The filename, internal representation ("root", "tar:/0"... ). If the tar:/ prefix is missing it's assumed to be a relative URI. |
Definition at line 109 of file KoStore.cpp.
References debugStore, errorStore, openRead(), openWrite(), Read, warnStore, and Write.
|
protectedpure virtual |
Open the file name in the store, for reading. On success, this method must set m_stream to a stream from which we can read, as well as setting m_iSize to the size of the file.
| name | "absolute path" (in the archive) to the file to open |
Implemented in KoDirectoryStore, and KoQuaZipStore.
|
protectedpure virtual |
Open the file name in the store, for writing On success, this method must set m_stream to a stream in which we can write.
| name | "absolute path" (in the archive) to the file to open |
Implemented in KoDirectoryStore, and KoQuaZipStore.
| void KoStore::popDirectory | ( | ) |
Restores the previously pushed directory. No-op if the stack is empty.
Definition at line 300 of file KoStore.cpp.
References enterAbsoluteDirectory(), and enterDirectory().
| qint64 KoStore::pos | ( | ) | const |
Definition at line 347 of file KoStore.cpp.
| void KoStore::pushDirectory | ( | ) |
Stacks the current directory. Restore the current path using popDirectory .
Definition at line 294 of file KoStore.cpp.
References currentPath().
| qint64 KoStore::read | ( | char * | buffer, |
| qint64 | length ) |
Read data from the currently opened file. You can also use the streams for this.
Definition at line 203 of file KoStore.cpp.
References errorStore, and Read.
| QByteArray KoStore::read | ( | qint64 | max | ) |
Read data from the currently opened file. You can also use the streams for this.
Definition at line 181 of file KoStore.cpp.
References errorStore, Read, and warnStore.
| bool KoStore::seek | ( | qint64 | pos | ) |
|
virtual |
Allow to enable or disable compression of the files. Only supported by the ZIP backend.
Reimplemented in KoQuaZipStore.
Definition at line 403 of file KoStore.cpp.
| void KoStore::setSubstitution | ( | const QString & | name, |
| const QString & | substitution ) |
When reading, in the paths in the store where name occurs, substitution is used.
Definition at line 407 of file KoStore.cpp.
| qint64 KoStore::size | ( | ) | const |
Definition at line 239 of file KoStore.cpp.
|
virtual |
Write data into the currently opened file. You can also use the streams for this.
Reimplemented in KoQuaZipStore.
Definition at line 218 of file KoStore.cpp.
References errorStore, and Write.
| qint64 KoStore::write | ( | const QByteArray & | data | ) |
Write data into the currently opened file. You can also use the streams for this.
Definition at line 198 of file KoStore.cpp.
References write().
|
protected |