pmt: reformat code and improve workflow
This commit is contained in:
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@@ -49,6 +49,9 @@ jobs:
|
||||
zip pmt-static-armeabi-v7a.zip pmt_static
|
||||
echo "BUILD_DATE=$(date +%Y%m%d)" >> $GITHUB_ENV
|
||||
echo "BUILD=${{ github.workspace }}/pmt" >> $GITHUB_ENV
|
||||
cd ..
|
||||
echo -e "Read [Wiki - About Release Types](https://github.com/ShawkTeam/pmt-renovated/wiki/About-Release-Types) for getting more information.\n\n### Changes\n" > release.txt
|
||||
git log --since="2025-08-21" --pretty=format:" * %ad | [%s](https://github.com/ShawkTeam/pmt-renovated/commit/%H)" --date=short | sed 's/ -.*//' | grep -v cleanup >> release.txt
|
||||
working-directory: ${{ github.workspace }}
|
||||
|
||||
- name: Upload To GitHub Releases
|
||||
@@ -60,4 +63,4 @@ jobs:
|
||||
${{ env.BUILD }}/build_armeabi-v7a/*.zip
|
||||
name: Partition Manager Tool Release ${{ env.BUILD_DATE }}
|
||||
tag_name: ${{ env.BUILD_DATE }}
|
||||
body: "Read [Wiki - About Release Types](https://github.com/ShawkTeam/pmt-renovated/wiki/About-Release-Types) for getting more information."
|
||||
body_path: ${{ env.BUILD }}/release.txt
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -164,8 +164,7 @@ 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!");
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -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,8 +96,7 @@ private:
|
||||
public:
|
||||
~garbageCollector();
|
||||
|
||||
template <typename T>
|
||||
void delAfterProgress(T *_ptr) {
|
||||
template <typename T> void delAfterProgress(T *_ptr) {
|
||||
_cleaners.push_back([_ptr] { delete[] _ptr; });
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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,13 +226,9 @@ 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 {};
|
||||
|
||||
Reference in New Issue
Block a user