kio Library: kzip.h Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | 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;
    00053 class KIO_EXPORT 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     void abort();
    00215
    00216 private:
    00217     QString m_filename;
    00218     class KZipPrivate;
    00219     KZipPrivate * d;
    00220 };
    00221
    00222
    00226 class KIO_EXPORT KZipFileEntry : public KArchiveFile
    00227 {
    00228 public:
    00229     /*KZipFileEntry() : st(-1)
    00230       {}*/
    00231     KZipFileEntry( KZip* zip, const QString& name, int access, int date,
    00232                    const QString& user, const QString& group, const QString& symlink,
    00233                    const QString& path, Q_LONG start, Q_LONG uncompressedSize,
    00234                    int encoding, Q_LONG compressedSize) :
    00235         KArchiveFile( zip, name, access, date, user, group, symlink,
    00236                       start, uncompressedSize ),
    00237         m_crc(0),
    00238         m_compressedSize(compressedSize),
    00239         m_headerStart(0),
    00240         m_encoding(encoding),
    00241         m_path( path )
    00242     {}
    00243     int encoding() const { return m_encoding; }
    00244     Q_LONG compressedSize() const { return m_compressedSize; }
    00245
    00247     void setCompressedSize(Q_LONG compressedSize) { m_compressedSize = compressedSize; }
    00248
    00250     void setHeaderStart(Q_LONG headerstart) { m_headerStart = headerstart; }
    00251     Q_LONG headerStart() const {return m_headerStart; }
    00252
    00254     unsigned long crc32() const { return m_crc; }
    00255     void setCRC32(unsigned long crc32) { m_crc=crc32; }
    00256
    00257     // Name with complete path - KArchiveFile::name() is the filename only (no path)
    00258     QString path() const { return m_path; }
    00259
    00264     virtual QByteArray data() const;
    00265
    00273     QIODevice* device() const; // WARNING, not virtual!
    00274
    00275 private:
    00276     unsigned long m_crc;
    00277     Q_LONG m_compressedSize;
    00278     Q_LONG m_headerStart;
    00279     int m_encoding;
    00280     QString m_path;
    00281     // KDE4: d pointer or at least some int for future extensions
    00282 };
    00283
    00284 #endif

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:24:06 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003