kio Library API Documentation

kzip.h

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2002 Holger Schroeder <holger-kde@holgis.net> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00016 Boston, MA 02111-1307, USA. 00017 */ 00018 #ifndef __kzip_h 00019 #define __kzip_h 00020 00021 #include <sys/stat.h> 00022 #include <sys/types.h> 00023 00024 #include <qdatetime.h> 00025 #include <qstring.h> 00026 #include <qstringlist.h> 00027 #include <qdict.h> 00028 #include <qvaluelist.h> 00029 #include <karchive.h> 00030 00031 class KZipFileEntry; 00053 class KZip : public KArchive 00054 { 00055 public: 00062 KZip( const QString& filename ); 00063 00071 KZip( QIODevice * dev ); 00072 00077 virtual ~KZip(); 00078 00084 QString fileName() { return m_filename; } 00085 00089 enum ExtraField { NoExtraField = 0, 00090 ModificationTime = 1, 00091 DefaultExtraField = 1 00092 }; 00093 00100 void setExtraField( ExtraField ef ); 00101 00107 ExtraField extraField() const; 00108 00112 enum Compression { NoCompression = 0, 00113 DeflateCompression = 1 00114 }; 00115 00116 00123 void setCompression( Compression c ); 00124 00130 Compression compression() const; 00131 00143 virtual bool writeFile( const QString& name, const QString& user, const QString& group, uint size, const char* data ); // BC: remove reimplementation for KDE-4.0 00144 00154 virtual bool prepareWriting( const QString& name, const QString& user, const QString& group, uint size ); 00155 00156 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 00157 bool writeSymLink(const QString &name, const QString &target, 00158 const QString &user, const QString &group, 00159 mode_t perm, time_t atime, time_t mtime, time_t ctime); 00160 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 00161 bool prepareWriting( const QString& name, const QString& user, 00162 const QString& group, uint size, mode_t perm, 00163 time_t atime, time_t mtime, time_t ctime ); 00164 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 00165 bool writeFile( const QString& name, const QString& user, const QString& group, 00166 uint size, mode_t perm, time_t atime, time_t mtime, 00167 time_t ctime, const char* data ); 00174 bool writeData( const char* data, uint size ); // TODO make virtual 00175 00181 virtual bool doneWriting( uint size ); 00182 00183 protected: 00190 virtual bool openArchive( int mode ); 00192 virtual bool closeArchive(); 00193 00197 virtual bool writeDir( const QString&, const QString&, const QString& ) { return true; } 00198 // TODO(BIC) uncomment and make virtual for KDE 4. 00199 // bool writeDir( const QString& name, const QString& user, const QString& group, 00200 // mode_t perm, time_t atime, time_t mtime, time_t ctime ); 00201 00202 protected: 00203 virtual void virtual_hook( int id, void* data ); 00205 // from KArchive 00206 bool writeData_impl( const char* data, uint size ); 00207 bool prepareWriting_impl(const QString& name, const QString& user, 00208 const QString& group, uint size, mode_t perm, 00209 time_t atime, time_t mtime, time_t ctime); 00210 bool writeSymLink_impl(const QString &name, const QString &target, 00211 const QString &user, const QString &group, 00212 mode_t perm, time_t atime, time_t mtime, time_t ctime); 00213 private: 00214 QString m_filename; 00215 class KZipPrivate; 00216 KZipPrivate * d; 00217 }; 00218 00219 00223 class KZipFileEntry : public KArchiveFile 00224 { 00225 public: 00226 /*KZipFileEntry() : st(-1) 00227 {}*/ 00228 KZipFileEntry( KZip* zip, const QString& name, int access, int date, 00229 const QString& user, const QString& group, const QString& symlink, 00230 const QString& path, Q_LONG start, Q_LONG uncompressedSize, 00231 int encoding, Q_LONG compressedSize) : 00232 KArchiveFile( zip, name, access, date, user, group, symlink, 00233 start, uncompressedSize ), 00234 m_crc(0), 00235 m_compressedSize(compressedSize), 00236 m_headerStart(0), 00237 m_encoding(encoding), 00238 m_path( path ) 00239 {} 00240 int encoding() const { return m_encoding; } 00241 Q_LONG compressedSize() const { return m_compressedSize; } 00242 00244 void setCompressedSize(Q_LONG compressedSize) { m_compressedSize = compressedSize; } 00245 00247 void setHeaderStart(Q_LONG headerstart) { m_headerStart = headerstart; } 00248 Q_LONG headerStart() const {return m_headerStart; } 00249 00251 unsigned long crc32() const { return m_crc; } 00252 void setCRC32(unsigned long crc32) { m_crc=crc32; } 00253 00254 // Name with complete path - KArchiveFile::name() is the filename only (no path) 00255 QString path() const { return m_path; } 00256 00261 virtual QByteArray data() const; 00262 00270 QIODevice* device() const; // WARNING, not virtual! 00271 00272 private: 00273 unsigned long m_crc; 00274 Q_LONG m_compressedSize; 00275 Q_LONG m_headerStart; 00276 int m_encoding; 00277 QString m_path; 00278 // KDE4: d pointer or at least some int for future extensions 00279 }; 00280 00281 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 12 15:08:46 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003