diff --git a/OpenRA.FileFormats/CompressedPackage.cs b/OpenRA.FileFormats/CompressedPackage.cs new file mode 100644 index 0000000000..6bba49fa2d --- /dev/null +++ b/OpenRA.FileFormats/CompressedPackage.cs @@ -0,0 +1,40 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see LICENSE. + */ +#endregion + +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.Packaging; +using System.Linq; + +namespace OpenRA.FileFormats +{ + public class CompressedPackage : IFolder + { + readonly uint[] hashes; + readonly Stream s; + readonly ZipPackage pkg; + + public CompressedPackage(string filename) + { + s = FileSystem.Open(filename); + pkg = (ZipPackage)ZipPackage.Open(s, FileMode.Open); + hashes = pkg.GetParts() + .Select(p => PackageEntry.HashFilename(p.Uri.LocalPath)).ToArray(); + } + + public Stream GetContent(string filename) + { + return pkg.GetPart(new Uri(filename)).GetStream(FileMode.Open); + } + + public IEnumerable AllFileHashes() { return hashes; } + } +} diff --git a/OpenRA.FileFormats/OpenRA.FileFormats.csproj b/OpenRA.FileFormats/OpenRA.FileFormats.csproj index e0b6750b12..552a3bf5fb 100644 --- a/OpenRA.FileFormats/OpenRA.FileFormats.csproj +++ b/OpenRA.FileFormats/OpenRA.FileFormats.csproj @@ -50,6 +50,9 @@ False ..\thirdparty\Tao\Tao.Sdl.dll + + 3.0 + @@ -69,8 +72,6 @@ - - @@ -99,6 +100,7 @@ +