Mercurial > repos > IBBoard.WarFoundry.API
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 wrap: on
line diff
--- a/API/Factories/AbstractNativeWarFoundryFactory.cs Wed Aug 31 13:57:27 2011 +0100 +++ b/API/Factories/AbstractNativeWarFoundryFactory.cs Sun Sep 04 20:43:44 2011 +0100 @@ -29,22 +29,25 @@ } protected override ZipFile GetFileAsSupportedType (FileInfo file) - { - ZipFile zip = null; - - try - { - zip = new ZipFile(file.FullName); + { + ZipFile zip = null; + string ext = file.Extension; + + if (ext == "race" || ext == "army" || ext == "system") + { + try + { + zip = new ZipFile(file.FullName); + } + catch (ZipException) + { + //Silently dispose as per spec for the method + } + catch (IOException) + { + //Silently dispose as per spec for the method + } } - catch(ZipException) - { - //Silently dispose as per spec for the method - } - catch (IOException) - { - //Silently dispose as per spec for the method - } - return zip; }