From af1930d123a644a34851c4748c836b902df0e5b3 Mon Sep 17 00:00:00 2001 From: uholeschak Date: Mon, 23 Dec 2024 14:29:52 +0100 Subject: [PATCH] Added progress --- Tools/ApkUncompress2/ApkUncompressCommon.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Tools/ApkUncompress2/ApkUncompressCommon.cs b/Tools/ApkUncompress2/ApkUncompressCommon.cs index 12693e193..0f452e914 100644 --- a/Tools/ApkUncompress2/ApkUncompressCommon.cs +++ b/Tools/ApkUncompress2/ApkUncompressCommon.cs @@ -90,13 +90,27 @@ public bool UncompressDLL(string fileName) return retVal; } - public bool UncompressFromAPK_IndividualElfFiles(ZipFile apk, string filePath, string outputPath) + public bool UncompressFromAPK_IndividualElfFiles(ZipFile apk, string filePath, string outputPath, ProgressDelegate? progressDelegate = null) { bool result = true; int extractedCount = 0; + long entryCount = apk.Count; + long itemIndex = 0; foreach (ZipEntry entry in apk) { + if (progressDelegate != null) + { + if (entryCount > 0) + { + if (!progressDelegate((int) ((itemIndex * 100) / entryCount))) + { + return false; + } + } + } + + itemIndex++; if (!entry.IsFile) { continue; @@ -345,7 +359,7 @@ public bool UncompressFromAPK(string filePath, string outputDir, ProgressDelegat { FileStream fs = File.OpenRead(filePath); zf = new ZipFile(fs); - if (UncompressFromAPK_IndividualElfFiles(zf, filePath, outputDir)) + if (UncompressFromAPK_IndividualElfFiles(zf, filePath, outputDir, progressDelegate)) { return true; }