From 428999fc0b2171a711c039685b4cf79248846704 Mon Sep 17 00:00:00 2001 From: Matthew Bowra-Dean Date: Thu, 30 Dec 2010 02:21:39 +1300 Subject: [PATCH] Create an empty zip file if it doesn't exist. --- OpenRA.FileFormats/Filesystem/ZipFile.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/OpenRA.FileFormats/Filesystem/ZipFile.cs b/OpenRA.FileFormats/Filesystem/ZipFile.cs index f4d68a9a08..d4c13938ad 100644 --- a/OpenRA.FileFormats/Filesystem/ZipFile.cs +++ b/OpenRA.FileFormats/Filesystem/ZipFile.cs @@ -8,12 +8,10 @@ */ #endregion -using System; using System.Collections.Generic; using System.IO; using ICSharpCode.SharpZipLib.Zip; using SZipFile = ICSharpCode.SharpZipLib.Zip.ZipFile; -using System.Linq; namespace OpenRA.FileFormats { @@ -25,7 +23,19 @@ namespace OpenRA.FileFormats public ZipFile(string filename, int priority) { this.priority = priority; - pkg = new SZipFile(File.OpenRead(filename)); + if (File.Exists(filename)) + { + try + { + pkg = new SZipFile(File.OpenRead(filename)); + } + catch (ZipException e) + { + Log.Write("debug", "Couldn't load zip file: {0}", e.Message); + } + } + else + pkg = SZipFile.Create(filename); } public Stream GetContent(string filename)