public static ZipSegmentedStream ForReading(string name, uint initialDiskNumber, uint maxDiskNumber) { ZipSegmentedStream zss = new ZipSegmentedStream() { rw = 1, // 1 == readonly CurrentSegment = initialDiskNumber, _maxDiskNumber = maxDiskNumber, _baseName = name, }; zss._SetReadStream(); return zss; }
public static ZipSegmentedStream ForWriting(string name, int maxSegmentSize) { ZipSegmentedStream zss = new ZipSegmentedStream() { rw = 2, // 2 == write CurrentSegment = 0, _baseName = name, _maxSegmentSize = maxSegmentSize, _baseDir = Path.GetDirectoryName(name) }; // workitem 9522 if (zss._baseDir=="") zss._baseDir="."; zss._SetWriteStream(0); return zss; }
public static ZipSegmentedStream ForReading(string name, uint initialDiskNumber, uint maxDiskNumber) { ZipSegmentedStream zss = new ZipSegmentedStream() { rwMode = RwMode.ReadOnly, CurrentSegment = initialDiskNumber, _maxDiskNumber = maxDiskNumber, _baseName = name, }; // Console.WriteLine("ZSS: ForReading ({0})", // Path.GetFileName(zss.CurrentName)); zss._SetReadStream(); return zss; }
public static ZipSegmentedStream ForWriting(string name, int maxSegmentSize) { ZipSegmentedStream zss = new ZipSegmentedStream() { rwMode = RwMode.Write, CurrentSegment = 0, _baseName = name, _maxSegmentSize = maxSegmentSize, _baseDir = Path.GetDirectoryName(name) }; // workitem 9522 if (zss._baseDir == "") { zss._baseDir = "."; } zss._SetWriteStream(0); // Console.WriteLine("ZSS: ForWriting ({0})", // Path.GetFileName(zss.CurrentName)); return(zss); }
public static ZipSegmentedStream ForWriting(string name, int maxSegmentSize) { ZipSegmentedStream zss = new ZipSegmentedStream() { rwMode = RwMode.Write, CurrentSegment = 0, _baseName = name, _maxSegmentSize = maxSegmentSize, _baseDir = Path.GetDirectoryName(name) }; // workitem 9522 if (zss._baseDir=="") zss._baseDir="."; zss._SetWriteStream(0); // Console.WriteLine("ZSS: ForWriting ({0})", // Path.GetFileName(zss.CurrentName)); return zss; }
public static ZipSegmentedStream ForWriting(ZipSegmentedStreamManager manager, int maxSegmentSize) { ZipSegmentedStream zss = new ZipSegmentedStream() { rwMode = RwMode.Write, CurrentSegment = 0, _maxSegmentSize = maxSegmentSize, _manager = manager }; zss._SetWriteStream(0); // Console.WriteLine("ZSS: ForWriting ({0})", // Path.GetFileName(zss.CurrentName)); return zss; }
// Token: 0x0600051B RID: 1307 RVA: 0x00024F38 File Offset: 0x00023138 public static bool WriteCentralDirectoryStructure(Stream s, ICollection <ZipEntry> entries, uint numSegments, Zip64Option zip64, string comment, ZipContainer container) { ZipSegmentedStream zipSegmentedStream = s as ZipSegmentedStream; if (zipSegmentedStream != null) { zipSegmentedStream.ContiguousWrite = true; } long num = 0L; using (MemoryStream memoryStream = new MemoryStream()) { foreach (ZipEntry zipEntry in entries) { if (zipEntry.IncludedInMostRecentSave) { zipEntry.WriteCentralDirectoryEntry(memoryStream); } } byte[] array = memoryStream.ToArray(); s.Write(array, 0, array.Length); num = (long)array.Length; } CountingStream countingStream = s as CountingStream; long num2 = (countingStream != null) ? countingStream.ComputedPosition : s.Position; long num3 = num2 - num; uint num4 = (zipSegmentedStream != null) ? zipSegmentedStream.CurrentSegment : 0u; long num5 = num2 - num3; int num6 = ZipOutput.CountEntries(entries); bool flag = zip64 == Zip64Option.Always || num6 >= 65535 || num5 > (long)((ulong)-1) || num3 > (long)((ulong)-1); byte[] array3; if (flag) { if (zip64 == Zip64Option.Default) { StackFrame stackFrame = new StackFrame(1); if (stackFrame.GetMethod().DeclaringType == typeof(ZipFile)) { throw new ZipException("The archive requires a ZIP64 Central Directory. Consider setting the ZipFile.UseZip64WhenSaving property."); } throw new ZipException("The archive requires a ZIP64 Central Directory. Consider setting the ZipOutputStream.EnableZip64 property."); } else { byte[] array2 = ZipOutput.GenZip64EndOfCentralDirectory(num3, num2, num6, numSegments); array3 = ZipOutput.GenCentralDirectoryFooter(num3, num2, zip64, num6, comment, container); if (num4 != 0u) { uint value = zipSegmentedStream.ComputeSegment(array2.Length + array3.Length); int num7 = 16; Array.Copy(BitConverter.GetBytes(value), 0, array2, num7, 4); num7 += 4; Array.Copy(BitConverter.GetBytes(value), 0, array2, num7, 4); num7 = 60; Array.Copy(BitConverter.GetBytes(value), 0, array2, num7, 4); num7 += 4; num7 += 8; Array.Copy(BitConverter.GetBytes(value), 0, array2, num7, 4); } s.Write(array2, 0, array2.Length); } } else { array3 = ZipOutput.GenCentralDirectoryFooter(num3, num2, zip64, num6, comment, container); } if (num4 != 0u) { ushort value2 = (ushort)zipSegmentedStream.ComputeSegment(array3.Length); int num8 = 4; Array.Copy(BitConverter.GetBytes(value2), 0, array3, num8, 2); num8 += 2; Array.Copy(BitConverter.GetBytes(value2), 0, array3, num8, 2); num8 += 2; } s.Write(array3, 0, array3.Length); if (zipSegmentedStream != null) { zipSegmentedStream.ContiguousWrite = false; } return(flag); }
public static ZipSegmentedStream ForUpdate(string name, uint diskNumber) { // ForUpdate is used only when updating the zip entry metadata for // a segmented zip file, when the starting segment is earlier // than the ending segment, for a particular entry. ZipSegmentedStream zss = new ZipSegmentedStream() { rw = 3, // 3 == update CurrentSegment = diskNumber, _baseName = name, _maxSegmentSize = Int32.MaxValue // insure no rollover }; // It's safe to assume that the update will not expand the size of the segment. // It's an in-place update of zip metadata. // Console.WriteLine("ZipSegmentedStream: update ({0})", name); zss._SetUpdateStream(); return zss; }