lib Library API Documentation

koStore.h

00001 // -*- c-basic-offset: 2 -*- 00002 /* This file is part of the KDE project 00003 Copyright (C) 1998, 1999 David Faure <faure@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 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 ); // don't copy 00320 KoStore& operator=( const KoStore& store ); // don't assign 00321 00322 class Private; 00323 Private * d; 00324 00325 }; 00326 00327 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Sep 28 04:04:01 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003