1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 2000-2005 David Faure <faure@kde.org>
3 SPDX-FileCopyrightText: 2003 Leo Savernik <l.savernik@aon.at>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KARCHIVE_P_H
9#define KARCHIVE_P_H
10
11#include "karchive.h"
12
13#include <QSaveFile>
14
15// Documentation says that QByteArray should be able to hold up to 2^63 on 64 bit platforms
16// but practice says it aborts with something like 2314885530818453536, so go with MAX_INT for now
17static constexpr int kMaxQByteArraySize = std::numeric_limits<int>::max() - 32;
18
19class KArchivePrivate
20{
21 Q_DECLARE_TR_FUNCTIONS(KArchivePrivate)
22
23public:
24 KArchivePrivate(KArchive *parent)
25 : q(parent)
26 {
27 }
28 ~KArchivePrivate()
29 {
30 if (deviceOwned) {
31 delete dev; // we created it ourselves in open()
32 dev = nullptr;
33 }
34
35 delete rootDir;
36 }
37
38 KArchivePrivate(const KArchivePrivate &) = delete;
39 KArchivePrivate &operator=(const KArchivePrivate &) = delete;
40
41 static bool hasRootDir(KArchive *archive)
42 {
43 return archive->d->rootDir;
44 }
45
46 void abortWriting();
47
48 static QDateTime time_tToDateTime(uint seconds);
49
50 KArchiveDirectory *findOrCreateDirectory(const QStringView path);
51
52 KArchive *q = nullptr;
53 KArchiveDirectory *rootDir = nullptr;
54 std::unique_ptr<QSaveFile> saveFile;
55 QIODevice *dev = nullptr;
56 QString fileName;
57 QIODevice::OpenMode mode = QIODevice::NotOpen;
58 bool deviceOwned = false; // if true, we (KArchive) own dev and must delete it
59 QString errorStr{tr(sourceText: "Unknown error")};
60};
61
62#endif // KARCHIVE_P_H
63

source code of karchive/src/karchive_p.h