Coverage Report

Created: 2026-04-01 07:24

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
// 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
17
static constexpr int kMaxQByteArraySize = std::numeric_limits<int>::max() - 32;
18
19
class KArchivePrivate
20
{
21
    Q_DECLARE_TR_FUNCTIONS(KArchivePrivate)
22
23
public:
24
    KArchivePrivate(KArchive *parent)
25
17.5k
        : q(parent)
26
17.5k
    {
27
17.5k
    }
28
    ~KArchivePrivate()
29
17.5k
    {
30
17.5k
        if (deviceOwned) {
31
0
            delete dev; // we created it ourselves in open()
32
0
            dev = nullptr;
33
0
        }
34
35
17.5k
        delete rootDir;
36
17.5k
    }
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;
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
    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("Unknown error")};
60
};
61
62
#endif // KARCHIVE_P_H