Coverage Report

Created: 2026-09-14 07:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/karchive/src/karchive_p.h
Line
Count
Source
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
#include <memory>
16
17
// Documentation says that QByteArray should be able to hold up to 2^63 on 64 bit platforms
18
// but practice says it aborts with something like 2314885530818453536, so go with MAX_INT for now
19
static constexpr int kMaxQByteArraySize = std::numeric_limits<int>::max() - 32;
20
21
class KArchivePrivate
22
{
23
    Q_DECLARE_TR_FUNCTIONS(KArchivePrivate)
24
25
public:
26
    KArchivePrivate(KArchive *parent)
27
8.57k
        : q(parent)
28
8.57k
    {
29
8.57k
    }
30
    ~KArchivePrivate()
31
8.57k
    {
32
8.57k
        if (deviceOwned) {
33
0
            delete dev; // we created it ourselves in open()
34
0
            dev = nullptr;
35
0
        }
36
8.57k
    }
37
38
    KArchivePrivate(const KArchivePrivate &) = delete;
39
    KArchivePrivate &operator=(const KArchivePrivate &) = delete;
40
41
    static bool hasRootDir(KArchive *archive)
42
0
    {
43
0
        return archive->d->rootDir.get();
44
0
    }
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
    std::unique_ptr<KArchiveDirectory> rootDir;
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("Unknown error")};
60
};
61
62
#endif // KARCHIVE_P_H