Mercurial > repos > IBDev-IBBoard.WarFoundry.API
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 wrap: on
line diff
--- a/api/Savers/Xml/WarFoundryXmlFileSaver.cs Sat Mar 05 15:22:07 2011 +0000 +++ b/api/Savers/Xml/WarFoundryXmlFileSaver.cs Sat Mar 05 15:38:54 2011 +0000 @@ -14,11 +14,24 @@ public bool Save(string path, params WarFoundryLoadedObject[] objects) { - ZipFile zipFile = ZipFile.Create(path); - zipFile.BeginUpdate(); - zipFile.CommitUpdate(); - zipFile.Close(); + ZipOutputStream zipStream = new ZipOutputStream(new FileStream(path, FileMode.Create)); + AddFiles(zipStream, objects); + zipStream.Close(); return true; } + + public void AddFiles(ZipOutputStream zipStream, WarFoundryLoadedObject[] objects) + { + foreach (WarFoundryLoadedObject obj in objects) + { + AddFile(zipStream, obj); + } + } + + public void AddFile(ZipOutputStream zipStream, WarFoundryLoadedObject obj) + { + ZipEntry entry = new ZipEntry(obj.ID); + zipStream.PutNextEntry(entry); + } } }