Exemplo n.º 1
0
		public override Package Read()
		{
			Package package = new Package();
			package.Name = this.packageName;
			ZipInputStream zipInputStream = new ZipInputStream(this.input);
			ZipEntry nextEntry;
			while ((nextEntry = zipInputStream.GetNextEntry()) != null)
			{
				if (!nextEntry.IsDirectory)
				{
					byte[] numArray = new byte[nextEntry.Size];
					int offset = 0;
					int length = numArray.Length;
					int num;
					do
					{
						num = ((Stream)zipInputStream).Read(numArray, offset, length);
						offset += num;
						length -= num;
					}
					while (num > 0);
					string path = nextEntry.Name.Replace('/', '\\').Trim(new char[]	{ '\\' });
					this.AddEntry(package, path, numArray);
				}
			}
			return package;
		}
Exemplo n.º 2
0
		protected void AddEntry(Package package, string path, byte[] data)
		{
            string[] array = path.Split(new char[] { Path.DirectorySeparatorChar });
			PackageFolder packageFolder = (PackageFolder)package;
            for (int i = 0; i < array.Length - 1; ++i)
				packageFolder = packageFolder.GetEntry<PackageFolder>(array[i]);
			packageFolder.GetEntry<PackageFile>(array[array.Length - 1]).Data = data;
		}
Exemplo n.º 3
0
		public override void Write(Package package)
		{
			MemoryStream memoryStream = new MemoryStream();
			ZipOutputStream zipStream = new ZipOutputStream(memoryStream);
			this.WriteFolder(zipStream, string.Empty, (PackageFolder)package);
			((DeflaterOutputStream)zipStream).Finish();
			memoryStream.WriteTo(this.output);
		}
Exemplo n.º 4
0
		public override Package Read()
		{
			Package package = new Package();
			package.Name = this.directory.Name;
			foreach (FileInfo fileInfo in this.directory.GetFiles("*.*", SearchOption.AllDirectories))
			{
				string path = fileInfo.FullName.Substring(this.directory.FullName.Length + 1);
				byte[] data = File.ReadAllBytes(fileInfo.FullName);
				this.AddEntry(package, path, data);
			}
			return package;
		}
Exemplo n.º 5
0
		public override void Write(Package package)
		{
			this.Write(this.directory, package);
		}