KArchive

karchivefile.h
1 /* This file is part of the KDE libraries
2  SPDX-FileCopyrightText: 2000-2005 David Faure <[email protected]>
3  SPDX-FileCopyrightText: 2003 Leo Savernik <[email protected]>
4 
5  Moved from ktar.h by Roberto Teixeira <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 #ifndef KARCHIVEFILE_H
10 #define KARCHIVEFILE_H
11 
12 #include <karchiveentry.h>
13 
14 class KArchiveFilePrivate;
15 /**
16  * @class KArchiveFile karchivefile.h KArchiveFile
17  *
18  * Represents a file entry in a KArchive.
19  * @short A file in an archive.
20  *
21  * @see KArchive
22  * @see KArchiveDirectory
23  */
24 class KARCHIVE_EXPORT KArchiveFile : public KArchiveEntry
25 {
26 public:
27  /**
28  * Creates a new file entry. Do not call this, KArchive takes care of it.
29  * @param archive the entries archive
30  * @param name the name of the entry
31  * @param access the permissions in unix format
32  * @param date the date (in seconds since 1970)
33  * @param user the user that owns the entry
34  * @param group the group that owns the entry
35  * @param symlink the symlink, or QString()
36  * @param pos the position of the file in the directory
37  * @param size the size of the file
38  */
39  KArchiveFile(KArchive *archive,
40  const QString &name,
41  int access,
42  const QDateTime &date,
43  const QString &user,
44  const QString &group,
45  const QString &symlink,
46  qint64 pos,
47  qint64 size);
48 
49  /**
50  * Destructor. Do not call this, KArchive takes care of it.
51  */
52  ~KArchiveFile() override;
53 
54  /**
55  * Position of the data in the [uncompressed] archive.
56  * @return the position of the file
57  */
58  qint64 position() const;
59  /**
60  * Size of the data.
61  * @return the size of the file
62  */
63  qint64 size() const;
64  /**
65  * Set size of data, usually after writing the file.
66  * @param s the new size of the file
67  */
68  void setSize(qint64 s);
69 
70  /**
71  * Returns the data of the file.
72  * Call data() with care (only once per file), this data isn't cached.
73  * @return the content of this file.
74  */
75  virtual QByteArray data() const;
76 
77  /**
78  * This method returns QIODevice (internal class: KLimitedIODevice)
79  * on top of the underlying QIODevice. This is obviously for reading only.
80  *
81  * WARNING: Note that the ownership of the device is being transferred to the caller,
82  * who will have to delete it.
83  *
84  * The returned device auto-opens (in readonly mode), no need to open it.
85  * @return the QIODevice of the file
86  */
87  virtual QIODevice *createDevice() const;
88 
89  /**
90  * Checks whether this entry is a file.
91  * @return true, since this entry is a file
92  */
93  bool isFile() const override;
94 
95  /**
96  * Extracts the file to the directory @p dest
97  * @param dest the directory to extract to
98  * @return true on success, false if the file (dest + '/' + name()) couldn't be created
99  */
100  bool copyTo(const QString &dest) const;
101 
102 protected:
103  void virtual_hook(int id, void *data) override;
104 
105 private:
106  KArchiveFilePrivate *const d;
107 };
108 
109 #endif
Base class for the archive-file's directory structure.
Definition: karchiveentry.h:34
virtual bool isFile() const
Checks whether the entry is a file.
Definition: karchive.cpp:730
generic class for reading/writing archives
Definition: karchive.h:39
A file in an archive.
Definition: karchivefile.h:24
int access(const QString &path, int mode)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Aug 14 2022 04:02:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.