MythTV
master
libs
libmythbase
unzip2.h
Go to the documentation of this file.
1
/*
2
* Class UnZip
3
*
4
* Copyright (c) David Hampton 2021
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
// libzip
22
#include "zip.h"
23
24
// Qt headers
25
#include <QDir>
26
#include <QString>
27
#include <QFileInfo>
28
29
class
UnZip
30
{
31
// NOLINTNEXTLINE(readability-uppercase-literal-suffix)
32
static
constexpr uint64_t
kSTATS_REQUIRED
{ZIP_STAT_NAME|ZIP_STAT_INDEX|ZIP_STAT_SIZE|ZIP_STAT_MTIME|ZIP_STAT_ENCRYPTION_METHOD};
33
34
struct
zipEntry
35
{
36
int
m_index
{0};
37
zip_stat_t
m_stats
{};
38
zip_uint32_t
m_attributes
{0};
39
QFileInfo
m_fi
;
40
};
41
42
public
:
43
explicit
UnZip
(QString zipFile);
44
~UnZip
();
45
bool
extractFile
(
const
QString& outDir);
46
47
private
:
48
bool
isValid
() {
return
m_zip
!=
nullptr
; };
49
bool
getEntryStats
(zipEntry& entry);
50
void
getEntryAttrs
(zipEntry& entry);
51
static
QFileDevice::Permissions
zipToQtPerms
(
const
zipEntry& entry);
52
static
bool
zipCreateDirectory
(
const
zipEntry& entry);
53
bool
zipValidateFilename
(
const
QFileInfo& fi);
54
static
void
zipSetFileAttributes
(
const
zipEntry& entry, QFile& outfile);
55
bool
zipCreateSymlink
(
const
zipEntry& entry);
56
bool
zipWriteOneFile
(
const
zipEntry& entry);
57
58
QDir
m_outDir
;
59
60
// Info about zip file itself
61
QString
m_zipFileName
;
62
zip_t *
m_zip
{
nullptr
};
63
zip_int64_t
m_zipFileCount
{-1};
64
};
UnZip::zipCreateDirectory
static bool zipCreateDirectory(const zipEntry &entry)
Definition:
unzip2.cpp:91
UnZip::isValid
bool isValid()
Definition:
unzip2.h:48
UnZip::zipToQtPerms
static QFileDevice::Permissions zipToQtPerms(const zipEntry &entry)
Definition:
unzip2.cpp:118
UnZip::UnZip
UnZip(QString zipFile)
Definition:
unzip2.cpp:38
UnZip::zipValidateFilename
bool zipValidateFilename(const QFileInfo &fi)
Definition:
unzip2.cpp:107
UnZip::kSTATS_REQUIRED
static constexpr uint64_t kSTATS_REQUIRED
Definition:
unzip2.h:32
UnZip::~UnZip
~UnZip()
Definition:
unzip2.cpp:51
UnZip::zipWriteOneFile
bool zipWriteOneFile(const zipEntry &entry)
Definition:
unzip2.cpp:201
UnZip::getEntryStats
bool getEntryStats(zipEntry &entry)
Definition:
unzip2.cpp:62
UnZip::m_zip
zip_t * m_zip
Definition:
unzip2.h:62
UnZip::zipEntry::m_attributes
zip_uint32_t m_attributes
Definition:
unzip2.h:38
UnZip::zipSetFileAttributes
static void zipSetFileAttributes(const zipEntry &entry, QFile &outfile)
Definition:
unzip2.cpp:148
UnZip::m_zipFileName
QString m_zipFileName
Definition:
unzip2.h:61
UnZip::zipEntry::m_fi
QFileInfo m_fi
Definition:
unzip2.h:39
UnZip::extractFile
bool extractFile(const QString &outDir)
Definition:
unzip2.cpp:264
UnZip::zipEntry::m_index
int m_index
Definition:
unzip2.h:36
UnZip::getEntryAttrs
void getEntryAttrs(zipEntry &entry)
Definition:
unzip2.cpp:82
UnZip
Definition:
unzip2.h:29
UnZip::m_outDir
QDir m_outDir
Definition:
unzip2.h:58
UnZip::zipEntry
Definition:
unzip2.h:34
UnZip::zipEntry::m_stats
zip_stat_t m_stats
Definition:
unzip2.h:37
UnZip::m_zipFileCount
zip_int64_t m_zipFileCount
Definition:
unzip2.h:63
UnZip::zipCreateSymlink
bool zipCreateSymlink(const zipEntry &entry)
Definition:
unzip2.cpp:163
Generated on Mon Oct 2 2023 03:19:36 for MythTV by
1.8.17