Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
ArchiveReader.h
浏览该文件的文档.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
19
20
21#pragma once
22
23#include <sese/archive/Config.h>
24#include <sese/io/InputStream.h>
25
26#include <functional>
27#include <filesystem>
28
29namespace sese::archive {
30
33 public:
35 using ExtractCallback = std::function<bool(const std::filesystem::path &base_path, Config::EntryType type, io::InputStream *input, size_t readable)>;
36
42 static bool extract(const std::filesystem::path &src_path, const std::filesystem::path &dest_path, const std::string &pwd = {});
43
47
48 virtual ~ArchiveReader();
49
53 [[nodiscard]] int setPassword(const std::string &pwd) const;
54
58 [[nodiscard]] int setOptions(const std::string &opt) const;
59
63 bool extract(const ExtractCallback &callback);
64
67 [[nodiscard]] int getError()const;
68
71 [[nodiscard]] const char *getErrorString()const;
72
73 static int openCallback(void *a, ArchiveReader *archive_this);
74
75 static int64_t readCallback(void *a, ArchiveReader *archive_this, const void **buffer);
76
77 static int closeCallback(void *a, ArchiveReader *archive_this);
78
79 protected:
80 char buffer[4096]{};
81 void *archive{};
83 };
84}