changeset 319:7187add280ed

Re #324: Add saving of Race and System data to files * Add entries to zip file
author IBBoard <dev@ibboard.co.uk>
date Sat, 05 Mar 2011 15:38:54 +0000
parents 234b902397e6
children 4be289645c4f
files api/Savers/Xml/WarFoundryXmlFileSaver.cs
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/api/Savers/Xml/WarFoundryXmlFileSaver.cs	Sat Mar 05 15:22:07 2011 +0000
     1.2 +++ b/api/Savers/Xml/WarFoundryXmlFileSaver.cs	Sat Mar 05 15:38:54 2011 +0000
     1.3 @@ -14,11 +14,24 @@
     1.4  
     1.5  		public bool Save(string path, params WarFoundryLoadedObject[] objects)
     1.6  		{
     1.7 -			ZipFile zipFile = ZipFile.Create(path);
     1.8 -			zipFile.BeginUpdate();
     1.9 -			zipFile.CommitUpdate();
    1.10 -			zipFile.Close();
    1.11 +			ZipOutputStream zipStream = new ZipOutputStream(new FileStream(path, FileMode.Create));
    1.12 +			AddFiles(zipStream, objects);
    1.13 +			zipStream.Close();
    1.14  			return true;
    1.15  		}
    1.16 +
    1.17 +		public void AddFiles(ZipOutputStream zipStream, WarFoundryLoadedObject[] objects)
    1.18 +		{
    1.19 +			foreach (WarFoundryLoadedObject obj in objects)
    1.20 +			{
    1.21 +				AddFile(zipStream, obj);
    1.22 +			}
    1.23 +		}
    1.24 +
    1.25 +		public void AddFile(ZipOutputStream zipStream, WarFoundryLoadedObject obj)
    1.26 +		{
    1.27 +			ZipEntry entry = new ZipEntry(obj.ID);
    1.28 +			zipStream.PutNextEntry(entry);
    1.29 +		}
    1.30  	}
    1.31  }