• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

  • tdeio
  • tdeio
kzip.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2002 Holger Schroeder <holger-kde@holgis.net>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 #ifndef __kzip_h
19 #define __kzip_h
20 
21 #include <sys/stat.h>
22 #include <sys/types.h>
23 
24 #include <tqdatetime.h>
25 #include <tqstring.h>
26 #include <tqstringlist.h>
27 #include <tqdict.h>
28 #include <tqvaluelist.h>
29 #include <karchive.h>
30 
31 class KZipFileEntry;
53 class TDEIO_EXPORT KZip : public KArchive
54 {
55 public:
62  KZip( const TQString& filename );
63 
71  KZip( TQIODevice * dev );
72 
77  virtual ~KZip();
78 
84  TQString fileName() { return m_filename; }
85 
89  enum ExtraField { NoExtraField = 0,
90  ModificationTime = 1,
91  DefaultExtraField = 1
92  };
93 
100  void setExtraField( ExtraField ef );
101 
107  ExtraField extraField() const;
108 
112  enum Compression { NoCompression = 0,
113  DeflateCompression = 1
114  };
115 
116 
123  void setCompression( Compression c );
124 
130  Compression compression() const;
131 
143  virtual bool writeFile( const TQString& name, const TQString& user, const TQString& group, uint size, const char* data ); // BC: remove reimplementation for KDE-4.0
144 
154  virtual bool prepareWriting( const TQString& name, const TQString& user, const TQString& group, uint size );
155 
156  // TODO(BIC) make virtual. For now it must be implemented by virtual_hook.
157  bool writeSymLink(const TQString &name, const TQString &target,
158  const TQString &user, const TQString &group,
159  mode_t perm, time_t atime, time_t mtime, time_t ctime);
160  // TODO(BIC) make virtual. For now it must be implemented by virtual_hook.
161  bool prepareWriting( const TQString& name, const TQString& user,
162  const TQString& group, uint size, mode_t perm,
163  time_t atime, time_t mtime, time_t ctime );
164  // TODO(BIC) make virtual. For now it must be implemented by virtual_hook.
165  bool writeFile( const TQString& name, const TQString& user, const TQString& group,
166  uint size, mode_t perm, time_t atime, time_t mtime,
167  time_t ctime, const char* data );
174  bool writeData( const char* data, uint size ); // TODO make virtual
175 
181  virtual bool doneWriting( uint size );
182 
183 protected:
190  virtual bool openArchive( int mode );
192  virtual bool closeArchive();
193 
197  virtual bool writeDir( const TQString& name, const TQString& user, const TQString& group);
198  // TODO(BIC) uncomment and make virtual for KDE 4.
199 // bool writeDir( const TQString& name, const TQString& user, const TQString& group,
200 // mode_t perm, time_t atime, time_t mtime, time_t ctime );
201 
202 protected:
203  virtual void virtual_hook( int id, void* data );
205  // from KArchive
206  bool writeData_impl( const char* data, uint size );
207  bool prepareWriting_impl(const TQString& name, const TQString& user,
208  const TQString& group, uint size, mode_t perm,
209  time_t atime, time_t mtime, time_t ctime);
210  bool writeSymLink_impl(const TQString &name, const TQString &target,
211  const TQString &user, const TQString &group,
212  mode_t perm, time_t atime, time_t mtime, time_t ctime);
213 private:
214  void abort();
215 
216 private:
217  TQString m_filename;
218  class KZipPrivate;
219  KZipPrivate * d;
220 };
221 
222 
226 class TDEIO_EXPORT KZipFileEntry : public KArchiveFile
227 {
228 public:
229  /*KZipFileEntry() : st(-1)
230  {}*/
231  KZipFileEntry( KZip* zip, const TQString& name, int access, int date,
232  const TQString& user, const TQString& group, const TQString& symlink,
233  const TQString& path, TQ_LONG start, TQ_LONG uncompressedSize,
234  int encoding, TQ_LONG compressedSize) :
235  KArchiveFile( zip, name, access, date, user, group, symlink,
236  start, uncompressedSize ),
237  m_crc(0),
238  m_compressedSize(compressedSize),
239  m_headerStart(0),
240  m_encoding(encoding),
241  m_path( path )
242  {}
243  int encoding() const { return m_encoding; }
244  TQ_LONG compressedSize() const { return m_compressedSize; }
245 
247  void setCompressedSize(TQ_LONG compressedSize) { m_compressedSize = compressedSize; }
248 
250  void setHeaderStart(TQ_LONG headerstart) { m_headerStart = headerstart; }
251  TQ_LONG headerStart() const {return m_headerStart; }
252 
254  unsigned long crc32() const { return m_crc; }
255  void setCRC32(unsigned long crc32) { m_crc=crc32; }
256 
258  TQString path() const { return m_path; }
259 
264  virtual TQByteArray data() const;
265 
273  TQIODevice* device() const; // WARNING, not virtual!
274 
275 private:
276  unsigned long m_crc;
277  TQ_LONG m_compressedSize;
278  TQ_LONG m_headerStart;
279  int m_encoding;
280  TQString m_path;
281  // KDE4: d pointer or at least some int for future extensions
282 };
283 
284 #endif
KArchiveFile
Represents a file entry in a KArchive.
Definition: karchive.h:491
KArchive
KArchive is a base class for reading and writing archives.
Definition: karchive.h:43
KArchive::writeDir
virtual bool writeDir(const TQString &name, const TQString &user, const TQString &group)=0
If an archive is opened for writing then you can add new directories using this function.
KArchive::closeArchive
virtual bool closeArchive()=0
Closes the archive.
KArchive::doneWriting
virtual bool doneWriting(uint size)=0
Call doneWriting after writing the data.
KArchive::openArchive
virtual bool openArchive(int mode)=0
Opens an archive for reading or writing.
KArchive::writeData
bool writeData(const char *data, uint size)
Write data into the current file - to be called after calling prepareWriting.
Definition: karchive.cpp:353
KArchive::device
TQIODevice * device() const
The underlying device.
Definition: karchive.h:96
KArchive::writeSymLink
bool writeSymLink(const TQString &name, const TQString &target, const TQString &user, const TQString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
Writes a symbolic link to the archive if the archive must be opened for writing.
Definition: karchive.cpp:327
KArchive::prepareWriting
virtual bool prepareWriting(const TQString &name, const TQString &user, const TQString &group, uint size)=0
Here's another way of writing a file into an archive: Call prepareWriting, then call writeData() as m...
KArchive::writeFile
virtual bool writeFile(const TQString &name, const TQString &user, const TQString &group, uint size, const char *data)
If an archive is opened for writing then you can add a new file using this function.
Definition: karchive.cpp:228
KZip
This class implements a tdeioslave to access zip files from KDE.
Definition: kzip.h:54
KZip::fileName
TQString fileName()
The name of the zip file, as passed to the constructor.
Definition: kzip.h:84
KZip::ExtraField
ExtraField
Describes the contents of the "extra field" for a given file in the Zip archive.
Definition: kzip.h:89
KZip::Compression
Compression
Describes the compression type for a given file in the Zip archive.
Definition: kzip.h:112
TDEIO::symlink
TDEIO_EXPORT SimpleJob * symlink(const TQString &target, const KURL &dest, bool overwrite, bool showProgressInfo=true)
Create or move a symlink.
Definition: job.cpp:808

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.1
This website is maintained by Timothy Pearson.