Skip to content

Commit

Permalink
Only delete created dir
Browse files Browse the repository at this point in the history
  • Loading branch information
uholeschak committed Dec 18, 2024
1 parent f4a0422 commit b47e3d1
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions Tools/ApkUncompress/main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,15 @@ static int Main(string[] args)
continue;
}

string prefix = $"uncompressed-{Path.GetFileNameWithoutExtension(file)}";
string outputDir = Path.Combine(outputPath, prefix);
if (Directory.Exists(outputDir))
{
Directory.Delete(outputDir, true);
}

string prefixDll = "uncompressed-";
string outputDirDll = Path.Combine(outputPath, prefixDll);
if (Directory.Exists(outputDirDll))
{
Directory.Delete(outputDirDll, true);
}

if (string.Compare(".dll", ext, StringComparison.OrdinalIgnoreCase) == 0)
{
string prefixDll = "uncompressed-";
string outputDirDll = Path.Combine(outputPath, prefixDll);
if (Directory.Exists(outputDirDll))
{
Directory.Delete(outputDirDll, true);
}

if (!apkUncompress.UncompressDLL(file, prefixDll, outputPath))
{
Console.WriteLine("Uncompress failed: {0}", file);
Expand All @@ -65,21 +58,27 @@ static int Main(string[] args)
continue;
}

string? assembliesPath = null;
if (string.Compare(".apk", ext, StringComparison.OrdinalIgnoreCase) == 0)
{
if (!apkUncompress.UncompressFromAPK(file, ApkUncompressCommon.AssembliesPathApk, prefix, outputPath))
{
Console.WriteLine("Uncompress failed: {0}", file);
haveErrors = true;
}

Console.WriteLine("Uncompressed: {0}", file);
continue;
assembliesPath = ApkUncompressCommon.AssembliesPathApk;
}

if (string.Compare(".aab", ext, StringComparison.OrdinalIgnoreCase) == 0)
{
if (!apkUncompress.UncompressFromAPK(file, ApkUncompressCommon.AssembliesPathAab, prefix, outputPath))
assembliesPath = ApkUncompressCommon.AssembliesPathAab;
}

if (!string.IsNullOrEmpty(assembliesPath))
{
string prefix = $"uncompressed-{Path.GetFileNameWithoutExtension(file)}";
string outputDir = Path.Combine(outputPath, prefix);
if (Directory.Exists(outputDir))
{
Directory.Delete(outputDir, true);
}

if (!apkUncompress.UncompressFromAPK(file, assembliesPath, prefix, outputPath))
{
Console.WriteLine("Uncompress failed: {0}", file);
haveErrors = true;
Expand Down

0 comments on commit b47e3d1

Please sign in to comment.