#include <KoStore.h>
Public Types | |
| enum | Mode { Read , Write } |
| enum | Backend { Auto , Tar , Zip , Directory } |
Public Member Functions | |
| virtual | ~KoStore () |
| bool | open (const TQString &name) |
| bool | isOpen () const |
| bool | close () |
| TQIODevice * | device () const |
| TQByteArray | read (unsigned long int max) |
| TQ_LONG | write (const TQByteArray &_data) |
| TQ_LONG | read (char *_buffer, TQ_ULONG _len) |
| virtual TQ_LONG | write (const char *_data, TQ_ULONG _len) |
| TQIODevice::Offset | size () const |
| bool | bad () const |
| Mode | mode () const |
| bool | enterDirectory (const TQString &directory) |
| bool | leaveDirectory () |
| TQString | currentPath () const |
| TQString | currentDirectory () const |
| void | pushDirectory () |
| void | popDirectory () |
| bool | hasFile (const TQString &fileName) const |
| bool | addLocalFile (const TQString &fileName, const TQString &destName) |
| TQStringList | addLocalDirectory (const TQString &dirPath, const TQString &dest) |
| bool | extractFile (const TQString &srcName, const TQString &fileName) |
| bool | at (TQIODevice::Offset pos) |
| TQIODevice::Offset | at () const |
| bool | atEnd () const |
| void | disallowNameExpansion (void) |
Static Public Member Functions | |
| static KoStore * | createStore (const TQString &fileName, Mode mode, const TQCString &appIdentification="", Backend backend=Auto) |
| static KoStore * | createStore (TQIODevice *device, Mode mode, const TQCString &appIdentification="", Backend backend=Auto) |
| static KoStore * | createStore (TQWidget *window, const KURL &url, Mode mode, const TQCString &appIdentification="", Backend backend=Auto) |
Protected Member Functions | |
| virtual bool | init (Mode mode) |
| virtual bool | openWrite (const TQString &name)=0 |
| virtual bool | openRead (const TQString &name)=0 |
| virtual bool | closeRead ()=0 |
| virtual bool | closeWrite ()=0 |
| virtual bool | enterRelativeDirectory (const TQString &dirName)=0 |
| virtual bool | enterAbsoluteDirectory (const TQString &path)=0 |
| virtual bool | fileExists (const TQString &absPath) const =0 |
Protected Attributes | |
| Mode | m_mode |
| TQStringList | m_strFiles |
| TQStringList | m_currentPath |
| TQValueStack< TQString > | m_directoryStack |
| TQString | m_sName |
| TQIODevice::Offset | m_iSize |
| TQIODevice * | m_stream |
| bool | m_bIsOpen |
| bool | m_bGood |
Static Protected Attributes | |
| static const int | s_area = 30002 |
Detailed Description
Saves and loads KOffice documents using various backends.
Currently supported backends are ZIP, tar 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.
Member Enumeration Documentation
◆ Backend
◆ Mode
Constructor & Destructor Documentation
◆ ~KoStore()
|
virtual |
Destroys the store (i.e.
closes the file on the hard disk)
Definition at line 183 of file KoStore.cpp.
◆ KoStore()
Member Function Documentation
◆ addLocalDirectory()
| TQStringList KoStore::addLocalDirectory | ( | const TQString & | dirPath, |
| const TQString & | dest | ||
| ) |
Imports a local directory.
- Parameters
-
dirPath path to the directory on a disk dest path in the store where the directory should get saved
- Returns
- the directory index
Definition at line 491 of file KoStore.cpp.
◆ addLocalFile()
| bool KoStore::addLocalFile | ( | const TQString & | fileName, |
| const TQString & | destName | ||
| ) |
Imports a local file into a store.
- Parameters
-
fileName file on hard disk destName file in the store
Definition at line 429 of file KoStore.cpp.
◆ at() [1/2]
| TQIODevice::Offset KoStore::at | ( | ) | const |
Definition at line 531 of file KoStore.cpp.
◆ at() [2/2]
| bool KoStore::at | ( | TQIODevice::Offset | pos | ) |
See TQIODevice.
Definition at line 526 of file KoStore.cpp.
◆ atEnd()
| bool KoStore::atEnd | ( | ) | const |
Definition at line 536 of file KoStore.cpp.
◆ bad()
|
inline |
◆ close()
| bool KoStore::close | ( | ) |
Close the file inside the store.
- Returns
- true on success.
Definition at line 242 of file KoStore.cpp.
◆ closeRead()
|
protectedpure virtual |
- Returns
- true on success
◆ closeWrite()
|
protectedpure virtual |
- Returns
- true on success
◆ createStore() [1/3]
|
static |
Open a store (i.e.
the representation on disk of a KOffice document).
- Parameters
-
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.
Definition at line 58 of file KoStore.cpp.
◆ createStore() [2/3]
|
static |
Create a store for any kind of TQIODevice: file, memory buffer... KoStore will take care of opening the TQIODevice.
This method doesn't support the Directory store!
Definition at line 92 of file KoStore.cpp.
◆ createStore() [3/3]
|
static |
Open a store (i.e.
the representation on disk of a KOffice document).
- Parameters
-
window associated window (for the progress bar dialog and authentification) url URL 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.
If the file is remote, the backend Directory cannot be used!
- Since
- 1.4
- Bug:
- saving not completely implemented (fixed temporary file)
Definition at line 120 of file KoStore.cpp.
◆ currentDirectory()
| TQString KoStore::currentDirectory | ( | ) | const |
Returns the current directory.
Note: Returns a path in "internal name" style
Definition at line 400 of file KoStore.cpp.
◆ currentPath()
| TQString KoStore::currentPath | ( | ) | const |
Returns the current path including a trailing slash.
Note: Returns a path in "internal name" style
Definition at line 405 of file KoStore.cpp.
◆ device()
| TQIODevice * 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 261 of file KoStore.cpp.
◆ disallowNameExpansion()
| void KoStore::disallowNameExpansion | ( | void | ) |
Do not expand file and directory names Useful when using KoStore on non-KOffice files.
(This method should be called just after the constructor)
Definition at line 620 of file KoStore.cpp.
◆ enterAbsoluteDirectory()
|
protectedpure virtual |
Enter a directory where we've been before.
It is guaranteed to always exist.
◆ enterDirectory()
| bool KoStore::enterDirectory | ( | const TQString & | directory | ) |
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 374 of file KoStore.cpp.
◆ enterRelativeDirectory()
|
protectedpure virtual |
Enter a subdirectory of the current directory.
The directory might not exist yet in Write mode.
◆ extractFile()
| bool KoStore::extractFile | ( | const TQString & | srcName, |
| const TQString & | fileName | ||
| ) |
Extracts a file out of the store.
- Parameters
-
srcName file in the store fileName file on a disk
Definition at line 462 of file KoStore.cpp.
◆ fileExists()
|
protectedpure virtual |
Check if a file exists inside the store.
- Parameters
-
absPath the absolute path inside the store, i.e. not relative to the current directory
◆ hasFile()
| bool KoStore::hasFile | ( | const TQString & | fileName | ) | const |
- Returns
- true if the given file exists in the current directory, i.e. if open(fileName) will work.
Definition at line 625 of file KoStore.cpp.
◆ init()
|
protectedvirtual |
Init store - called by constructor.
- Returns
- true on success
Definition at line 171 of file KoStore.cpp.
◆ isOpen()
| bool KoStore::isOpen | ( | ) | const |
Check whether a file inside the store is currently opened with open(), ready to be read or written.
- Returns
- true if a file is currently opened.
Definition at line 237 of file KoStore.cpp.
◆ leaveDirectory()
| bool KoStore::leaveDirectory | ( | ) |
Leaves a directory.
Equivalent to "cd .."
- Returns
- true on success, false if we were at the root already to make it possible to "loop to the root"
Definition at line 390 of file KoStore.cpp.
◆ mode()
|
inline |
◆ open()
| bool KoStore::open | ( | const TQString & | name | ) |
Open a new file inside the store.
- Parameters
-
name The filename, internal representation ("root", "tar:/0"... ). If the tar:/ prefix is missing it's assumed to be a relative URI.
- Returns
- true on success.
Definition at line 188 of file KoStore.cpp.
◆ openRead()
|
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.
- Parameters
-
name "absolute path" (in the archive) to the file to open
- Returns
- true on success
◆ openWrite()
|
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.
- Parameters
-
name "absolute path" (in the archive) to the file to open
- Returns
- true on success
◆ popDirectory()
| void KoStore::popDirectory | ( | ) |
Restores the previously pushed directory.
No-op if the stack is empty.
Definition at line 422 of file KoStore.cpp.
◆ pushDirectory()
| void KoStore::pushDirectory | ( | ) |
Stacks the current directory.
Restore the current path using popDirectory .
Definition at line 417 of file KoStore.cpp.
◆ read() [1/2]
| TQ_LONG KoStore::read | ( | char * | _buffer, |
| TQ_ULONG | _len | ||
| ) |
Read data from the currently opened file.
You can also use the streams for this.
- Returns
- size of data read, -1 on error
Definition at line 313 of file KoStore.cpp.
◆ read() [2/2]
| TQByteArray KoStore::read | ( | unsigned long int | max | ) |
Read data from the currently opened file.
You can also use the streams for this.
Definition at line 270 of file KoStore.cpp.
◆ size()
| TQIODevice::Offset KoStore::size | ( | ) | const |
- Returns
- the size of the currently opened file, -1 on error. Can be used as an argument for the read methods, for instance
Definition at line 359 of file KoStore.cpp.
◆ write() [1/2]
|
virtual |
Write data into the currently opened file.
You can also use the streams for this.
Definition at line 337 of file KoStore.cpp.
◆ write() [2/2]
| TQ_LONG KoStore::write | ( | const TQByteArray & | _data | ) |
Write data into the currently opened file.
You can also use the streams for this.
Definition at line 308 of file KoStore.cpp.
Member Data Documentation
◆ m_bGood
|
protected |
◆ m_bIsOpen
◆ m_currentPath
|
protected |
◆ m_directoryStack
|
protected |
◆ m_iSize
|
protected |
◆ m_mode
◆ m_sName
|
protected |
◆ m_stream
|
protected |
◆ m_strFiles
|
protected |
◆ s_area
The documentation for this class was generated from the following files:
