MLBookProc 1.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 <archive.h>
24#include <filesystem>
25#include <memory>
26#include <vector>
27
28#ifndef USE_OPENMP
29#include <atomic>
30#include <condition_variable>
31#include <mutex>
32#else
33#include <omp.h>
34#endif
35
42class ARCHParser : public LibArchive
43{
44public:
51 ARCHParser(const std::shared_ptr<AuxFunc> &af, const bool &rar_support);
52
56 virtual ~ARCHParser();
57
65 std::vector<BookParseEntry>
66 arch_parser(const std::filesystem::path &filepath);
67
71 void
73
74private:
75 void
76 arch_process(const std::shared_ptr<archive> &a);
77
78 void
79 unpack_entry(const std::filesystem::path &ch_p,
80 const std::shared_ptr<archive> &a,
81 const std::shared_ptr<archive_entry> &e);
82
83 void
84 check_for_fbd();
85
86 static void
87 signalHandler(int sig);
88
89 std::shared_ptr<AuxFunc> af;
90 bool rar_support = false;
91
92 std::vector<BookParseEntry> result;
93 std::vector<BookParseEntry> fbd;
94
95 std::vector<ARCHParser *> archp_obj;
96
97#ifndef USE_OPENMP
98 std::mutex archp_obj_mtx;
99 std::atomic<bool> cancel;
100
101 bool extra_run = false;
102 std::mutex extra_run_mtx;
103 std::condition_variable extra_run_var;
104#else
105 bool cancel = false;
106 omp_lock_t archp_obj_mtx;
107#endif
108
109 std::filesystem::path arch_path;
110};
111
112#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.