Skip to content

Commit

Permalink
Rework GenerateResourceCaseMap
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Jan 9, 2025
1 parent 4e471d0 commit 907cc17
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions src/Xamarin.Android.Build.Tasks/Tasks/GenerateResourceCaseMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,27 @@ public override bool RunTask ()
}
using (var file = File.OpenRead (aar)) {
using var zip = ZipArchive.Open (file);
foreach (var entry in zip) {
if (entry.IsDirectory)
continue;
if (entry.FullName != resmap)
continue;
Log.LogDebugMessage ($"Found: {entry.FullName}");
var ms = MemoryStreamPool.Shared.Rent ();
try {
entry.Extract (ms);
ms.Position = 0;
using var reader = new StreamReader (ms);
string line;
// Read each line until the end of the file
while ((line = reader.ReadLine()) != null) {
if (string.IsNullOrEmpty (line))
continue;
string [] tok = line.Split (';');
AddRename (tok [1].Replace ('/', Path.DirectorySeparatorChar), tok [0].Replace ('/', Path.DirectorySeparatorChar));
}
} finally {
MemoryStreamPool.Shared.Return (ms);
ZipEntry entry = zip.ReadEntry (resmap);
if (entry == null) {
Log.LogDebugMessage ($"Skipping non-existent file: {resmap}");
continue;
}
Log.LogDebugMessage ($"Found: {entry.FullName}");
var ms = MemoryStreamPool.Shared.Rent ();
try {
entry.Extract (ms);
ms.Position = 0;
using var reader = new StreamReader (ms);
string line;
// Read each line until the end of the file
while ((line = reader.ReadLine()) != null) {
if (string.IsNullOrEmpty (line))
continue;
string [] tok = line.Split (';');
AddRename (tok [1].Replace ('/', Path.DirectorySeparatorChar), tok [0].Replace ('/', Path.DirectorySeparatorChar));
}
// no need to read the rest of the files we found the one we want
break;
} finally {
MemoryStreamPool.Shared.Return (ms);
}
}
}
Expand Down

0 comments on commit 907cc17

Please sign in to comment.