Skip to content

Commit

Permalink
CAB Extractor: removed dependency to DotNetZip
Browse files Browse the repository at this point in the history
  • Loading branch information
DSUK committed May 20, 2015
1 parent 17c8eab commit 356a4fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
CSC = dmcs
CSFLAGS = -nologo -warn:4 -debug:full -optimize- -codepage:utf8 -unsafe -warnaserror
DEFINE = DEBUG;TRACE
COMMON_LIBS = System.dll System.Core.dll System.Data.dll System.Data.DataSetExtensions.dll System.Drawing.dll System.Xml.dll thirdparty/download/ICSharpCode.SharpZipLib.dll thirdparty/download/FuzzyLogicLibrary.dll thirdparty/download/Mono.Nat.dll thirdparty/download/MaxMind.Db.dll thirdparty/download/MaxMind.GeoIP2.dll thirdparty/download/Eluant.dll thirdparty/download/Ionic.Zip.dll
COMMON_LIBS = System.dll System.Core.dll System.Data.dll System.Data.DataSetExtensions.dll System.Drawing.dll System.Xml.dll thirdparty/download/ICSharpCode.SharpZipLib.dll thirdparty/download/FuzzyLogicLibrary.dll thirdparty/download/Mono.Nat.dll thirdparty/download/MaxMind.Db.dll thirdparty/download/MaxMind.GeoIP2.dll thirdparty/download/Eluant.dll



Expand Down
24 changes: 15 additions & 9 deletions OpenRA.Game/FileSystem/InstallShieldCABExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using OpenRA.FileFormats;
namespace OpenRA.FileSystem
{
Expand Down Expand Up @@ -255,22 +256,28 @@ public void ExtractFile(uint index, string fileName)
var reader = new BinaryReader(fil);
if (reader.ReadUInt32() != 0x28635349)
throw new InvalidDataException("Not an Installshield CAB package");
new CommonHeader(reader);
new VolumeHeader(reader);
reader.BaseStream.Seek(fd.DataOffset, SeekOrigin.Begin);
var writer = new BinaryWriter(File.Open(fileName, FileMode.Create));
var destfile = File.Open(fileName, FileMode.Create);
var writer = new BinaryWriter(destfile);
if ((fd.Flags & FILECOMPRESSED) != 0) {
uint bytes_to_read = fd.CompressedSize;
ushort bytes_to_extract;
byte[] read_buffer;
byte[] write_buffer;
const int BUFFER_SIZE = 65536;
var write_buffer = new byte[BUFFER_SIZE];
int extracted_bytes;
var inf = new ICSharpCode.SharpZipLib.Zip.Compression.Inflater(true);
while (bytes_to_read > 0) {
long p = reader.BaseStream.Position;
bytes_to_extract = reader.ReadUInt16();
read_buffer = reader.ReadBytes(bytes_to_extract);
write_buffer = Ionic.Zlib.DeflateStream.UncompressBuffer(read_buffer);
writer.Write(write_buffer);
inf.SetInput(read_buffer);
extracted_bytes = inf.Inflate(write_buffer);
if (extracted_bytes > BUFFER_SIZE)
throw new Exception("needs a bigger buffer");
writer.Write(write_buffer, 0, extracted_bytes);
bytes_to_read -= (uint)bytes_to_extract + 2;

inf.Reset();
}

writer.Dispose();
Expand All @@ -280,8 +287,7 @@ public void ExtractFile(uint index, string fileName)
}
}

public void Dispose()
{
public void Dispose() {
s.Dispose();
}
}
Expand Down
13 changes: 0 additions & 13 deletions thirdparty/fetch-thirdparty-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ if [ ! -f FuzzyLogicLibrary.dll ]; then
cp ./FuzzyLogicLibrary/bin/Release/FuzzyLogicLibrary.dll .
rm -rf FuzzyLogicLibrary
fi
if [ ! -f Ionic.Zip.dll ]; then
echo "Fetching DotNetZip from NuGet."
nuget install DotNetZip -Version 1.9.3 -ExcludeVersion
cp ./DotNetZip/lib/net20/Ionic.Zip.dll .
rm -rf DotNetZip
fi

if [ ! -f Ionic.Zip.dll ]; then
echo "Fetching DotNetZip from NuGet."
nuget install DotNetZip -Version 1.9.3
mv ./DotNetZip.1.9.3/lib/net20/Ionic.Zip.dll .
rm -rf DotNetZip.1.9.3
fi

if [ ! -f SDL2-CS.dll ]; then
echo "Fetching SDL2-CS from GitHub."
Expand Down

0 comments on commit 356a4fb

Please sign in to comment.