changeset 416:c70973b65090

Fixes #94: Loading files is too slow * Check file extensions to cut down on false-positive file loads. NOTE: This solution isn't ideal, but SharpZipLib has a FIXME in that their scan will be slow on non-zips.
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Sep 2011 20:43:44 +0100
parents 131fb56da842
children 2a36ebb7b6a9
files API/Factories/AbstractNativeWarFoundryFactory.cs
diffstat 1 files changed, 18 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/API/Factories/AbstractNativeWarFoundryFactory.cs	Wed Aug 31 13:57:27 2011 +0100
     1.2 +++ b/API/Factories/AbstractNativeWarFoundryFactory.cs	Sun Sep 04 20:43:44 2011 +0100
     1.3 @@ -29,22 +29,25 @@
     1.4  		}
     1.5  				
     1.6  		protected override ZipFile GetFileAsSupportedType (FileInfo file)
     1.7 -		{
     1.8 -			ZipFile zip = null;
     1.9 -			
    1.10 -			try
    1.11 -			{
    1.12 -				zip = new ZipFile(file.FullName);
    1.13 +		{
    1.14 +			ZipFile zip = null;
    1.15 +			string ext = file.Extension;
    1.16 +
    1.17 +			if (ext == "race" || ext == "army" || ext == "system")
    1.18 +			{
    1.19 +				try
    1.20 +				{
    1.21 +					zip = new ZipFile(file.FullName);
    1.22 +				}
    1.23 +				catch (ZipException)
    1.24 +				{
    1.25 +					//Silently dispose as per spec for the method
    1.26 +				}
    1.27 +				catch (IOException)
    1.28 +				{
    1.29 +					//Silently dispose as per spec for the method
    1.30 +				}
    1.31  			}
    1.32 -			catch(ZipException)
    1.33 -			{
    1.34 -				//Silently dispose as per spec for the method
    1.35 -			}
    1.36 -			catch (IOException)
    1.37 -			{
    1.38 -				//Silently dispose as per spec for the method
    1.39 -			}
    1.40 -			
    1.41  			return zip;
    1.42  		}
    1.43