• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • io
kzip.h
Go to the documentation of this file.
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 <karchive.h>
22
23class KZipFileEntry;
45class KDECORE_EXPORT KZip : public KArchive
46{
47public:
54 KZip( const QString& filename );
55
63 KZip( QIODevice * dev );
64
69 virtual ~KZip();
70
74 enum ExtraField { NoExtraField = 0,
75 ModificationTime = 1,
76 DefaultExtraField = 1
77 };
78
85 void setExtraField( ExtraField ef );
86
92 ExtraField extraField() const;
93
97 enum Compression { NoCompression = 0,
98 DeflateCompression = 1
99 };
100
101
108 void setCompression( Compression c );
109
115 Compression compression() const;
116
123 virtual bool writeData( const char* data, qint64 size );
124
125protected:
127 virtual bool doWriteSymLink(const QString &name, const QString &target,
128 const QString &user, const QString &group,
129 mode_t perm, time_t atime, time_t mtime, time_t ctime);
131 virtual bool doPrepareWriting( const QString& name, const QString& user,
132 const QString& group, qint64 size, mode_t perm,
133 time_t atime, time_t mtime, time_t ctime );
134
140 virtual bool doFinishWriting( qint64 size );
141
148 virtual bool openArchive( QIODevice::OpenMode mode );
149
151 virtual bool closeArchive();
152
154 virtual bool doWriteDir( const QString& name, const QString& user,
155 const QString& group, mode_t perm, time_t atime,
156 time_t mtime, time_t ctime );
157
158protected:
159 virtual void virtual_hook( int id, void* data );
160
161private:
162 class KZipPrivate;
163 KZipPrivate * const d;
164};
165
166
170class KDECORE_EXPORT KZipFileEntry : public KArchiveFile
171{
172public:
176 KZipFileEntry( KZip* zip, const QString& name, int access, int date,
177 const QString& user, const QString& group, const QString& symlink,
178 const QString& path, qint64 start, qint64 uncompressedSize,
179 int encoding, qint64 compressedSize);
180
184 ~KZipFileEntry();
185
186 int encoding() const;
187 qint64 compressedSize() const;
188
190 void setCompressedSize(qint64 compressedSize);
191
193 void setHeaderStart(qint64 headerstart);
194 qint64 headerStart() const;
195
197 unsigned long crc32() const;
198 void setCRC32(unsigned long crc32);
199
201 const QString &path() const;
202
207 virtual QByteArray data() const;
208
216 virtual QIODevice* createDevice() const;
217
218private:
219 class KZipFileEntryPrivate;
220 KZipFileEntryPrivate * const d;
221};
222
223#endif
KArchiveEntry::date
int date() const
Creation date of the file.
Definition karchive.cpp:546
KArchiveEntry::user
QString user() const
User who created the file.
Definition karchive.cpp:561
KArchiveEntry::group
QString group() const
Group of the user who created the file.
Definition karchive.cpp:566
KArchiveEntry::name
QString name() const
Name of the file without path.
Definition karchive.cpp:551
KArchiveFile::KArchiveFile
KArchiveFile(KArchive *archive, const QString &name, int access, int date, const QString &user, const QString &group, const QString &symlink, qint64 pos, qint64 size)
Creates a new file entry.
Definition karchive.cpp:606
KArchive::createDevice
virtual bool createDevice(QIODevice::OpenMode mode)
Can be reimplemented in order to change the creation of the device (when using the fileName construct...
Definition karchive.cpp:131
KArchive::doFinishWriting
virtual bool doFinishWriting(qint64 size)=0
Called after writing the data.
KArchive::doWriteDir
virtual bool doWriteDir(const QString &name, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)=0
Write a directory to the archive.
KArchive::KArchive
KArchive(const QString &fileName)
Base constructor (protected since this is a pure virtual class).
Definition karchive.cpp:81
KArchive::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition karchive.cpp:871
KArchive::closeArchive
virtual bool closeArchive()=0
Closes the archive.
KArchive::openArchive
virtual bool openArchive(QIODevice::OpenMode mode)=0
Opens an archive for reading or writing.
KArchive::writeData
virtual bool writeData(const char *data, qint64 size)
Write data into the current file - to be called after calling prepareWriting.
Definition karchive.cpp:345
KArchive::doWriteSymLink
virtual bool doWriteSymLink(const QString &name, const QString &target, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)=0
Writes a symbolic link to the archive.
KArchive::doPrepareWriting
virtual bool doPrepareWriting(const QString &name, const QString &user, const QString &group, qint64 size, mode_t perm, time_t atime, time_t mtime, time_t ctime)=0
This virtual method must be implemented by subclasses.
KZipFileEntry
A KZipFileEntry represents an file in a zip archive.
Definition kzip.h:171
KZipFileEntry::KZipFileEntry
KZipFileEntry(KZip *zip, const QString &name, int access, int date, const QString &user, const QString &group, const QString &symlink, const QString &path, qint64 start, qint64 uncompressedSize, int encoding, qint64 compressedSize)
Creates a new zip file entry.
Definition kzip.cpp:1318
KZipFileEntry::compressedSize
qint64 compressedSize() const
Definition kzip.cpp:1340
KZipFileEntry::setCompressedSize
void setCompressedSize(qint64 compressedSize)
Only used when writing.
Definition kzip.cpp:1345
KZipFileEntry::setCRC32
void setCRC32(unsigned long crc32)
Definition kzip.cpp:1365
KZipFileEntry::crc32
unsigned long crc32() const
CRC: only used when writing.
Definition kzip.cpp:1360
KZipFileEntry::path
const QString & path() const
Name with complete path - KArchiveFile::name() is the filename only (no path)
Definition kzip.cpp:1370
KZipFileEntry::data
virtual QByteArray data() const
Definition kzip.cpp:1375
KZipFileEntry::encoding
int encoding() const
Definition kzip.cpp:1335
KZipFileEntry::headerStart
qint64 headerStart() const
Definition kzip.cpp:1355
KZipFileEntry::setHeaderStart
void setHeaderStart(qint64 headerstart)
Header start: only used when writing.
Definition kzip.cpp:1350
KZip
A class for reading / writing zip archives.
Definition kzip.h:46
KZip::ExtraField
ExtraField
Describes the contents of the "extra field" for a given file in the Zip archive.
Definition kzip.h:74
KZip::DefaultExtraField
@ DefaultExtraField
Definition kzip.h:76
KZip::ModificationTime
@ ModificationTime
Modification time ("extended timestamp" header)
Definition kzip.h:75
KZip::NoExtraField
@ NoExtraField
No extra field.
Definition kzip.h:74
KZip::KZip
KZip(const QString &filename)
Creates an instance that operates on the given filename.
Definition kzip.cpp:395
KZip::Compression
Compression
Describes the compression type for a given file in the Zip archive.
Definition kzip.h:97
KZip::DeflateCompression
@ DeflateCompression
Deflate compression method.
Definition kzip.h:98
KZip::NoCompression
@ NoCompression
Uncompressed.
Definition kzip.h:97
QIODevice
QString
qint64
karchive.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal