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

# karchive.h

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2000 David Faure <faure@kde.org>
    00003
    00004    Moved from ktar.h by Roberto Teixeira <maragato@kde.org>
    00005
    00006    This library is free software; you can redistribute it and/or
    00007    modify it under the terms of the GNU Library General Public
    00008    License version 2 as published by the Free Software Foundation.
    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 #ifndef __karchive_h
    00021 #define __karchive_h
    00022
    00023 #include <sys/stat.h>
    00024 #include <sys/types.h>
    00025
    00026 #include <qdatetime.h>
    00027 #include <qstring.h>
    00028 #include <qstringlist.h>
    00029 #include <qdict.h>
    00030
    00031 class KArchiveDirectory;
    00032 class KArchiveFile;
    00033
    00038 class KArchive
    00039 {
    00040 protected:
    00046     KArchive( QIODevice * dev );
    00047
    00048 public:
    00049     virtual ~KArchive();
    00050
    00057     virtual bool open( int mode );
    00058
    00065     virtual void close();
    00066
    00070     bool isOpened() const { return m_open; }
    00071
    00075     int mode() const { return m_mode; }
    00076
    00080     QIODevice * device() const { return m_dev; }
    00081
    00086     const KArchiveDirectory* directory() const;
    00087
    00092     virtual bool writeDir( const QString& name, const QString& user, const QString& group ) = 0;
    00093
    00100     virtual bool writeFile( const QString& name, const QString& user, const QString& group, uint size, const char* data );
    00101
    00110     virtual bool prepareWriting( const QString& name, const QString& user, const QString& group, uint size ) = 0;
    00111
    00116     virtual bool doneWriting( uint size ) = 0;
    00117
    00118 protected:
    00123     virtual bool openArchive( int mode ) = 0;
    00124
    00129     virtual bool closeArchive() = 0;
    00130
    00137     virtual KArchiveDirectory* rootDir();
    00138
    00143     KArchiveDirectory * findOrCreate( const QString & path );
    00144
    00148     void setDevice( QIODevice *dev );
    00149
    00153     void setRootDir( KArchiveDirectory *rootDir );
    00154
    00155 private:
    00156     QIODevice * m_dev;
    00157     bool m_open;
    00158     char m_mode;
    00159 protected:
    00160     virtual void virtual_hook( int id, void* data );
    00161 private:
    00162     class KArchivePrivate;
    00163     KArchivePrivate * d;
    00164 };
    00165
    00172 class KArchiveEntry
    00173 {
    00174 public:
    00175     KArchiveEntry( KArchive* archive, const QString& name, int access, int date,
    00176                const QString& user, const QString& group,
    00177                const QString &symlink );
    00178
    00179     virtual ~KArchiveEntry() { }
    00180
    00184     QDateTime datetime() const;
    00185     int date() const { return m_date; }
    00186
    00190     QString name() const { return m_name; }
    00195     mode_t permissions() const { return m_access; }
    00199     QString user() const { return m_user; }
    00203     QString group() const { return m_group; }
    00204
    00208     QString symlink() const { return m_symlink; }
    00209
    00213     virtual bool isFile() const { return false; }
    00214
    00218     virtual bool isDirectory() const { return false; }
    00219
    00220 protected:
    00221     KArchive* archive() const { return m_archive; }
    00222
    00223 private:
    00224     QString m_name;
    00225     int m_date;
    00226     mode_t m_access;
    00227     QString m_user;
    00228     QString m_group;
    00229     QString m_symlink;
    00230     KArchive* m_archive;
    00231 protected:
    00232     virtual void virtual_hook( int id, void* data );
    00233 private:
    00234     class KArchiveEntryPrivate* d;
    00235 };
    00236
    00243 class KArchiveFile : public KArchiveEntry
    00244 {
    00245 public:
    00246     KArchiveFile( KArchive* archive, const QString& name, int access, int date,
    00247               const QString& user, const QString& group, const QString &symlink,
    00248               int pos, int size );
    00249
    00250     virtual ~KArchiveFile() { }
    00251
    00255     int position() const; // TODO use Q_LONG in KDE-4.0
    00259     int size() const; // TODO use Q_LONG in KDE-4.0
    00263     void setSize( int s ) { m_size = s; }
    00264
    00269     virtual QByteArray data() const;
    00270
    00278     QIODevice *device() const; // TODO make virtual
    00279
    00283     virtual bool isFile() const { return true; }
    00284
    00289     void copyTo(const QString& dest) const;
    00290
    00291 private:
    00292     int m_pos; // TODO use Q_LONG in KDE-4.0
    00293     int m_size; // TODO use Q_LONG in KDE-4.0
    00294 protected:
    00295     virtual void virtual_hook( int id, void* data );
    00296 private:
    00297     class KArchiveFilePrivate* d;
    00298 };
    00299
    00306 class KArchiveDirectory : public KArchiveEntry
    00307 {
    00308 public:
    00309     KArchiveDirectory( KArchive* archive, const QString& name, int access, int date,
    00310                    const QString& user, const QString& group,
    00311                    const QString& symlink);
    00312
    00313     virtual ~KArchiveDirectory() { }
    00314
    00318     QStringList entries() const;
    00324     KArchiveEntry* entry( QString name );
    00325     const KArchiveEntry* entry( QString name ) const;
    00326
    00331     void addEntry( KArchiveEntry* );
    00332
    00336     virtual bool isDirectory() const { return true; }
    00337
    00344      void copyTo(const QString& dest, bool recursive = true) const;
    00345
    00346 private:
    00347     QDict<KArchiveEntry> m_entries;
    00348 protected:
    00349     virtual void virtual_hook( int id, void* data );
    00350 private:
    00351     class KArchiveDirectoryPrivate* d;
    00352 };
    00353
    00354 #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:13:07 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001