Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Factories/AbstractNativeWarFoundryFactory.cs @ 199:70ba3bee0c2e
Fixes #207: WarFoundry still keeps file handles on failure
* Move close of zip file into a "finally" block
* Remove unnecessary extra Close()
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 02 Nov 2009 20:58:01 +0000 |
parents | 1d13820b3d96 |
children | 3e287b6b5244 |
line wrap: on
line diff
--- a/api/Factories/AbstractNativeWarFoundryFactory.cs Sat Oct 31 20:55:19 2009 +0000 +++ b/api/Factories/AbstractNativeWarFoundryFactory.cs Mon Nov 02 20:58:01 2009 +0000 @@ -82,19 +82,26 @@ { ICollection<IWarFoundryObject> objects = null; string comment = file.ZipFileComment; - IWarFoundryObject obj = null; - - if (comment.StartsWith(SYSTEM_ZIP_IDENTIFIER)) - { - obj = CreateGameSystemFromFile(file); - } - else if (comment.StartsWith(RACE_ZIP_IDENTIFIER)) - { - obj = CreateRaceFromFile(file); - } - else if (comment.StartsWith(ARMY_ZIP_IDENTIFIER)) - { - obj = CreateArmyFromFile(file); + IWarFoundryObject obj = null; + + try + { + if (comment.StartsWith(SYSTEM_ZIP_IDENTIFIER)) + { + obj = CreateGameSystemFromFile(file); + } + else if (comment.StartsWith(RACE_ZIP_IDENTIFIER)) + { + obj = CreateRaceFromFile(file); + } + else if (comment.StartsWith(ARMY_ZIP_IDENTIFIER)) + { + obj = CreateArmyFromFile(file); + } + } + finally + { + file.Close(); } if (obj!=null) @@ -102,8 +109,6 @@ objects = new List<IWarFoundryObject>(); objects.Add(obj); } - - file.Close(); return objects; }