private void WriteZipFileHeader(Stream writer) { byte[] bytes = Encoding.UTF8.GetBytes(this.name.Replace(Path.DirectorySeparatorChar, '/')); if ((ulong)((uint)this.length) != this.length) { throw new ApplicationException("File length too long."); } this.headerOffset = (uint)writer.Position; ByteBuffer byteBuffer = new ByteBuffer(30); byteBuffer.WriteUInt32(67324752); byteBuffer.WriteUInt16(256); byteBuffer.WriteUInt16(0); byteBuffer.WriteUInt16((ushort)this.compressionMethod); byteBuffer.WriteUInt32(ZipArchiveFile.DateTimeToDosTime(this.lastWriteTime)); byteBuffer.WriteUInt32(this.CheckSum); byteBuffer.WriteUInt32((uint)this.compressedLength); byteBuffer.WriteUInt32((uint)this.Length); byteBuffer.WriteUInt16((ushort)((int)bytes.Length)); byteBuffer.WriteUInt16(0); byteBuffer.WriteContentsTo(writer); writer.Write(bytes, 0, (int)bytes.Length); }
internal void WriteArchiveDirectoryEntryToStream(Stream writer) { byte[] bytes = Encoding.UTF8.GetBytes(this.name); ByteBuffer byteBuffer = new ByteBuffer(46); byteBuffer.WriteUInt32(33639248); byteBuffer.WriteUInt16(0); byteBuffer.WriteUInt16(256); byteBuffer.WriteUInt16(0); byteBuffer.WriteUInt16((ushort)this.compressionMethod); byteBuffer.WriteUInt32(ZipArchiveFile.DateTimeToDosTime(this.lastWriteTime)); byteBuffer.WriteUInt32(this.CheckSum); byteBuffer.WriteUInt32((uint)this.compressedLength); byteBuffer.WriteUInt32((uint)this.Length); byteBuffer.WriteUInt16((ushort)((int)bytes.Length)); byteBuffer.WriteUInt16(0); byteBuffer.WriteUInt16(0); byteBuffer.WriteUInt16(0); byteBuffer.WriteUInt16(0); byteBuffer.WriteUInt32(0); byteBuffer.WriteUInt32(this.headerOffset); byteBuffer.WriteContentsTo(writer); writer.Write(bytes, 0, (int)bytes.Length); }