remove some crap code in Util

This commit is contained in:
Chris Forbes
2011-04-09 12:14:23 +12:00
parent b633802ec2
commit fddfdd5073

View File

@@ -42,18 +42,26 @@ namespace OpenRA.Utility
}
}
static IEnumerable<ZipEntry> GetEntries(this ZipInputStream z)
{
for (; ; )
{
var e = z.GetNextEntry();
if (e != null) yield return e; else break;
}
}
public static void ExtractZip(this ZipInputStream z, string destPath, List<string> extracted)
{
ZipEntry entry;
while ((entry = z.GetNextEntry()) != null)
foreach (var entry in z.GetEntries())
{
if (!entry.IsFile) continue;
Console.WriteLine("Status: Extracting {0}", entry.Name);
if (!Directory.Exists(Path.Combine(destPath, Path.GetDirectoryName(entry.Name))))
Directory.CreateDirectory(Path.Combine(destPath, Path.GetDirectoryName(entry.Name)));
var path = destPath + Path.DirectorySeparatorChar + entry.Name;
var path = Path.Combine(destPath, entry.Name);
extracted.Add(path);
using (var f = File.Create(path))
{
int bufSize = 2048;
@@ -62,6 +70,7 @@ namespace OpenRA.Utility
f.Write(buf, 0, bufSize);
}
}
z.Close();
}