pmt: The basis of the system for adding features was created and improvements were made.

- The basic header contents of the system, designed to easily add features, were written.
 - The [CLI11](https://github.com/CLIUtils/CLI11) project was included to provide a better experience for the project.
 - Improved logging system.
 - Unnecessary code cleaned.
This commit is contained in:
2025-07-24 17:38:31 +03:00
parent 18b5700cbd
commit 9cd97a085e
16 changed files with 11763 additions and 46 deletions

View File

@@ -55,12 +55,14 @@ Map_t basic_partition_map_builder::_build_map(std::string_view path, bool logica
return a.path().filename() < b.path().filename();
});
LOGN_IF(MAP, WARNING, entries.empty()) << __func__ << "(): " << path << "is exists but generated vector is empty (std::vector<std::filesystem::directory_entry>)." << std::endl;
for (const auto& entry : entries) {
if (entry.path().filename() != "by-uuid"
&& std::string(entry.path()).find("com.") == std::string::npos)
map.insert(entry.path().filename().string(), _get_size(entry.path()), logical);
}
LOGN(MAP, INFO) << std::boolalpha << __func__ << "(): Map generated successfully. is_logical_map=" << logical << std::endl;
return map;
}
@@ -94,6 +96,8 @@ uint64_t basic_partition_map_builder::_get_size(const std::string path)
basic_partition_map_builder::basic_partition_map_builder()
{
LOGN(MAP, INFO) << __func__ << "(): default constructor called. Starting build." << std::endl;
for (const auto& path : defaultEntryList) {
if (std::filesystem::exists(path)) {
_current_map = _build_map(path);
@@ -110,12 +114,15 @@ basic_partition_map_builder::basic_partition_map_builder()
if (_current_map.empty())
throw Error("Cannot build map by any default search entry.");
LOGN(MAP, INFO) << __func__ << "(): default constructor successfully ended work." << std::endl;
_insert_logicals(_build_map("/dev/block/mapper", true));
_map_builded = true;
}
basic_partition_map_builder::basic_partition_map_builder(const std::string_view path)
{
LOGN(MAP, INFO) << __func__ << "(): argument-based constructor called. Starting build." << std::endl;
if (std::filesystem::exists(path)) {
_is_real_block_dir(path);
_current_map = _build_map(path);
@@ -124,6 +131,7 @@ basic_partition_map_builder::basic_partition_map_builder(const std::string_view
} else
throw Error("Cannot find directory: %s. Cannot build partition map!", path.data());
LOGN(MAP, INFO) << __func__ << "(): argument-based constructor successfully ended work." << std::endl;
_insert_logicals(_build_map("/dev/block/mapper", true));
_map_builded = true;
}
@@ -150,6 +158,7 @@ void basic_partition_map_builder::clear()
bool basic_partition_map_builder::readDirectory(const std::string_view path)
{
_map_builded = false;
LOGN(MAP, INFO) << __func__ << "(): read " << path << " directory request." << std::endl;
if (std::filesystem::exists(path)) {
if (!_is_real_block_dir(path)) return false;
@@ -161,6 +170,7 @@ bool basic_partition_map_builder::readDirectory(const std::string_view path)
} else
throw Error("Cannot find directory: %s. Cannot build partition map!", path.data());
LOGN(MAP, INFO) << __func__ << "(): read " << path << " successfull." << std::endl;
_insert_logicals(_build_map("/dev/block/mapper", true));
_map_builded = true;
return true;