pmt: reformat code and improve workflow
This commit is contained in:
@@ -20,12 +20,12 @@
|
||||
#include <cstdint>
|
||||
#include <dirent.h>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#define KB(x) (static_cast<uint64_t>(x) * 1024) // KB(8) = 8192 (8 * 1024)
|
||||
#define MB(x) (KB(x) * 1024) // MB(4) = 4194304 (KB(4) * 1024)
|
||||
@@ -96,9 +96,8 @@ private:
|
||||
public:
|
||||
~garbageCollector();
|
||||
|
||||
template <typename T>
|
||||
void delAfterProgress(T *_ptr) {
|
||||
_cleaners.push_back([_ptr] { delete[] _ptr; });
|
||||
template <typename T> void delAfterProgress(T *_ptr) {
|
||||
_cleaners.push_back([_ptr] { delete[] _ptr; });
|
||||
}
|
||||
|
||||
void delFileAfterProgress(const std::string &_path);
|
||||
@@ -115,13 +114,11 @@ void set(std::string_view name, std::string_view file);
|
||||
void setProgramName(std::string_view name);
|
||||
void setLogFile(std::string_view file);
|
||||
|
||||
template <int state>
|
||||
void setPrinting() {
|
||||
template <int state> void setPrinting() {
|
||||
if (state == 1 || state == 0) PRINT = state;
|
||||
else PRINT = NO;
|
||||
}
|
||||
template <int state>
|
||||
void setLoggingState() {
|
||||
template <int state> void setLoggingState() {
|
||||
if (state == 1 || state == 0) DISABLE = state;
|
||||
else DISABLE = NO;
|
||||
}
|
||||
@@ -352,8 +349,7 @@ std::string convertTo(uint64_t size, const std::string &multiple);
|
||||
/**
|
||||
* Convert input size to input multiple
|
||||
*/
|
||||
template <uint64_t size>
|
||||
std::string convertTo(const std::string &multiple) {
|
||||
template <uint64_t size> std::string convertTo(const std::string &multiple) {
|
||||
if (multiple == "KB") return std::to_string(TO_KB(size));
|
||||
if (multiple == "MB") return std::to_string(TO_MB(size));
|
||||
if (multiple == "GB") return std::to_string(TO_GB(size));
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include <cstring>
|
||||
#include <dirent.h>
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <fcntl.h>
|
||||
#include <functional>
|
||||
#include <libgen.h>
|
||||
#include <libhelper/lib.hpp>
|
||||
#include <sstream>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#else
|
||||
#include <sys/system_properties.h>
|
||||
#endif
|
||||
#include <cutils/android_reboot.h>
|
||||
#include <iostream>
|
||||
#include <libgen.h>
|
||||
#include <libhelper/lib.hpp>
|
||||
@@ -32,7 +33,6 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <sys/_system_properties.h>
|
||||
#include <cutils/android_reboot.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
explicit operator bool() const;
|
||||
|
||||
Info operator[](int index) const;
|
||||
BasicInf operator[](const std::string_view& name) const;
|
||||
BasicInf operator[](const std::string_view &name) const;
|
||||
|
||||
operator std::vector<Info>() const;
|
||||
operator int() const;
|
||||
@@ -363,7 +363,7 @@ public:
|
||||
/**
|
||||
* Get BasicInfo structure with given index
|
||||
*/
|
||||
BasicInf operator[](const std::string_view& name) const;
|
||||
BasicInf operator[](const std::string_view &name) const;
|
||||
|
||||
/**
|
||||
* Get map contents as vector (PartitionManager::Info type).
|
||||
|
||||
@@ -136,8 +136,7 @@ basic_partition_map_builder::basic_partition_map_builder() {
|
||||
LOGN(MAP, ERROR) << "Cannot build map by any default search entry."
|
||||
<< std::endl;
|
||||
|
||||
LOGN(MAP, INFO) << "default constructor ended work."
|
||||
<< std::endl;
|
||||
LOGN(MAP, INFO) << "default constructor ended work." << std::endl;
|
||||
_insert_logicals(_build_map("/dev/block/mapper", true));
|
||||
_map_builded = true;
|
||||
}
|
||||
@@ -420,7 +419,8 @@ Info basic_partition_map_builder::operator[](const int index) const {
|
||||
return _current_map[index];
|
||||
}
|
||||
|
||||
BasicInf basic_partition_map_builder::operator[](const std::string_view& name) const {
|
||||
BasicInf
|
||||
basic_partition_map_builder::operator[](const std::string_view &name) const {
|
||||
return _current_map[name];
|
||||
}
|
||||
|
||||
|
||||
@@ -184,9 +184,7 @@ std::string basic_partition_map::find_(const std::string &name) const {
|
||||
|
||||
size_t basic_partition_map::size() const { return _count; }
|
||||
|
||||
bool basic_partition_map::empty() const {
|
||||
return _count == 0;
|
||||
}
|
||||
bool basic_partition_map::empty() const { return _count == 0; }
|
||||
|
||||
void basic_partition_map::clear() {
|
||||
LOGN(MAP, INFO) << "map clean requested. Cleaning..." << std::endl;
|
||||
@@ -228,20 +226,16 @@ bool basic_partition_map::operator!=(const basic_partition_map &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
basic_partition_map::operator bool() const{
|
||||
return _count > 0;
|
||||
}
|
||||
basic_partition_map::operator bool() const { return _count > 0; }
|
||||
|
||||
bool basic_partition_map::operator!() const{
|
||||
return _count == 0;
|
||||
}
|
||||
bool basic_partition_map::operator!() const { return _count == 0; }
|
||||
|
||||
Info basic_partition_map::operator[](const int index) const {
|
||||
if (_count == 0 || index >= _count) return {};
|
||||
return _data[index];
|
||||
}
|
||||
|
||||
BasicInf basic_partition_map::operator[](const std::string_view& name) const {
|
||||
BasicInf basic_partition_map::operator[](const std::string_view &name) const {
|
||||
if (_count == 0) return {};
|
||||
|
||||
if (const int i = _index_of(name); name == _data[i].name)
|
||||
|
||||
Reference in New Issue
Block a user