pmt: Improve libhelper and libpartition_map, etc.

This commit is contained in:
2025-09-07 21:54:35 +03:00
parent 77760bd1d4
commit 9625bf6df0
8 changed files with 53 additions and 47 deletions

View File

@@ -21,6 +21,7 @@
#include <cstring>
#include <dirent.h>
#include <exception>
#include <functional>
#include <fcntl.h>
#include <libgen.h>
#include <libhelper/lib.hpp>
@@ -96,10 +97,8 @@ Logger &Logger::operator<<(std::ostream &(*msg)(std::ostream &)) {
}
garbageCollector::~garbageCollector() {
for (const auto &ptr : _ptrs_c)
delete[] ptr;
for (const auto &ptr : _ptrs_u)
delete[] ptr;
for (auto &ptr_func : _cleaners)
ptr_func();
for (const auto &fd : _fds)
close(fd);
for (const auto &fp : _fps)
@@ -110,18 +109,12 @@ garbageCollector::~garbageCollector() {
eraseEntry(file);
}
void garbageCollector::delAfterProgress(char *&_ptr) {
_ptrs_c.push_back(_ptr);
}
void garbageCollector::delAfterProgress(uint8_t *&_ptr) {
_ptrs_u.push_back(_ptr);
}
void garbageCollector::delFileAfterProgress(const std::string &path) {
_files.push_back(path);
void garbageCollector::delFileAfterProgress(const std::string &_path) {
_files.push_back(_path);
}
void garbageCollector::closeAfterProgress(const int _fd) {
_fds.push_back(_fd);
}
void garbageCollector::closeAfterProgress(FILE *&_fp) { _fps.push_back(_fp); }
void garbageCollector::closeAfterProgress(DIR *&_dp) { _dps.push_back(_dp); }
void garbageCollector::closeAfterProgress(FILE *_fp) { _fps.push_back(_fp); }
void garbageCollector::closeAfterProgress(DIR *_dp) { _dps.push_back(_dp); }
} // namespace Helper

View File

@@ -85,16 +85,6 @@ void set(std::string_view file, std::string_view name) {
void setProgramName(const std::string_view name) { NAME = name; }
void setLogFile(const std::string_view file) { FILE = file; }
void setPrinting(const int state) {
if (state == 1 || state == 0) PRINT = state;
else PRINT = NO;
}
void setLoggingState(const int state) {
if (state == 1 || state == 0) DISABLE = state;
else DISABLE = NO;
}
} // namespace LoggingProperties
bool runCommand(const std::string_view cmd) {