Ring Daemon 16.0.0
Loading...
Searching...
No Matches
archiver.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 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 "noncopyable.h"
20
21#include <cstdint>
22#include <string>
23#include <vector>
24#include <map>
25#include <functional>
26
27#ifdef HAVE_CONFIG_H
28#include "config.h"
29#endif // HAVE_CONFIG_H
30
31typedef struct gzFile_s* gzFile;
32
33namespace jami {
34
38namespace archiver {
39
40using FileMatchPair = std::function<std::pair<bool, std::string_view>(std::string_view)>;
41
46std::vector<uint8_t> compress(const std::string& str);
47
51std::vector<uint8_t> decompress(const std::vector<uint8_t>& dat);
52
56void compressGzip(const std::string& str, const std::string& path);
57void compressGzip(const std::vector<uint8_t>& dat, const std::string& path);
58
62std::vector<uint8_t> decompressGzip(const std::string& path);
63
67gzFile openGzip(const std::string& path, const char* mode);
68
81void uncompressArchive(const std::string& path, const std::string& dir, const FileMatchPair& f);
82
91std::vector<uint8_t> readFileFromArchive(const std::string& path,
92 const std::string& fileRelativePathName);
93
99std::vector<std::string> listFilesFromArchive(const std::string& path);
100} // namespace archiver
101
102} // namespace jami
struct gzFile_s * gzFile
Definition archiver.h:31
void compressGzip(const std::string &str, const std::string &path)
Compress string to a Gzip file.
Definition archiver.cpp:76
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:111
std::vector< std::string > listFilesFromArchive(const std::string &path)
listFilesFromArchive list all files from an archive
Definition archiver.cpp:438
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:212
std::function< std::pair< bool, std::string_view >(std::string_view)> FileMatchPair
Definition archiver.h:40
gzFile openGzip(const std::string &path, const char *mode)
Open Gzip file (uses wide string version of gzopen on windows)
Definition archiver.cpp:154
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:348
std::vector< uint8_t > decompressGzip(const std::string &path)
Decompress Gzip file to bytes.
Definition archiver.cpp:92
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:56
void emitSignal(Args... args)
Definition ring_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.