27#include <tqdatetime.h>
29#include <tqstringlist.h>
32#include <tdelibs_export.h>
90 int mode()
const {
return m_mode; }
96 TQIODevice *
device()
const {
return m_dev; }
115 bool addLocalFile(
const TQString& fileName,
const TQString& destName );
128 bool addLocalDirectory(
const TQString& path,
const TQString& destName );
142 virtual bool writeDir(
const TQString& name,
const TQString& user,
const TQString& group ) = 0;
161 bool writeDir(
const TQString& name,
const TQString& user,
const TQString& group,
162 mode_t perm, time_t atime, time_t mtime, time_t ctime );
178 bool writeSymLink(
const TQString &name,
const TQString &target,
179 const TQString &user,
const TQString &group,
180 mode_t perm, time_t atime, time_t mtime, time_t ctime);
195 virtual bool writeFile(
const TQString& name,
const TQString& user,
const TQString& group, uint size,
const char* data );
218 bool writeFile(
const TQString& name,
const TQString& user,
const TQString& group,
219 uint size, mode_t perm, time_t atime, time_t mtime,
220 time_t ctime,
const char* data );
238 virtual bool prepareWriting(
const TQString& name,
const TQString& user,
const TQString& group, uint size ) = 0;
262 const TQString& group, uint size, mode_t perm,
263 time_t atime, time_t mtime, time_t ctime );
269 bool writeData(
const char* data, uint size );
312 void setDevice( TQIODevice *dev );
324 virtual void virtual_hook(
int id,
void* data );
326 enum { VIRTUAL_WRITE_DATA = 1, VIRTUAL_WRITE_SYMLINK, VIRTUAL_WRITE_DIR,
327 VIRTUAL_WRITE_FILE, VIRTUAL_PREPARE_WRITING };
328 bool prepareWriting_impl(
const TQString& name,
const TQString& user,
329 const TQString& group, uint size, mode_t perm,
330 time_t atime, time_t mtime, time_t ctime );
331 struct PrepareWritingParams {
332 const TQString *name;
333 const TQString *user;
334 const TQString *group;
337 time_t atime, mtime, ctime;
340 bool writeFile_impl(
const TQString& name,
const TQString& user,
341 const TQString& group, uint size, mode_t perm,
342 time_t atime, time_t mtime, time_t ctime,
344 struct WriteFileParams {
345 const TQString *name;
346 const TQString *user;
347 const TQString *group;
350 time_t atime, mtime, ctime;
354 bool writeDir_impl(
const TQString& name,
const TQString& user,
355 const TQString& group, mode_t perm,
356 time_t atime, time_t mtime, time_t ctime);
357 struct WriteDirParams {
358 const TQString *name;
359 const TQString *user;
360 const TQString *group;
362 time_t atime, mtime, ctime;
365 bool writeSymLink_impl(
const TQString &name,
const TQString &target,
366 const TQString &user,
const TQString &group,
367 mode_t perm, time_t atime, time_t mtime, time_t ctime);
368 struct WriteSymlinkParams {
369 const TQString *name;
370 const TQString *target;
371 const TQString *user;
372 const TQString *group;
374 time_t atime, mtime, ctime;
377 bool writeData_impl(
const char* data, uint size );
378 struct WriteDataParams {
384 class KArchivePrivate;
409 const TQString&
user,
const TQString&
group,
424 int date()
const {
return m_date; }
430 TQString
name()
const {
return m_name; }
441 TQString
user()
const {
return m_user; }
446 TQString
group()
const {
return m_group; }
452 TQString
symlink()
const {
return m_symlink; }
458 virtual bool isFile()
const {
return false; }
467 KArchive* archive()
const {
return m_archive; }
478 virtual void virtual_hook(
int id,
void* data );
480 class KArchiveEntryPrivate* d;
532 virtual TQByteArray data()
const;
542 TQIODevice *device()
const;
548 virtual bool isFile()
const {
return true; }
555 void copyTo(
const TQString& dest)
const;
561 virtual void virtual_hook(
int id,
void* data );
563 class KArchiveFilePrivate* d;
587 const TQString&
user,
const TQString&
group,
629 void copyTo(
const TQString& dest,
bool recursive =
true)
const;
632 TQDict<KArchiveEntry> m_entries;
634 virtual void virtual_hook(
int id,
void* data );
636 class KArchiveDirectoryPrivate* d;
Represents a directory entry in a KArchive.
TQStringList entries() const
Returns a list of sub-entries.
KArchiveDirectory(KArchive *archive, const TQString &name, int access, int date, const TQString &user, const TQString &group, const TQString &symlink)
Creates a new directory entry.
virtual bool isDirectory() const
Checks whether this entry is a directory.
KArchiveEntry * entry(TQString name)
Returns the entry with the given name.
virtual bool isDirectory() const
Checks whether the entry is a directory.
int date() const
Creation date of the file.
mode_t permissions() const
The permissions and mode flags as returned by the stat() function in st_mode.
TQString group() const
Group of the user who created the file.
TQString user() const
User who created the file.
virtual bool isFile() const
Checks whether the entry is a file.
TQString name() const
Name of the file without path.
TQDateTime datetime() const
Creation date of the file.
TQString symlink() const
Symlink if there is one.
KArchiveEntry(KArchive *archive, const TQString &name, int access, int date, const TQString &user, const TQString &group, const TQString &symlink)
Creates a new entry.
Represents a file entry in a KArchive.
KArchiveFile(KArchive *archive, const TQString &name, int access, int date, const TQString &user, const TQString &group, const TQString &symlink, int pos, int size)
Creates a new file entry.
int size() const
Size of the data.
void setSize(int s)
Set size of data, usually after writing the file.
int position() const
Position of the data in the [uncompressed] archive.
virtual bool isFile() const
Checks whether this entry is a file.
KArchive is a base class for reading and writing archives.
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.
virtual KArchiveDirectory * rootDir()
Retrieves or create the root directory.
virtual bool open(int mode)
Opens the archive for reading or writing.
KArchive(TQIODevice *dev)
Base constructor (protected since this is a pure virtual class).
KArchiveDirectory * findOrCreate(const TQString &path)
Ensures that path exists, create otherwise.
virtual void close()
Closes the archive.
virtual bool closeArchive()=0
Closes the archive.
int mode() const
Returns the mode in which the archive was opened.
TQIODevice * device() const
The underlying device.
virtual bool doneWriting(uint size)=0
Call doneWriting after writing the data.
virtual bool openArchive(int mode)=0
Opens an archive for reading or writing.
bool isOpened() const
Checks whether the archive is open.
bool closeSucceeded() const
Use to check if close had any problem.
bool writeData(const char *data, uint size)
Write data into the current file - to be called after calling prepareWriting.
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.
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...
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.