| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# 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;
    00054 class KZip : public KArchive
    00055 {
    00056 public:
    00063     KZip( const QString& filename );
    00064
    00071     KZip( QIODevice * dev );
    00072
    00077     virtual ~KZip();
    00078
    00083     QString fileName() { return m_filename; }
    00084
    00085     enum Compression { NoCompression = 0, DeflateCompression = 1 };
    00090     void setCompression( Compression c );
    00091     Compression compression() const;
    00092
    00099     virtual bool writeFile( const QString& name, const QString& user, const QString& group, uint size, const char* data );
    00100
    00105     virtual bool prepareWriting( const QString& name, const QString& user, const QString& group, uint size );
    00106     bool writeData( const char* data, uint size );
    00107     virtual bool doneWriting( uint size );
    00108
    00109 protected:
    00116     virtual bool openArchive( int mode );
    00117     virtual bool closeArchive();
    00118
    00122     virtual bool writeDir( const QString&, const QString&, const QString& ) { return true; }
    00123
    00124 protected:
    00125     virtual void virtual_hook( int id, void* data );
    00126 private:
    00127     QString m_filename;
    00128     class KZipPrivate;
    00129     KZipPrivate * d;
    00130 };
    00131
    00132
    00136 class KZipFileEntry : public KArchiveFile
    00137 {
    00138 public:
    00139     /*KZipFileEntry() : st(-1)
    00140       {}*/
    00141     KZipFileEntry( KZip* zip, const QString& name, int access, int date,
    00142                    const QString& user, const QString& group, const QString& symlink,
    00143                    const QString& path, Q_LONG start, Q_LONG uncompressedSize,
    00144                    int encoding, Q_LONG compressedSize) :
    00145         KArchiveFile( zip, name, access, date, user, group, symlink,
    00146                       start, uncompressedSize ),
    00147         m_crc(0),
    00148         m_compressedSize(compressedSize),
    00149         m_headerStart(0),
    00150         m_encoding(encoding),
    00151         m_path( path )
    00152     {}
    00153     int encoding() const { return m_encoding; }
    00154     Q_LONG compressedSize() const { return m_compressedSize; }
    00155
    00156     // Only used when writing
    00157     void setCompressedSize(Q_LONG compressedSize) { m_compressedSize = compressedSize; }
    00158
    00159     // Header start: only used when writing
    00160     void setHeaderStart(Q_LONG headerstart) { m_headerStart = headerstart; }
    00161     Q_LONG headerStart() const {return m_headerStart; }
    00162
    00163     // CRC: only used when writing
    00164     unsigned long crc32() const { return m_crc; }
    00165     void setCRC32(unsigned long crc32) { m_crc=crc32; }
    00166
    00167     // Name with complete path - KArchiveFile::name() is the filename only (no path)
    00168     QString path() const { return m_path; }
    00169
    00174     virtual QByteArray data() const;
    00175
    00183     QIODevice* device() const; // WARNING, not virtual!
    00184
    00185 private:
    00186     unsigned long m_crc;
    00187     Q_LONG m_compressedSize;
    00188     Q_LONG m_headerStart;
    00189     int m_encoding;
    00190     QString m_path;
    00191 };
    00192
    00193 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:14:35 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001