Make our IFolder zip support actually work.
This commit is contained in:
2
Makefile
2
Makefile
@@ -16,7 +16,7 @@ COMMON_LIBS = System.dll System.Core.dll System.Drawing.dll System.Xml.dll
|
|||||||
fileformats_SRCS = $(shell find OpenRA.FileFormats/ -iname '*.cs')
|
fileformats_SRCS = $(shell find OpenRA.FileFormats/ -iname '*.cs')
|
||||||
fileformats_TARGET = OpenRA.FileFormats.dll
|
fileformats_TARGET = OpenRA.FileFormats.dll
|
||||||
fileformats_KIND = library
|
fileformats_KIND = library
|
||||||
fileformats_LIBS = $(COMMON_LIBS) thirdparty/Tao/Tao.Sdl.dll System.Windows.Forms.dll thirdparty/WindowsBase.dll
|
fileformats_LIBS = $(COMMON_LIBS) thirdparty/Tao/Tao.Sdl.dll System.Windows.Forms.dll thirdparty/ICSharpCode.SharpZipLib.dll
|
||||||
|
|
||||||
rcg_SRCS = $(shell find OpenRA.Renderer.Cg/ -iname '*.cs')
|
rcg_SRCS = $(shell find OpenRA.Renderer.Cg/ -iname '*.cs')
|
||||||
rcg_TARGET = OpenRA.Renderer.Cg.dll
|
rcg_TARGET = OpenRA.Renderer.Cg.dll
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRA.FileFormats
|
|||||||
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
||||||
return new MixFile(filename, order++);
|
return new MixFile(filename, order++);
|
||||||
else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
|
else if (filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
|
||||||
return new CompressedPackage(filename, order++);
|
return new ZipFile(filename, order++);
|
||||||
else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase))
|
else if (filename.EndsWith(".Z", StringComparison.InvariantCultureIgnoreCase))
|
||||||
return new InstallShieldPackage(filename, order++);
|
return new InstallShieldPackage(filename, order++);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -11,40 +11,39 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Packaging;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
using SZipFile = ICSharpCode.SharpZipLib.Zip.ZipFile;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace OpenRA.FileFormats
|
namespace OpenRA.FileFormats
|
||||||
{
|
{
|
||||||
public class CompressedPackage : IFolder
|
public class ZipFile : IFolder
|
||||||
{
|
{
|
||||||
readonly uint[] hashes;
|
readonly SZipFile pkg;
|
||||||
readonly Stream s;
|
|
||||||
readonly ZipPackage pkg;
|
|
||||||
int priority;
|
int priority;
|
||||||
|
|
||||||
public CompressedPackage(string filename, int priority)
|
public ZipFile(string filename, int priority)
|
||||||
{
|
{
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
s = FileSystem.Open(filename);
|
pkg = new SZipFile(File.OpenRead(filename));
|
||||||
pkg = (ZipPackage)ZipPackage.Open(s, FileMode.Open);
|
|
||||||
hashes = pkg.GetParts()
|
|
||||||
.Select(p => PackageEntry.HashFilename(p.Uri.LocalPath)).ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream GetContent(string filename)
|
public Stream GetContent(string filename)
|
||||||
{
|
{
|
||||||
return pkg.GetPart(new Uri(filename)).GetStream(FileMode.Open);
|
return pkg.GetInputStream(pkg.GetEntry(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<uint> AllFileHashes() { return hashes; }
|
public IEnumerable<uint> AllFileHashes()
|
||||||
|
{
|
||||||
|
foreach(ZipEntry entry in pkg)
|
||||||
|
yield return PackageEntry.HashFilename(entry.Name);
|
||||||
|
}
|
||||||
|
|
||||||
public bool Exists(string filename)
|
public bool Exists(string filename)
|
||||||
{
|
{
|
||||||
return hashes.Contains(PackageEntry.HashFilename(filename));
|
return pkg.GetEntry(filename) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int Priority
|
public int Priority
|
||||||
{
|
{
|
||||||
get { return 500 + priority; }
|
get { return 500 + priority; }
|
||||||
@@ -54,6 +54,10 @@
|
|||||||
<Reference Include="WindowsBase">
|
<Reference Include="WindowsBase">
|
||||||
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\thirdparty\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Evaluator.cs" />
|
<Compile Include="Evaluator.cs" />
|
||||||
@@ -102,9 +106,9 @@
|
|||||||
<Compile Include="Filesystem\FileSystem.cs" />
|
<Compile Include="Filesystem\FileSystem.cs" />
|
||||||
<Compile Include="Filesystem\Folder.cs" />
|
<Compile Include="Filesystem\Folder.cs" />
|
||||||
<Compile Include="Filesystem\PackageWriter.cs" />
|
<Compile Include="Filesystem\PackageWriter.cs" />
|
||||||
<Compile Include="Filesystem\CompressedPackage.cs" />
|
|
||||||
<Compile Include="Filesystem\InstallShieldPackage.cs" />
|
<Compile Include="Filesystem\InstallShieldPackage.cs" />
|
||||||
<Compile Include="FileFormats\Blast.cs" />
|
<Compile Include="FileFormats\Blast.cs" />
|
||||||
|
<Compile Include="Filesystem\ZipFile.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
|||||||
@@ -17,9 +17,8 @@ fi
|
|||||||
cp -rv template.app OpenRA.app
|
cp -rv template.app OpenRA.app
|
||||||
cp -rv $2/* "OpenRA.app/Contents/Resources/" || exit 3
|
cp -rv $2/* "OpenRA.app/Contents/Resources/" || exit 3
|
||||||
|
|
||||||
# Remove the tao and WindowsBase dlls (they are shipped in the deps package)
|
# Remove the tao dlls (they are shipped in the deps package)
|
||||||
rm OpenRA.app/Contents/Resources/Tao.*
|
rm OpenRA.app/Contents/Resources/Tao.*
|
||||||
rm OpenRA.app/Contents/Resources/WindowsBase.dll
|
|
||||||
|
|
||||||
# Icon isn't used, and editor doesn't work under mono 2.8
|
# Icon isn't used, and editor doesn't work under mono 2.8
|
||||||
rm OpenRA.app/Contents/Resources/OpenRA.ico
|
rm OpenRA.app/Contents/Resources/OpenRA.ico
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ done
|
|||||||
# Copy Tao
|
# Copy Tao
|
||||||
cp thirdparty/Tao/* packaging/built
|
cp thirdparty/Tao/* packaging/built
|
||||||
|
|
||||||
# Copy WindowsBase.dll for linux packages
|
|
||||||
cp thirdparty/WindowsBase.dll packaging/built
|
|
||||||
|
|
||||||
# SharpZipLib for zip file support
|
# SharpZipLib for zip file support
|
||||||
cp thirdparty/ICSharpCode.SharpZipLib.dll packaging/built
|
cp thirdparty/ICSharpCode.SharpZipLib.dll packaging/built
|
||||||
|
|
||||||
|
|||||||
BIN
thirdparty/WindowsBase.dll
vendored
BIN
thirdparty/WindowsBase.dll
vendored
Binary file not shown.
Reference in New Issue
Block a user