pmt: CLeanup unnecessary function: real-link-path

- real-link-path function is removed.
 - Added --real-link-path flag to real-path function for as real-link-path.
This commit is contained in:
2025-08-15 11:52:03 +03:00
parent c3acd4b370
commit 1bc3b5ccef
6 changed files with 14 additions and 89 deletions

View File

@@ -158,20 +158,16 @@ Show the **absolute block device path** for each partition. General syntax:
pmt real-path partition(s) [OPTIONS]
```
**Options:**
- `--real-link-path` → Tells real link path.
**Example usages:**\
`pmt real-path boot` - Example output: `/dev/block/sda25`
`pmt real-path boot` - Example output: `/dev/block/sda25`\
`pmt real-path boot --real-link-path` - Example output: `/dev/block/by-name/boot`
---
### 7. `real-linkpath`
Show the **symbolic link path** for each partition (e.g., `/dev/block/by-name/boot`). General syntax:
```bash
pmt real-link-path partition(s) [OPTIONS]
```
---
### 8. `type`
### 7. `type`
Check magic numbers to determine file system or other types of partition(s) or image(s). General syntax:
```bash
pmt type partition(s) [OPTIONS]
@@ -188,7 +184,7 @@ pmt type partition(s) [OPTIONS]
---
### 9. `reboot`
### 8. `reboot`
Reboot the device. Default reboot target is normal. If you are using it via ADB terminal, you **DO NOT** need root to use this feature. General syntax:
```bash
pmt reboot [rebootTarget] [OPTIONS]
@@ -201,7 +197,7 @@ pmt reboot [rebootTarget] [OPTIONS]
---
### 10. `memtest`
### 9. `memtest`
Test your sequential (random tests is soon) read/write speed of your memory.
```bash
pmt memtest [testPath]

View File

@@ -25,7 +25,6 @@ set(PMT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/functions/MemoryTestFunction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/functions/PartitionSizeFunction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/functions/RealPathFunction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/functions/RealLinkPathFunction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/functions/RebootFunction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/functions/TypeFunction.cpp
)

View File

@@ -96,8 +96,6 @@ int Main(int argc, char **argv) {
AppMain);
FuncManager.registerFunction(std::make_unique<infoFunction>(), AppMain);
FuncManager.registerFunction(std::make_unique<realPathFunction>(), AppMain);
FuncManager.registerFunction(std::make_unique<realLinkPathFunction>(),
AppMain);
FuncManager.registerFunction(std::make_unique<typeFunction>(), AppMain);
FuncManager.registerFunction(std::make_unique<rebootFunction>(), AppMain);
FuncManager.registerFunction(std::make_unique<memoryTestFunction>(),

View File

@@ -1,59 +0,0 @@
/*
Copyright 2025 Yağız Zengin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "functions.hpp"
#include <PartitionManager/PartitionManager.hpp>
#define RLPFUN "realPathFunction"
namespace PartitionManager {
bool realLinkPathFunction::init(CLI::App &_app) {
LOGN(RLPFUN, INFO) << "Initializing variables of real link path function."
<< std::endl;
cmd = _app.add_subcommand("real-linkpath",
"Tell real link paths of partition(s)");
cmd->add_option("partition(s)", partitions, "Partition name(s)")
->required()
->delimiter(',');
return true;
}
bool realLinkPathFunction::run() {
for (const auto &partition : partitions) {
if (!Variables->PartMap->hasPartition(partition))
throw Error("Couldn't find partition: %s", partition.data());
if (Variables->onLogical && !Variables->PartMap->isLogical(partition)) {
if (Variables->forceProcess)
LOGN(RLPFUN, WARNING)
<< "Partition " << partition
<< " is exists but not logical. Ignoring (from --force, -f)."
<< std::endl;
else
throw Error("Used --logical (-l) flag but is not logical partition: %s",
partition.data());
}
println("%s", Variables->PartMap->getRealPathOf(partition).data());
}
return true;
}
bool realLinkPathFunction::isUsed() const { return cmd->parsed(); }
const char *realLinkPathFunction::name() const { return RLPFUN; }
} // namespace PartitionManager

View File

@@ -27,6 +27,7 @@ bool realPathFunction::init(CLI::App &_app) {
cmd->add_option("partition(s)", partitions, "Partition name(s)")
->required()
->delimiter(',');
cmd->add_flag("--real-link-path", realLinkPath, "Print real link path(s)")->default_val(false);
return true;
}
@@ -46,6 +47,9 @@ bool realPathFunction::run() {
partition.data());
}
if (realLinkPath)
println("%s", Variables->PartMap->getRealLinkPathOf(partition).data());
else
println("%s", Variables->PartMap->getRealPathOf(partition).data());
}

View File

@@ -117,20 +117,7 @@ public:
class realPathFunction final : public FunctionBase {
private:
std::vector<std::string> partitions;
public:
CLI::App *cmd = nullptr;
bool init(CLI::App &_app) override;
bool run() override;
[[nodiscard]] bool isUsed() const override;
[[nodiscard]] const char *name() const override;
};
class realLinkPathFunction final : public FunctionBase {
private:
std::vector<std::string> partitions;
bool realLinkPath = false;
public:
CLI::App *cmd = nullptr;