00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __ktar_h
00020 #define __ktar_h
00021
00022 #include <sys/stat.h>
00023 #include <sys/types.h>
00024
00025 #include <qdatetime.h>
00026 #include <qstring.h>
00027 #include <qstringlist.h>
00028 #include <qdict.h>
00029
00030 #include <karchive.h>
00031
00040 class KIO_EXPORT KTar : public KArchive
00041 {
00042 public:
00053 KTar( const QString& filename, const QString & mimetype = QString::null );
00054
00063 KTar( QIODevice * dev );
00064
00069 virtual ~KTar();
00070
00076 QString fileName() { return m_filename; }
00077
00084 void setOrigFileName( const QCString & fileName );
00085
00086
00087 bool writeSymLink(const QString &name, const QString &target,
00088 const QString &user, const QString &group,
00089 mode_t perm, time_t atime, time_t mtime, time_t ctime);
00090 virtual bool writeDir( const QString& name, const QString& user, const QString& group );
00091
00092 bool writeDir( const QString& name, const QString& user, const QString& group,
00093 mode_t perm, time_t atime, time_t mtime, time_t ctime );
00094 virtual bool prepareWriting( const QString& name, const QString& user, const QString& group, uint size );
00095
00096 bool prepareWriting( const QString& name, const QString& user,
00097 const QString& group, uint size, mode_t perm,
00098 time_t atime, time_t mtime, time_t ctime );
00099 virtual bool doneWriting( uint size );
00100
00101 protected:
00108 virtual bool openArchive( int mode );
00109 virtual bool closeArchive();
00110
00111 private:
00115 void prepareDevice( const QString & filename, const QString & mimetype, bool forced = false );
00116
00124 void fillBuffer( char * buffer, const char * mode, int size, time_t mtime,
00125 char typeflag, const char * uname, const char * gname );
00126
00138 void writeLonglink(char *buffer, const QCString &name, char typeflag,
00139 const char *uname, const char *gname);
00140
00141 Q_LONG readRawHeader(char *buffer);
00142 bool readLonglink(char *buffer,QCString &longlink);
00143 Q_LONG readHeader(char *buffer,QString &name,QString &symlink);
00144
00145 QString m_filename;
00146 protected:
00147 virtual void virtual_hook( int id, void* data );
00148 bool prepareWriting_impl(const QString& name, const QString& user,
00149 const QString& group, uint size, mode_t perm,
00150 time_t atime, time_t mtime, time_t ctime);
00151 bool writeDir_impl(const QString& name, const QString& user,
00152 const QString& group, mode_t perm,
00153 time_t atime, time_t mtime, time_t ctime );
00154 bool writeSymLink_impl(const QString &name, const QString &target,
00155 const QString &user, const QString &group,
00156 mode_t perm, time_t atime, time_t mtime, time_t ctime);
00157 private:
00158 class KTarPrivate;
00159 KTarPrivate * d;
00160 };
00161
00165 #define KTarGz KTar
00166 #define KTarEntry KArchiveEntry
00167 #define KTarFile KArchiveFile
00168 #define KTarDirectory KArchiveDirectory
00169
00170 #endif