KDECore
kzip.h
Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef KZIP_H 00019 #define KZIP_H 00020 00021 #include <karchive.h> 00022 00023 class KZipFileEntry; 00045 class KDECORE_EXPORT KZip : public KArchive 00046 { 00047 public: 00054 KZip( const QString& filename ); 00055 00063 KZip( QIODevice * dev ); 00064 00069 virtual ~KZip(); 00070 00074 enum ExtraField { NoExtraField = 0, 00075 ModificationTime = 1, 00076 DefaultExtraField = 1 00077 }; 00078 00085 void setExtraField( ExtraField ef ); 00086 00092 ExtraField extraField() const; 00093 00097 enum Compression { NoCompression = 0, 00098 DeflateCompression = 1 00099 }; 00100 00101 00108 void setCompression( Compression c ); 00109 00115 Compression compression() const; 00116 00123 virtual bool writeData( const char* data, qint64 size ); 00124 00125 protected: 00127 virtual bool doWriteSymLink(const QString &name, const QString &target, 00128 const QString &user, const QString &group, 00129 mode_t perm, time_t atime, time_t mtime, time_t ctime); 00131 virtual bool doPrepareWriting( const QString& name, const QString& user, 00132 const QString& group, qint64 size, mode_t perm, 00133 time_t atime, time_t mtime, time_t ctime ); 00134 00140 virtual bool doFinishWriting( qint64 size ); 00141 00148 virtual bool openArchive( QIODevice::OpenMode mode ); 00149 00151 virtual bool closeArchive(); 00152 00154 virtual bool doWriteDir( const QString& name, const QString& user, 00155 const QString& group, mode_t perm, time_t atime, 00156 time_t mtime, time_t ctime ); 00157 00158 protected: 00159 virtual void virtual_hook( int id, void* data ); 00160 00161 private: 00162 class KZipPrivate; 00163 KZipPrivate * const d; 00164 }; 00165 00166 00170 class KDECORE_EXPORT KZipFileEntry : public KArchiveFile 00171 { 00172 public: 00176 KZipFileEntry( KZip* zip, const QString& name, int access, int date, 00177 const QString& user, const QString& group, const QString& symlink, 00178 const QString& path, qint64 start, qint64 uncompressedSize, 00179 int encoding, qint64 compressedSize); 00180 00184 ~KZipFileEntry(); 00185 00186 int encoding() const; 00187 qint64 compressedSize() const; 00188 00190 void setCompressedSize(qint64 compressedSize); 00191 00193 void setHeaderStart(qint64 headerstart); 00194 qint64 headerStart() const; 00195 00197 unsigned long crc32() const; 00198 void setCRC32(unsigned long crc32); 00199 00201 const QString &path() const; 00202 00207 virtual QByteArray data() const; 00208 00216 virtual QIODevice* createDevice() const; 00217 00218 private: 00219 class KZipFileEntryPrivate; 00220 KZipFileEntryPrivate * const d; 00221 }; 00222 00223 #endif
KDE 4.6 API Reference