• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

karchive.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2000-2005 David Faure <faure@kde.org>
00003    Copyright (C) 2003 Leo Savernik <l.savernik@aon.at>
00004 
00005    Moved from ktar.h by Roberto Teixeira <maragato@kde.org>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License version 2 as published by the Free Software Foundation.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 #ifndef KARCHIVE_H
00022 #define KARCHIVE_H
00023 
00024 #include <sys/stat.h>
00025 #include <sys/types.h>
00026 
00027 #include <QtCore/QDate>
00028 #include <QtCore/QString>
00029 #include <QtCore/QStringList>
00030 #include <QtCore/QHash>
00031 
00032 #include <kio/kio_export.h>
00033 
00034 class KArchiveDirectory;
00035 class KArchiveFile;
00036 
00037 class KArchivePrivate;
00043 class KIO_EXPORT KArchive
00044 {
00045 protected:
00052     KArchive( const QString& fileName );
00053 
00061     KArchive( QIODevice * dev );
00062 
00063 public:
00064     virtual ~KArchive();
00065 
00072     virtual bool open( QIODevice::OpenMode mode );
00073 
00081     virtual bool close();
00082 
00087     bool isOpen() const;
00088 
00094     QIODevice::OpenMode mode() const;
00095 
00100     QIODevice * device() const;
00101 
00107     QString fileName() const;
00108 
00114     const KArchiveDirectory* directory() const;
00115 
00126     bool addLocalFile( const QString& fileName, const QString& destName );
00127 
00139     bool addLocalDirectory( const QString& path, const QString& destName );
00140 
00141     enum { UnknownTime = static_cast<time_t>( -1 ) };
00142 
00158     virtual bool writeDir( const QString& name, const QString& user, const QString& group,
00159                            mode_t perm = 040755, time_t atime = UnknownTime,
00160                            time_t mtime = UnknownTime, time_t ctime = UnknownTime );
00161 
00175     virtual bool writeSymLink(const QString &name, const QString &target,
00176                               const QString &user, const QString &group,
00177                               mode_t perm = 0120755, time_t atime = UnknownTime,
00178                               time_t mtime = UnknownTime, time_t ctime = UnknownTime );
00179 
00199     virtual bool writeFile( const QString& name, const QString& user, const QString& group,
00200                             const char* data, qint64 size,
00201                             mode_t perm = 0100644, time_t atime = UnknownTime,
00202                             time_t mtime = UnknownTime, time_t ctime = UnknownTime );
00203 
00223     virtual bool prepareWriting( const QString& name, const QString& user,
00224                                  const QString& group, qint64 size,
00225                                  mode_t perm = 0100644, time_t atime = UnknownTime,
00226                                  time_t mtime = UnknownTime, time_t ctime = UnknownTime );
00227 
00231     virtual bool writeData( const char* data, qint64 size );
00232 
00238     virtual bool finishWriting( qint64 size );
00239 
00240 protected:
00246     virtual bool openArchive( QIODevice::OpenMode mode ) = 0;
00247 
00252     virtual bool closeArchive() = 0;
00253 
00261     virtual KArchiveDirectory* rootDir();
00262 
00278     virtual bool doWriteDir( const QString& name, const QString& user, const QString& group,
00279                              mode_t perm, time_t atime, time_t mtime, time_t ctime ) = 0;
00280 
00295     virtual bool doWriteSymLink(const QString &name, const QString &target,
00296                                 const QString &user, const QString &group,
00297                                 mode_t perm, time_t atime, time_t mtime, time_t ctime) = 0;
00298 
00314     virtual bool doPrepareWriting( const QString& name, const QString& user,
00315                                    const QString& group, qint64 size, mode_t perm,
00316                                    time_t atime, time_t mtime, time_t ctime ) = 0;
00317 
00325     virtual bool doFinishWriting( qint64 size ) = 0;
00326 
00333     KArchiveDirectory * findOrCreate( const QString & path );
00334 
00341     virtual bool createDevice( QIODevice::OpenMode mode );
00342 
00347     void setDevice( QIODevice *dev );
00348 
00353     void setRootDir( KArchiveDirectory *rootDir );
00354 
00355 protected:
00356     virtual void virtual_hook( int id, void* data );
00357 private:
00358     KArchivePrivate* const d;
00359 };
00360 
00361 class KArchiveEntryPrivate;
00369 class KIO_EXPORT KArchiveEntry
00370 {
00371 public:
00382     KArchiveEntry( KArchive* archive, const QString& name, int access, int date,
00383                    const QString& user, const QString& group,
00384                    const QString& symlink );
00385 
00386     virtual ~KArchiveEntry();
00387 
00392     QDateTime datetime() const;
00393 
00398     int date() const;
00399 
00404     QString name() const;
00410     mode_t permissions() const;
00415     QString user() const;
00420     QString group() const;
00421 
00426     QString symLinkTarget() const;
00427 
00432     virtual bool isFile() const;
00433 
00438     virtual bool isDirectory() const;
00439 
00440 protected:
00441     KArchive* archive() const;
00442 
00443 protected:
00444     virtual void virtual_hook( int id, void* data );
00445 private:
00446     KArchiveEntryPrivate* const d;
00447 };
00448 
00449 class KArchiveFilePrivate;
00457 class KIO_EXPORT KArchiveFile : public KArchiveEntry
00458 {
00459 public:
00472     KArchiveFile( KArchive* archive, const QString& name, int access, int date,
00473                   const QString& user, const QString& group, const QString &symlink,
00474                   qint64 pos, qint64 size );
00475 
00479     virtual ~KArchiveFile();
00480 
00485     qint64 position() const;
00490     qint64 size() const;
00495     void setSize( qint64 s );
00496 
00502     virtual QByteArray data() const;
00503 
00514     virtual QIODevice *createDevice() const;
00515 
00520     virtual bool isFile() const;
00521 
00526     void copyTo(const QString& dest) const;
00527 
00528 protected:
00529     virtual void virtual_hook( int id, void* data );
00530 private:
00531     KArchiveFilePrivate* const d;
00532 };
00533 
00534 class KArchiveDirectoryPrivate;
00542 class KIO_EXPORT KArchiveDirectory : public KArchiveEntry
00543 {
00544 public:
00555     KArchiveDirectory( KArchive* archive, const QString& name, int access, int date,
00556                    const QString& user, const QString& group,
00557                    const QString& symlink);
00558 
00559     virtual ~KArchiveDirectory();
00560 
00568     QStringList entries() const;
00574     const KArchiveEntry* entry( const QString& name ) const;
00575 
00580     void addEntry( KArchiveEntry* );
00581 
00586     virtual bool isDirectory() const;
00587 
00594      void copyTo(const QString& dest, bool recursive = true) const;
00595 
00596 protected:
00597     virtual void virtual_hook( int id, void* data );
00598 private:
00599     KArchiveDirectoryPrivate* const d;
00600 };
00601 
00602 #endif

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal