Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison API/Factories/AbstractNativeWarFoundryFactory.cs @ 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 | 3c4a6403a88c |
children | 2a36ebb7b6a9 |
comparison
equal
deleted
inserted
replaced
415:131fb56da842 | 416:c70973b65090 |
---|---|
29 } | 29 } |
30 | 30 |
31 protected override ZipFile GetFileAsSupportedType (FileInfo file) | 31 protected override ZipFile GetFileAsSupportedType (FileInfo file) |
32 { | 32 { |
33 ZipFile zip = null; | 33 ZipFile zip = null; |
34 | 34 string ext = file.Extension; |
35 try | 35 |
36 if (ext == "race" || ext == "army" || ext == "system") | |
36 { | 37 { |
37 zip = new ZipFile(file.FullName); | 38 try |
39 { | |
40 zip = new ZipFile(file.FullName); | |
41 } | |
42 catch (ZipException) | |
43 { | |
44 //Silently dispose as per spec for the method | |
45 } | |
46 catch (IOException) | |
47 { | |
48 //Silently dispose as per spec for the method | |
49 } | |
38 } | 50 } |
39 catch(ZipException) | |
40 { | |
41 //Silently dispose as per spec for the method | |
42 } | |
43 catch (IOException) | |
44 { | |
45 //Silently dispose as per spec for the method | |
46 } | |
47 | |
48 return zip; | 51 return zip; |
49 } | 52 } |
50 | 53 |
51 protected override bool CheckCanHandleFileFormat (ZipFile file) | 54 protected override bool CheckCanHandleFileFormat (ZipFile file) |
52 { | 55 { |