Ring Daemon
Loading...
Searching...
No Matches
archiver.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <cstdint>
20#include <string>
21#include <vector>
22#include <functional>
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif // HAVE_CONFIG_H
27
28typedef struct gzFile_s* gzFile;
29
30namespace jami {
31
35namespace archiver {
36
37using FileMatchPair = std::function<std::pair<bool, std::string_view>(std::string_view)>;
38
43std::vector<uint8_t> compress(const std::string& str);
44
48std::vector<uint8_t> decompress(const std::vector<uint8_t>& dat);
49
53void compressGzip(const std::string& str, const std::string& path);
54void compressGzip(const std::vector<uint8_t>& dat, const std::string& path);
55
59std::vector<uint8_t> decompressGzip(const std::string& path);
60
64gzFile openGzip(const std::string& path, const char* mode);
65
78void uncompressArchive(const std::string& path, const std::string& dir, const FileMatchPair& f);
79
88std::vector<uint8_t> readFileFromArchive(const std::string& path, const std::string& fileRelativePathName);
89
95std::vector<std::string> listFilesFromArchive(const std::string& path);
96} // namespace archiver
97
98} // namespace jami
struct gzFile_s * gzFile
Definition archiver.h:28
void compressGzip(const std::string &str, const std::string &path)
Compress string to a Gzip file.
Definition archiver.cpp:66
std::vector< uint8_t > decompress(const std::vector< uint8_t > &str)
Decompress an STL string using zlib and return the original data.
Definition archiver.cpp:101
std::vector< std::string > listFilesFromArchive(const std::string &path)
listFilesFromArchive list all files from an archive
Definition archiver.cpp:417
void uncompressArchive(const std::string &archivePath, const std::string &dir, const FileMatchPair &f)
uncompressArchive Uncompresses an archive and puts the different files in dir folder according to a F...
Definition archiver.cpp:200
std::function< std::pair< bool, std::string_view >(std::string_view)> FileMatchPair
Definition archiver.h:37
gzFile openGzip(const std::string &path, const char *mode)
Open Gzip file (uses wide string version of gzopen on windows)
Definition archiver.cpp:142
std::vector< uint8_t > readFileFromArchive(const std::string &archivePath, const std::string &fileRelativePathName)
readFileFromArchive read a file from an archive without uncompressing the whole archive
Definition archiver.cpp:329
std::vector< uint8_t > decompressGzip(const std::string &path)
Decompress Gzip file to bytes.
Definition archiver.cpp:82
std::vector< uint8_t > compress(const std::string &str)
Compress a STL string using zlib with given compression level and return the binary data.
Definition archiver.cpp:51
void emitSignal(Args... args)
Definition jami_signal.h:64