| 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 | class KArchivePrivate |
| 16 | { |
| 17 | Q_DECLARE_TR_FUNCTIONS(KArchivePrivate) |
| 18 | |
| 19 | public: |
| 20 | KArchivePrivate(KArchive *parent) |
| 21 | : q(parent) |
| 22 | { |
| 23 | } |
| 24 | ~KArchivePrivate() |
| 25 | { |
| 26 | if (deviceOwned) { |
| 27 | delete dev; // we created it ourselves in open() |
| 28 | dev = nullptr; |
| 29 | } |
| 30 | |
| 31 | delete rootDir; |
| 32 | } |
| 33 | |
| 34 | KArchivePrivate(const KArchivePrivate &) = delete; |
| 35 | KArchivePrivate &operator=(const KArchivePrivate &) = delete; |
| 36 | |
| 37 | static bool hasRootDir(KArchive *archive) |
| 38 | { |
| 39 | return archive->d->rootDir; |
| 40 | } |
| 41 | |
| 42 | void abortWriting(); |
| 43 | |
| 44 | static QDateTime time_tToDateTime(uint time_t); |
| 45 | |
| 46 | KArchiveDirectory *findOrCreate(const QString &path, int recursionCounter); |
| 47 | |
| 48 | KArchive *q = nullptr; |
| 49 | KArchiveDirectory *rootDir = nullptr; |
| 50 | std::unique_ptr<QSaveFile> saveFile; |
| 51 | QIODevice *dev = nullptr; |
| 52 | QString fileName; |
| 53 | QIODevice::OpenMode mode = QIODevice::NotOpen; |
| 54 | bool deviceOwned = false; // if true, we (KArchive) own dev and must delete it |
| 55 | QString errorStr{tr(sourceText: "Unknown error" )}; |
| 56 | }; |
| 57 | |
| 58 | #endif // KARCHIVE_P_H |
| 59 | |