Skip to content

Commit 5aa33b4

Browse files
committed
修复直接传入反编译目录时会导致目录内容被覆盖的问题
1 parent 7f0d4f5 commit 5aa33b4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

shell/reverse-tools/apktool/DecompileApk.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ waitUserInputParameter() {
3535
read -r apkDecompileDirPath
3636
apkDecompileDirPath=$(parseComputerFilePath "${apkDecompileDirPath}")
3737

38+
decompileDirNameSuffix="-decompile-$(date "+%Y%m%d%H%M%S")"
3839
if [[ -z "${apkDecompileDirPath}" ]]; then
39-
apkDecompileDirPath="${sourceApkFilePath%.*}-decompile-$(date "+%Y%m%d%H%M%S")"
40+
apkDecompileDirPath="${sourceApkFilePath%.*}${decompileDirNameSuffix}"
41+
else
42+
apkDecompileDirPath="${apkDecompileDirPath}$(getFileSeparator)$(basename "${sourceApkFilePath%.*}")${decompileDirNameSuffix}"
4043
fi
4144

4245
local apktoolJarFileName="apktool-2.12.1.jar"
@@ -97,7 +100,6 @@ decompileApk() {
97100
exit 1
98101
fi
99102

100-
# 核心逻辑:目录不存在或者目录为空
101103
if [[ ! -d "${apkDecompileDirPath}" || -z "$(ls -A "${apkDecompileDirPath}")" ]]; then
102104
echo "❌ 反编译失败,请检查 apktool 输出的信息:"
103105
echo "${outputPrint}"

0 commit comments

Comments
 (0)