AODL.Document.Import.OpenDocument.OpenDocumentImporter.UnpackFiles C# (CSharp) Method

UnpackFiles() private method

Unpacks the files.
private UnpackFiles ( string file ) : void
file string The file.
return void
		private void UnpackFiles(string file)
		{
			if (!Directory.Exists(m_dirInfo.Dir))
				Directory.CreateDirectory(m_dirInfo.Dir);

			ZipInputStream s = new ZipInputStream(File.OpenRead(file));
			
			ZipEntry theEntry;
			while ((theEntry = s.GetNextEntry()) != null)
			{
				string directoryName = Path.GetDirectoryName(theEntry.Name);
				string fileName      = Path.GetFileName(theEntry.Name);

				if (directoryName != String.Empty)
					Directory.CreateDirectory(Path.Combine(m_dirInfo.Dir, directoryName));
				
				if (fileName != String.Empty)
				{
					FileStream streamWriter = File.Create(Path.Combine(m_dirInfo.Dir, theEntry.Name));
					// TODO: Switch this to MemoryStream which is accessible through a package factory
					int size = 2048;
					byte[] data = new byte[2048];
					while (true)
					{
						size = s.Read(data, 0, data.Length);
						if (size > 0)
						{
							streamWriter.Write(data, 0, size);
						}
						else
						{
							break;
						}
					}
					
					streamWriter.Close();
				}
			}
			s.Close();
			
			this.MovePictures();
			this.ReadResources();
		}