pmt: reformat code and improve workflow
This commit is contained in:
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
|
||||
#include <PartitionManager/PartitionManager.hpp>
|
||||
#include <algorithm>
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace PartitionManager {
|
||||
std::vector<std::string> splitIfHasDelim(const std::string &s, const char delim,
|
||||
@@ -96,9 +96,11 @@ bool basic_function_manager::hasFlagOnUsedFunction(const int flag) const {
|
||||
for (const auto &func : _functions) {
|
||||
if (func->isUsed()) {
|
||||
std::for_each(func->flags.begin(), func->flags.end(), [&](const int x) {
|
||||
LOGN(PMTF, INFO) << "Used flag " << x << " on " << func->name() << std::endl;
|
||||
LOGN(PMTF, INFO) << "Used flag " << x << " on " << func->name()
|
||||
<< std::endl;
|
||||
});
|
||||
return std::find(func->flags.begin(), func->flags.end(), flag) != func->flags.end();
|
||||
return std::find(func->flags.begin(), func->flags.end(), flag) !=
|
||||
func->flags.end();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -47,13 +47,13 @@ __attribute__((constructor)) void init() {
|
||||
}
|
||||
|
||||
static void sigHandler(const int sig) {
|
||||
if (sig == SIGINT) println("\n%sInterrupted.%s", YELLOW, STYLE_RESET);
|
||||
if (sig == SIGINT) println("\n%sInterrupted.%s", YELLOW, STYLE_RESET);
|
||||
if (sig == SIGABRT) println("\n%sAborted.%s", RED, STYLE_RESET);
|
||||
exit(sig);
|
||||
}
|
||||
|
||||
static int write(void *cookie, const char *buf, const int size) {
|
||||
auto *real = static_cast<FILE*>(cookie);
|
||||
auto *real = static_cast<FILE *>(cookie);
|
||||
if (!VARS.quietProcess) {
|
||||
const int ret = fwrite(buf, 1, static_cast<size_t>(size), real);
|
||||
fflush(real);
|
||||
@@ -163,9 +163,8 @@ int Main(int argc, char **argv) {
|
||||
|
||||
if (!Helper::hasSuperUser() && !FuncManager.hasFlagOnUsedFunction(NO_SU)) {
|
||||
if (!(FuncManager.hasFlagOnUsedFunction(ADB_SUFFICIENT) &&
|
||||
Helper::hasAdbPermissions())) {
|
||||
throw Error(
|
||||
"This function is requires super-user privileges!");
|
||||
Helper::hasAdbPermissions())) {
|
||||
throw Error("This function is requires super-user privileges!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ Copyright 2025 Yağız Zengin
|
||||
|
||||
namespace PartitionManager {
|
||||
INIT {
|
||||
LOGN(CFUN, INFO) << "Initializing variables of clean log function." << std::endl;
|
||||
LOGN(CFUN, INFO) << "Initializing variables of clean log function."
|
||||
<< std::endl;
|
||||
flags = {FunctionFlags::NO_MAP_CHECK, FunctionFlags::NO_SU};
|
||||
cmd = _app.add_subcommand("clean-logs", "Clean PMT logs.");
|
||||
return true;
|
||||
|
||||
@@ -42,17 +42,12 @@ INIT {
|
||||
"Print info(s) as JSON body. The body of each partition will "
|
||||
"be written separately")
|
||||
->default_val(false);
|
||||
cmd->add_flag("--as-byte", asByte,
|
||||
"View sizes as byte.")
|
||||
->default_val(true);
|
||||
cmd->add_flag("--as-kilobyte", asKiloBytes,
|
||||
"View sizes as kilobyte.")
|
||||
cmd->add_flag("--as-byte", asByte, "View sizes as byte.")->default_val(true);
|
||||
cmd->add_flag("--as-kilobyte", asKiloBytes, "View sizes as kilobyte.")
|
||||
->default_val(false);
|
||||
cmd->add_flag("--as-megabyte", asMega,
|
||||
"View sizes as megabyte.")
|
||||
cmd->add_flag("--as-megabyte", asMega, "View sizes as megabyte.")
|
||||
->default_val(false);
|
||||
cmd->add_flag("--as-gigabyte", asGiga,
|
||||
"View sizes as gigabyte.")
|
||||
cmd->add_flag("--as-gigabyte", asGiga, "View sizes as gigabyte.")
|
||||
->default_val(false);
|
||||
cmd->add_option("--json-partition-name", jNamePartition,
|
||||
"Specify partition name element for JSON body")
|
||||
@@ -90,10 +85,13 @@ RUN {
|
||||
}
|
||||
|
||||
if (jsonFormat)
|
||||
jParts.push_back({partition, {std::stoull(Helper::convertTo(props.size, multiple)), props.isLogical}});
|
||||
jParts.push_back({partition,
|
||||
{std::stoull(Helper::convertTo(props.size, multiple)),
|
||||
props.isLogical}});
|
||||
else
|
||||
println("partition=%s size=%s isLogical=%s",
|
||||
partition.data(), Helper::convertTo(props.size, multiple).data(), props.isLogical ? "true" : "false");
|
||||
println("partition=%s size=%s isLogical=%s", partition.data(),
|
||||
Helper::convertTo(props.size, multiple).data(),
|
||||
props.isLogical ? "true" : "false");
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user