Skip to content

Commit

Permalink
Using temp memory stream
Browse files Browse the repository at this point in the history
  • Loading branch information
uholeschak committed Dec 20, 2024
1 parent 67a7abb commit 61c137f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Tools/ApkUncompress2/AssemblyStore/AssemblyStoreExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@ public static (IList<AssemblyStoreExplorer>? explorers, string? errorMessage) Op

if (string.Compare(zipEntry.Name, path, StringComparison.OrdinalIgnoreCase) == 0)
{
Stream zipStream = zf.GetInputStream(zipEntry);
ret.Add(new AssemblyStoreExplorer(zipStream, $"{fi.FullName}!{path}"));
MemoryStream memoryStream = new MemoryStream();
byte[] buffer = new byte[4096]; // 4K is optimum
using (Stream zipStream = zf.GetInputStream(zipEntry))
{
StreamUtils.Copy(zipStream, memoryStream, buffer);
}

ret.Add(new AssemblyStoreExplorer(memoryStream, $"{fi.FullName}!{path}"));
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tools/ApkUncompress2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int Main(string[] args)
}

Directory.CreateDirectory(outDir);
using (var fileStream = File.Create(outFile))
using (FileStream fileStream = File.Create(outFile))
{
stream.Seek(0, SeekOrigin.Begin);
stream.CopyTo(fileStream);
Expand Down

0 comments on commit 61c137f

Please sign in to comment.