MLBookProc 1.3
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 archProcess(const std::shared_ptr<archive> &a);
78
79 void
80 unpackEntry(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 checkForFbd();
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#else
102 bool cancel = false;
103 omp_lock_t archp_obj_mtx;
104#endif
105
106 std::filesystem::path arch_path;
107};
108
109#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.