lib
KoStore.h00001
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 #include <koffice_export.h>
00029
00030 class QWidget;
00031
00032 class KURL;
00033
00040 class KOSTORE_EXPORT KoStore
00041 {
00042 public:
00043
00044 enum Mode { Read, Write };
00045 enum Backend { Auto, Tar, Zip, Directory };
00046
00061 static KoStore* createStore( const QString& fileName, Mode mode, const QCString & appIdentification = "", Backend backend = Auto );
00062
00068 static KoStore* createStore( QIODevice *device, Mode mode, const QCString & appIdentification = "", Backend backend = Auto );
00069
00090 static KoStore* createStore( QWidget* window, const KURL& url, Mode mode, const QCString & appIdentification = "", Backend backend = Auto );
00091
00095 virtual ~KoStore();
00096
00103 bool open( const QString & name );
00104
00110 bool isOpen() const;
00111
00116 bool close();
00117
00123 QIODevice* device() const;
00124
00129 QByteArray read( unsigned long int max );
00130
00135 Q_LONG write( const QByteArray& _data );
00136
00142 Q_LONG read( char *_buffer, Q_ULONG _len );
00143
00148 virtual Q_LONG write( const char* _data, Q_ULONG _len );
00149
00154 QIODevice::Offset size() const;
00155
00159 bool bad() const { return !m_bGood; }
00160
00164 Mode mode() const { return m_mode; }
00165
00175 bool enterDirectory( const QString& directory );
00176
00182 bool leaveDirectory();
00183
00188 QString currentPath() const;
00189
00194 QString currentDirectory() const;
00195
00196
00201 void pushDirectory();
00202
00207 void popDirectory();
00208
00213 bool hasFile( const QString& fileName ) const;
00214
00220 bool addLocalFile( const QString &fileName, const QString &destName );
00221
00228 QStringList addLocalDirectory( const QString &dirPath, const QString &dest );
00229
00230
00236 bool extractFile( const QString &srcName, const QString &fileName );
00237
00239
00240 bool at( QIODevice::Offset pos );
00241 QIODevice::Offset at() const;
00242 bool atEnd() const;
00244
00250 void disallowNameExpansion( void );
00251
00252 protected:
00253
00254 KoStore() {}
00255
00260 virtual bool init( Mode mode );
00267 virtual bool openWrite( const QString& name ) = 0;
00275 virtual bool openRead( const QString& name ) = 0;
00276
00280 virtual bool closeRead() = 0;
00284 virtual bool closeWrite() = 0;
00285
00290 virtual bool enterRelativeDirectory( const QString& dirName ) = 0;
00295 virtual bool enterAbsoluteDirectory( const QString& path ) = 0;
00296
00301 virtual bool fileExists( const QString& absPath ) const = 0;
00302
00303 private:
00304 static Backend determineBackend( QIODevice* dev );
00305
00319 QString toExternalNaming( const QString & _internalNaming ) const;
00320
00324 QString expandEncodedPath( QString intern ) const;
00325
00330 QString expandEncodedDirectory( QString intern ) const;
00331
00332 mutable enum
00333 {
00334 NAMING_VERSION_2_1,
00335 NAMING_VERSION_2_2,
00336 NAMING_VERSION_RAW
00337 } m_namingVersion;
00338
00343 bool enterDirectoryInternal( const QString& directory );
00344
00345 protected:
00346
00347 Mode m_mode;
00348
00350 QStringList m_strFiles;
00351
00353 QStringList m_currentPath;
00354
00356 QValueStack<QString> m_directoryStack;
00357
00359 QString m_sName;
00361 QIODevice::Offset m_iSize;
00362
00364 QIODevice * m_stream;
00365
00366 bool m_bIsOpen;
00368 bool m_bGood;
00369
00370 static const int s_area;
00371
00372 private:
00373 KoStore( const KoStore& store );
00374 KoStore& operator=( const KoStore& store );
00375
00376 class Private;
00377 Private * d;
00378
00379 };
00380
00381 #endif
|