Loading...
Searching...
No Matches
Zip.hpp
1#pragma once
2#include <QByteArray>
3#include <QString>
4
5#include <score_lib_base_export.h>
6
7#include <functional>
8#include <optional>
9#include <vector>
10
11namespace score
12{
13
16{
18 QString sourceFile;
21};
22
24using ZipProgress = std::function<bool(int, int)>;
25
36SCORE_LIB_BASE_EXPORT
38 const QString& destination, const std::vector<ZipEntry>& entries, int level,
39 QString& error, const ZipProgress& progress = {});
40
43{
45 QString scoreFile;
46 int files{};
47 quint64 uncompressedSize{};
48};
49
57SCORE_LIB_BASE_EXPORT
58std::optional<ZipArchiveSummary> summarizeZipArchive(const QString& archive);
59
62SCORE_LIB_BASE_EXPORT
63bool isSafeZipMemberName(const QString& name);
64
67SCORE_LIB_BASE_EXPORT
68QByteArray readZipMember(
69 const QString& archive, const QString& member, QString& error,
70 quint64 maxSize = 256 * 1024 * 1024);
71
79SCORE_LIB_BASE_EXPORT
81 const QString& archive, const QString& destination, QString& error,
82 const ZipProgress& progress = {});
83}
Base toolkit upon which the software is built.
Definition Application.cpp:83
bool extractZipArchive(const QString &archive, const QString &destination, QString &error, const ZipProgress &progress)
Extract every member of archive under destination.
Definition Zip.cpp:225
QByteArray readZipMember(const QString &archive, const QString &member, QString &error, quint64 maxSize)
Definition Zip.cpp:185
bool writeZipArchive(const QString &destination, const std::vector< ZipEntry > &entries, int level, QString &error, const ZipProgress &progress)
Write entries into a zip archive at destination.
Definition Zip.cpp:19
bool isSafeZipMemberName(const QString &name)
Definition Zip.cpp:125
std::function< bool(int, int)> ZipProgress
Called with (files written, total). Return false to abort the archive.
Definition Zip.hpp:24
std::optional< ZipArchiveSummary > summarizeZipArchive(const QString &archive)
Look at a zip's table of contents without inflating anything.
Definition Zip.cpp:137
What a project archive holds, read from the archive's directory only.
Definition Zip.hpp:43
QString scoreFile
Path of the .score inside the archive, e.g. "foo.score" or "foo/foo.score".
Definition Zip.hpp:45
One file to put in an archive.
Definition Zip.hpp:16
QString nameInArchive
Path it takes inside the archive, always with forward slashes.
Definition Zip.hpp:20
QString sourceFile
Absolute path of the file to read.
Definition Zip.hpp:18