koStore.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __koStore_h_
00022 #define __koStore_h_
00023
00024 #include <qstring.h>
00025 #include <qstringlist.h>
00026 #include <qiodevice.h>
00027 #include <qvaluestack.h>
00028
00035 class KoStore
00036 {
00037 public:
00038
00039 enum Mode { Read, Write };
00040 enum Backend { Auto, Tar, Zip, Directory };
00041
00056 static KoStore* createStore( const QString& fileName, Mode mode, const QCString & appIdentification = "", Backend backend = Auto );
00057
00062 static KoStore* createStore( QIODevice *device, Mode mode, const QCString & appIdentification = "", Backend backend = Auto );
00063
00067 virtual ~KoStore();
00068
00075 bool open( const QString & name );
00076
00080 bool isOpen() const;
00081
00086 bool close();
00087
00093 QIODevice* device() const;
00094
00099 QByteArray read( long unsigned int max );
00100
00105 Q_LONG write( const QByteArray& _data );
00106
00112 Q_LONG read( char *_buffer, Q_ULONG _len );
00113
00118 virtual Q_LONG write( const char* _data, Q_ULONG _len );
00119
00124 QIODevice::Offset size() const;
00125
00129 bool bad() const { return !m_bGood; }
00130
00134 Mode mode() const { return m_mode; }
00135
00145 bool enterDirectory( const QString& directory );
00146
00152 bool leaveDirectory();
00153
00158 QString currentPath() const;
00159
00164 void pushDirectory();
00165
00170 void popDirectory();
00171
00177 bool addLocalFile( const QString &fileName, const QString &destName );
00178
00185 QStringList addLocalDirectory( const QString &dirPath, const QString &dest );
00186
00187
00193 bool extractFile( const QString &srcName, const QString &fileName );
00194
00196 bool at( QIODevice::Offset pos );
00198 QIODevice::Offset at() const;
00200 bool atEnd() const;
00201
00202
00203 protected:
00204
00205 KoStore() {}
00206
00211 virtual bool init( Mode mode );
00218 virtual bool openWrite( const QString& name ) = 0;
00226 virtual bool openRead( const QString& name ) = 0;
00227
00231 virtual bool closeRead() = 0;
00235 virtual bool closeWrite() = 0;
00236
00241 virtual bool enterRelativeDirectory( const QString& dirName ) = 0;
00246 virtual bool enterAbsoluteDirectory( const QString& path ) = 0;
00247
00248 virtual bool fileExists( const QString& absPath ) = 0;
00249
00250 private:
00251 static Backend determineBackend( QIODevice* dev );
00252
00266 QString toExternalNaming( const QString & _internalNaming );
00267
00271 QString expandEncodedPath( QString intern );
00272
00277 QString expandEncodedDirectory( QString intern );
00278
00279 enum
00280 {
00281 NAMING_VERSION_2_1,
00282 NAMING_VERSION_2_2
00283 } m_namingVersion;
00284
00289 bool enterDirectoryInternal( const QString& directory );
00290
00291 protected:
00292
00293 Mode m_mode;
00294
00296 QStringList m_strFiles;
00297
00299 QStringList m_currentPath;
00300
00302 QValueStack<QString> m_directoryStack;
00303
00305 QString m_sName;
00307 QIODevice::Offset m_iSize;
00308
00310 QIODevice * m_stream;
00311
00312 bool m_bIsOpen;
00314 bool m_bGood;
00315
00316 static const int s_area;
00317
00318 private:
00319 KoStore( const KoStore& store );
00320 KoStore& operator=( const KoStore& store );
00321
00322 class Private;
00323 Private * d;
00324
00325 };
00326
00327 #endif
This file is part of the documentation for lib Library Version 1.3.5.