pmt: fix std::filesystem exceptions

This commit is contained in:
2025-08-11 12:29:21 +03:00
parent 295e890324
commit b76b79ba07
4 changed files with 148 additions and 3 deletions

View File

@@ -30,3 +30,4 @@ Detailed usage instructions and option references can be found in the [USAGE.md]
## Credits ## Credits
- [CLI11: Command line parser for C++11](https://github.com/CLIUtils/CLI11) - [CLI11: Command line parser for C++11](https://github.com/CLIUtils/CLI11)
- [PicoSHA2: A header-file-only, SHA256 hash generator in C++](https://github.com/okdshin/PicoSHA2)

21
include/LICENSE.picosha2 Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 okdshin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

121
manager.sh Normal file
View File

@@ -0,0 +1,121 @@
#!/data/data/com.termux/files/usr/bin/env bash
#
# 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.
#
THIS="$(basename $0)"
RELEASE="20250810"
echo() { command echo "[$THIS]: $@"; }
checks()
{
if ! curl "https://github.com" &>/dev/null; then
echo "No internet connection!"
exit 1
fi
echo "Updating repositories and checking required packages..."
pkg update &>/dev/null
[ ! -f $PREFIX/bin/unzip ] && pkg install -y unzip
[ ! -f $PREFIX/bin/wget ] && pkg install -y wget
}
select_variant()
{
LINK=""; ARCH=""; VARIANT=""
if getprop ro.product.cpu.abi | grep "arm64-v8a" &>/dev/null; then ARCH="arm64-v8a";
else ARCH="armeabi-v7a"
fi
[ $1 == "static" ] && VARIANT="static-"
LINK="https://github.com/ShawkTeam/pmt-renovated/releases/download/${RELEASE}/pmt-${VARIANT}${ARCH}.zip"
}
download()
{
mkdir -p $PREFIX/tmp
echo "Downloading pmt-${VARIANT}${ARCH}.zip (${RELEASE})"
if ! wget -o $PREFIX/tmp/pmt.zip "${LINK}" &>/dev/null; then
echo "Download failed! LINK=${LINK}"
rm $PREFIX/tmp/*.zip
exit 1
fi
echo "Extracting..."
if ! unzip -d $PREFIX/tmp $PREFIX/tmp/pmt.zip &>/dev/null; then
echo "Extraction failed!"
exit 1
fi
}
setup()
{
[ -f $PREFIX/tmp/pmt_static ]; mv $PREFIX/tmp/pmt_static $PREFIX/tmp/pmt
set -e
install -t $PREFIX/bin $PREFIX/tmp/pmt
if [ -f $PREFIX/tmp/libhelper.so ]; then
install -t $PREFIX/lib $(find $PREFIX/tmp -name "lib*.so")
install -t $PREFIX/lib $(find $PREFIX/tmp -name "lib*.a")
fi
echo "Installed successfully. Try running 'pmt' command."
}
uninstall()
{
rm -f $PREFIX/pmt $PREFIX/lib/libhelper* $PREFIX/libpartition_map* &>/dev/null
}
is_installed()
{
if /system/bin/which pmt &>/dev/null; then
echo "PMT is already installed."
exit 1
fi
}
cleanup()
{
rm -f $PREFIX/tmp/pmt* $PREFIX/tmp/lib* $PREFIX/tmp/*.zip &>/dev/null
}
if [ $# -eq 0 ]; then
command echo "Usage: $0 install|uninstall [--static]"
exit 1
fi
case $1 in
"install")
is_installed
checks
select_variant $([ "$2" == "--static" ] && echo static)
download
setup
;;
"uninstall")
uninstall && echo "Uninstalled successfully."
;;
"reinstall")
uninstall
checks
select_variant $([ "$2" == "--static" ] && echo static)
download
setup
;;
*)
command echo "$0: Unknown argument: $1"
exit 1 ;;
esac

View File

@@ -37,10 +37,12 @@ void variableProtect::setVariablePointer(basic_variables *&_ptr) {
basic_variables::~basic_variables() { delete PartMap; } basic_variables::~basic_variables() { delete PartMap; }
basic_variables::basic_variables() basic_variables::basic_variables()
: PartMap(new PartitionMap::BuildMap()), : logFile("/sdcard/Documents/last_pmt_logs.log"), onLogical(false),
logFile("/sdcard/Documents/last_pmt_logs.log"), onLogical(false),
quietProcess(false), verboseMode(false), viewVersion(false), quietProcess(false), verboseMode(false), viewVersion(false),
forceProcess(false) {} forceProcess(false) {
try { PartMap = new PartitionMap::BuildMap(); }
catch (std::exception&) {}
}
int Main(int argc, char **argv) { int Main(int argc, char **argv) {
try { try {