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 <tqdatetime.h> 00026 #include <tqstring.h> 00027 #include <tqstringlist.h> 00028 #include <tqdict.h> 00029 00030 #include <karchive.h> 00031 00040 class TDEIO_EXPORT KTar : public KArchive 00041 { 00042 public: 00054 KTar( const TQString& filename, const TQString & mimetype = TQString::null ); 00055 00064 KTar( TQIODevice * dev ); 00065 00070 virtual ~KTar(); 00071 00077 TQString fileName() { return m_filename; } // TODO KDE4 const 00078 00085 void setOrigFileName( const TQCString & fileName ); 00086 00087 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 00088 bool writeSymLink(const TQString &name, const TQString &target, 00089 const TQString &user, const TQString &group, 00090 mode_t perm, time_t atime, time_t mtime, time_t ctime); 00091 virtual bool writeDir( const TQString& name, const TQString& user, const TQString& group ); 00092 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 00093 bool writeDir( const TQString& name, const TQString& user, const TQString& group, 00094 mode_t perm, time_t atime, time_t mtime, time_t ctime ); 00095 virtual bool prepareWriting( const TQString& name, const TQString& user, const TQString& group, uint size ); 00096 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 00097 bool prepareWriting( const TQString& name, const TQString& user, 00098 const TQString& group, uint size, mode_t perm, 00099 time_t atime, time_t mtime, time_t ctime ); 00100 virtual bool doneWriting( uint size ); 00101 00102 protected: 00109 virtual bool openArchive( int mode ); 00110 virtual bool closeArchive(); 00111 00112 private: 00116 void prepareDevice( const TQString & filename, const TQString & mimetype, bool forced = false ); 00117 00125 void fillBuffer( char * buffer, const char * mode, int size, time_t mtime, 00126 char typeflag, const char * uname, const char * gname ); 00127 00139 void writeLonglink(char *buffer, const TQCString &name, char typeflag, 00140 const char *uname, const char *gname); 00141 00142 TQ_LONG readRawHeader(char *buffer); 00143 bool readLonglink(char *buffer,TQCString &longlink); 00144 TQ_LONG readHeader(char *buffer,TQString &name,TQString &symlink); 00145 00146 TQString m_filename; 00147 protected: 00148 virtual void virtual_hook( int id, void* data ); 00149 bool prepareWriting_impl(const TQString& name, const TQString& user, 00150 const TQString& group, uint size, mode_t perm, 00151 time_t atime, time_t mtime, time_t ctime); 00152 bool writeDir_impl(const TQString& name, const TQString& user, 00153 const TQString& group, mode_t perm, 00154 time_t atime, time_t mtime, time_t ctime ); 00155 bool writeSymLink_impl(const TQString &name, const TQString &target, 00156 const TQString &user, const TQString &group, 00157 mode_t perm, time_t atime, time_t mtime, time_t ctime); 00158 private: 00159 class KTarPrivate; 00160 KTarPrivate * d; 00161 }; 00162 00166 #define KTarGz KTar 00167 #define KTarEntry KArchiveEntry 00168 #define KTarFile KArchiveFile 00169 #define KTarDirectory KArchiveDirectory 00170 00171 #endif