ktar.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 David Faure <faure@kde.org> 00003 Copyright (C) 2003 Leo Savernik <l.savernik@aon.at> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 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; } // TODO KDE4 const 00077 00084 void setOrigFileName( const QCString & fileName ); 00085 00086 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 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 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 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 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 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