MLBookProc 1.2.1
Loading...
Searching...
No Matches
ARCHParser.h
1/*
2 * Copyright (C) 2024-2025 Yury Bobylev <bobilev_yury@mail.ru>
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation, version 3.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16
17#ifndef ARCHPARSER_H
18#define ARCHPARSER_H
19
20#include <AuxFunc.h>
21#include <BookParseEntry.h>
22#include <LibArchive.h>
23#include <SelfRemovingPath.h>
24#include <archive.h>
25#include <filesystem>
26#include <memory>
27#include <vector>
28
29#ifndef USE_OPENMP
30#include <atomic>
31#include <condition_variable>
32#include <mutex>
33#else
34#include <omp.h>
35#endif
36
43class ARCHParser : public LibArchive
44{
45public:
52 ARCHParser(const std::shared_ptr<AuxFunc> &af, const bool &rar_support);
53
57 virtual ~ARCHParser();
58
66 std::vector<BookParseEntry>
67 arch_parser(const std::filesystem::path &filepath);
68
72 void
74
75private:
76 void
77 arch_process(const std::shared_ptr<archive> &a);
78
79 void
80 unpack_entry(const std::filesystem::path &ch_p,
81 const std::shared_ptr<archive> &a,
82 const std::shared_ptr<archive_entry> &e);
83
84 void
85 check_for_fbd();
86
87 static void
88 signalHandler(int sig);
89
90 std::shared_ptr<AuxFunc> af;
91 bool rar_support = false;
92
93 std::vector<BookParseEntry> result;
94 std::vector<BookParseEntry> fbd;
95
96 std::vector<ARCHParser *> archp_obj;
97
98#ifndef USE_OPENMP
99 std::mutex archp_obj_mtx;
100 std::atomic<bool> cancel;
101
102 bool extra_run = false;
103 std::mutex extra_run_mtx;
104 std::condition_variable extra_run_var;
105#else
106 bool cancel = false;
107 omp_lock_t archp_obj_mtx;
108#endif
109
110 std::filesystem::path arch_path;
111};
112
113#endif // ARCHPARSER_H
void stopAll()
Stops all operations.
ARCHParser(const std::shared_ptr< AuxFunc > &af, const bool &rar_support)
ARCHParser constructor.
virtual ~ARCHParser()
ARCHParser destructor.
std::vector< BookParseEntry > arch_parser(const std::filesystem::path &filepath)
This method carries out actual parsing.
LibArchive(const std::shared_ptr< AuxFunc > &af)
LibArchive constructor.