127 throw new InvalidOperationException(
"Central directory currently does not exist");
129 List<ZipArchiveEntry> list =
new();
133 for (
int i = 0; i < CentralDirImage.Length && BitConverter.ToUInt32(
CentralDirImage, i) == 33639248; i += 46 + num + num2 + num3) {
143 uint headerSize = (uint)(46 + num + num2 + num3);
144 Encoding uTF = Encoding.UTF8;
151 CompressedSize = compressedSize,
152 HeaderOffset = headerOffset,
153 HeaderSize = headerSize,
158 zipArchiveEntry.Comment = uTF.GetString(
CentralDirImage, i + 46 + num + num2, num3);
160 list.Add(zipArchiveEntry);
166 if (!stream.CanWrite) {
167 throw new InvalidOperationException(
"Stream cannot be written");
169 byte[] array =
new byte[4];
172 if (BitConverter.ToUInt32(array, 0) != 67324752) {
173 throw new InvalidOperationException(
"Unsupported zip archive.");
181 throw new InvalidOperationException(
"Unsupported zip archive.");
183 stream2 =
new DeflateStream(
ZipFileStream, CompressionMode.Decompress,
true);
185 byte[] array2 =
new byte[16384];
189 int num2 = stream2.Read(array2, 0, (
int)Math.Min(num, array2.Length));
190 stream.Write(array2, 0, num2);
191 num = (uint)((
int)num - num2);
200 byte[] array =
new byte[2];
203 ushort num = BitConverter.ToUInt16(array, 0);
205 ushort num2 = BitConverter.ToUInt16(array, 0);
206 return (uint)(30 + num + num2 + _headerOffset);
217 ZipFileStream.Write(BitConverter.GetBytes((ushort)bytes.Length), 0, 2);
224 Encoding uTF = Encoding.UTF8;
226 byte[] bytes2 = uTF.GetBytes(_zfe.
Comment);
247 ZipFileStream.Write(BitConverter.GetBytes((ushort)bytes.Length), 0, 2);
249 ZipFileStream.Write(BitConverter.GetBytes((ushort)bytes2.Length), 0, 2);
253 ZipFileStream.Write(BitConverter.GetBytes((ushort)33024), 0, 2);
260 byte[] bytes = Encoding.UTF8.GetBytes(
Comment);
279 ZipFileStream.Write(BitConverter.GetBytes((ushort)bytes.Length), 0, 2);
284 byte[] array =
new byte[16384];
287 long position2 = _source.Position;
289 _zfe.Crc32 = 4294967295u;
292 num2 = _source.Read(array, 0, array.Length);
293 num = (uint)((
int)num + num2);
295 stream.Write(array, 0, num2);
296 for (uint num3 = 0u; num3 < num2; num3++) {
297 _zfe.Crc32 =
CrcTable[(_zfe.Crc32 ^ array[num3]) & 0xFF] ^ (_zfe.
Crc32 >> 8);
301 while (num2 == array.Length);
306 _zfe.Crc32 ^= 4294967295u;
308 _zfe.CompressedSize = (uint)(
ZipFileStream.Position - position);
314 ZipFileStream.Position = position;
316 _source.Position = position2;
317 Store(_zfe, _source);
329 (int)((_dt >> 25) + 1980),
330 (int)((_dt >> 21) & 0xF),
331 (int)((_dt >> 16) & 0x1F),
332 (int)((_dt >> 11) & 0x1F),
333 (int)((_dt >> 5) & 0x3F),
334 (int)((_dt & 0x1F) * 2)
339 ZipFileStream.Position = _zfe.HeaderOffset + 8;
341 ZipFileStream.Position = _zfe.HeaderOffset + 14;
345 ZipFileStream.Position = position;
366 if (binaryReader.ReadUInt32() == 101010256) {
368 ushort existingFiles = binaryReader.ReadUInt16();
369 int num = binaryReader.ReadInt32();
370 uint num2 = binaryReader.ReadUInt32();
371 ushort num3 = binaryReader.ReadUInt16();