GIT: perform LF normalization
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,248 +1,248 @@
|
||||
// BitWriter.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2011 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Last Saved: <2011-July-25 18:57:31>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the BitWriter class, which writes bits at a time
|
||||
// to an output stream. It's used by the BZip2Compressor class, and by
|
||||
// the BZip2OutputStream class and its parallel variant,
|
||||
// ParallelBZip2OutputStream.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Design notes:
|
||||
//
|
||||
// BZip2 employs byte-shredding in its data format - rather than
|
||||
// aligning all data items in a compressed .bz2 file on byte barriers,
|
||||
// the BZip2 format uses portions of bytes to represent independent
|
||||
// pieces of information. This "shredding" starts with the first
|
||||
// "randomised" bit - just 12 bytes or so into a bz2 file or stream. But
|
||||
// the approach is used extensively in bzip2 files - sometimes 5 bits
|
||||
// are used, sometimes 24 or 3 bits, sometimes just 1 bit, and so on.
|
||||
// It's not possible to send this information directly to a stream in
|
||||
// this form; Streams in .NET accept byte-oriented input. Therefore,
|
||||
// when actually writing a bz2 file, the output data must be organized
|
||||
// into a byte-aligned format before being written to the output stream.
|
||||
//
|
||||
// This BitWriter class provides the byte-shredding necessary for BZip2
|
||||
// output. Think of this class as an Adapter that enables Bit-oriented
|
||||
// output to a standard byte-oriented .NET stream. This class writes
|
||||
// data out to the captive output stream only after the data bits have
|
||||
// been accumulated and aligned. For example, suppose that during
|
||||
// operation, the BZip2 compressor emits 5 bits, then 24 bits, then 32
|
||||
// bits. When the first 5 bits are sent to the BitWriter, nothing is
|
||||
// written to the output stream; instead these 5 bits are simply stored
|
||||
// in the internal accumulator. When the next 24 bits are written, the
|
||||
// first 3 bits are gathered with the accumulated bits. The resulting
|
||||
// 5+3 constitutes an entire byte; the BitWriter then actually writes
|
||||
// that byte to the output stream. This leaves 21 bits. BitWriter writes
|
||||
// 2 more whole bytes (16 more bits), in 8-bit chunks, leaving 5 in the
|
||||
// accumulator. BitWriter then follows the same procedure with the 32
|
||||
// new bits. And so on.
|
||||
//
|
||||
// A quick tour of the implementation:
|
||||
//
|
||||
// The accumulator is a uint - so it can accumulate at most 4 bytes of
|
||||
// information. In practice because of the design of this class, it
|
||||
// never accumulates more than 3 bytes.
|
||||
//
|
||||
// The Flush() method emits all whole bytes available. After calling
|
||||
// Flush(), there may be between 0-7 bits yet to be emitted into the
|
||||
// output stream.
|
||||
//
|
||||
// FinishAndPad() emits all data, including the last partial byte and
|
||||
// any necessary padding. In effect, it establishes a byte-alignment
|
||||
// barrier. To support bzip2, FinishAndPad() should be called only once
|
||||
// for a bz2 file, after the last bit of data has been written through
|
||||
// this adapter. Other binary file formats may use byte-alignment at
|
||||
// various points within the file, and FinishAndPad() would support that
|
||||
// scenario.
|
||||
//
|
||||
// The internal fn Reset() is used to reset the state of the adapter;
|
||||
// this class is used by BZip2Compressor, instances of which get re-used
|
||||
// by multiple distinct threads, for different blocks of data.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Ionic.BZip2
|
||||
{
|
||||
|
||||
internal class BitWriter
|
||||
{
|
||||
uint accumulator;
|
||||
int nAccumulatedBits;
|
||||
Stream output;
|
||||
int totalBytesWrittenOut;
|
||||
|
||||
public BitWriter(Stream s)
|
||||
{
|
||||
this.output = s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delivers the remaining bits, left-aligned, in a byte.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This is valid only if NumRemainingBits is less than 8;
|
||||
/// in other words it is valid only after a call to Flush().
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public byte RemainingBits
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte) (this.accumulator >> (32 - this.nAccumulatedBits) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
public int NumRemainingBits
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nAccumulatedBits;
|
||||
}
|
||||
}
|
||||
|
||||
public int TotalBytesWrittenOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.totalBytesWrittenOut;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the BitWriter.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This is useful when the BitWriter writes into a MemoryStream, and
|
||||
/// is used by a BZip2Compressor, which itself is re-used for multiple
|
||||
/// distinct data blocks.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public void Reset()
|
||||
{
|
||||
this.accumulator = 0;
|
||||
this.nAccumulatedBits = 0;
|
||||
this.totalBytesWrittenOut = 0;
|
||||
this.output.Seek(0, SeekOrigin.Begin);
|
||||
this.output.SetLength(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write some number of bits from the given value, into the output.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The nbits value should be a max of 25, for safety. For performance
|
||||
/// reasons, this method does not check!
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public void WriteBits(int nbits, uint value)
|
||||
{
|
||||
int nAccumulated = this.nAccumulatedBits;
|
||||
uint u = this.accumulator;
|
||||
|
||||
while (nAccumulated >= 8)
|
||||
{
|
||||
this.output.WriteByte ((byte)(u >> 24 & 0xff));
|
||||
this.totalBytesWrittenOut++;
|
||||
u <<= 8;
|
||||
nAccumulated -= 8;
|
||||
}
|
||||
|
||||
this.accumulator = u | (value << (32 - nAccumulated - nbits));
|
||||
this.nAccumulatedBits = nAccumulated + nbits;
|
||||
|
||||
// Console.WriteLine("WriteBits({0}, 0x{1:X2}) => {2:X8} n({3})",
|
||||
// nbits, value, accumulator, nAccumulatedBits);
|
||||
// Console.ReadLine();
|
||||
|
||||
// At this point the accumulator may contain up to 31 bits waiting for
|
||||
// output.
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Write a full 8-bit byte into the output.
|
||||
/// </summary>
|
||||
public void WriteByte(byte b)
|
||||
{
|
||||
WriteBits(8, b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write four 8-bit bytes into the output.
|
||||
/// </summary>
|
||||
public void WriteInt(uint u)
|
||||
{
|
||||
WriteBits(8, (u >> 24) & 0xff);
|
||||
WriteBits(8, (u >> 16) & 0xff);
|
||||
WriteBits(8, (u >> 8) & 0xff);
|
||||
WriteBits(8, u & 0xff);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write all available byte-aligned bytes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method writes no new output, but flushes any accumulated
|
||||
/// bits. At completion, the accumulator may contain up to 7
|
||||
/// bits.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This is necessary when re-assembling output from N independent
|
||||
/// compressors, one for each of N blocks. The output of any
|
||||
/// particular compressor will in general have some fragment of a byte
|
||||
/// remaining. This fragment needs to be accumulated into the
|
||||
/// parent BZip2OutputStream.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public void Flush()
|
||||
{
|
||||
WriteBits(0,0);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Writes all available bytes, and emits padding for the final byte as
|
||||
/// necessary. This must be the last method invoked on an instance of
|
||||
/// BitWriter.
|
||||
/// </summary>
|
||||
public void FinishAndPad()
|
||||
{
|
||||
Flush();
|
||||
|
||||
if (this.NumRemainingBits > 0)
|
||||
{
|
||||
byte b = (byte)((this.accumulator >> 24) & 0xff);
|
||||
this.output.WriteByte(b);
|
||||
this.totalBytesWrittenOut++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// BitWriter.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2011 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Last Saved: <2011-July-25 18:57:31>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the BitWriter class, which writes bits at a time
|
||||
// to an output stream. It's used by the BZip2Compressor class, and by
|
||||
// the BZip2OutputStream class and its parallel variant,
|
||||
// ParallelBZip2OutputStream.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// Design notes:
|
||||
//
|
||||
// BZip2 employs byte-shredding in its data format - rather than
|
||||
// aligning all data items in a compressed .bz2 file on byte barriers,
|
||||
// the BZip2 format uses portions of bytes to represent independent
|
||||
// pieces of information. This "shredding" starts with the first
|
||||
// "randomised" bit - just 12 bytes or so into a bz2 file or stream. But
|
||||
// the approach is used extensively in bzip2 files - sometimes 5 bits
|
||||
// are used, sometimes 24 or 3 bits, sometimes just 1 bit, and so on.
|
||||
// It's not possible to send this information directly to a stream in
|
||||
// this form; Streams in .NET accept byte-oriented input. Therefore,
|
||||
// when actually writing a bz2 file, the output data must be organized
|
||||
// into a byte-aligned format before being written to the output stream.
|
||||
//
|
||||
// This BitWriter class provides the byte-shredding necessary for BZip2
|
||||
// output. Think of this class as an Adapter that enables Bit-oriented
|
||||
// output to a standard byte-oriented .NET stream. This class writes
|
||||
// data out to the captive output stream only after the data bits have
|
||||
// been accumulated and aligned. For example, suppose that during
|
||||
// operation, the BZip2 compressor emits 5 bits, then 24 bits, then 32
|
||||
// bits. When the first 5 bits are sent to the BitWriter, nothing is
|
||||
// written to the output stream; instead these 5 bits are simply stored
|
||||
// in the internal accumulator. When the next 24 bits are written, the
|
||||
// first 3 bits are gathered with the accumulated bits. The resulting
|
||||
// 5+3 constitutes an entire byte; the BitWriter then actually writes
|
||||
// that byte to the output stream. This leaves 21 bits. BitWriter writes
|
||||
// 2 more whole bytes (16 more bits), in 8-bit chunks, leaving 5 in the
|
||||
// accumulator. BitWriter then follows the same procedure with the 32
|
||||
// new bits. And so on.
|
||||
//
|
||||
// A quick tour of the implementation:
|
||||
//
|
||||
// The accumulator is a uint - so it can accumulate at most 4 bytes of
|
||||
// information. In practice because of the design of this class, it
|
||||
// never accumulates more than 3 bytes.
|
||||
//
|
||||
// The Flush() method emits all whole bytes available. After calling
|
||||
// Flush(), there may be between 0-7 bits yet to be emitted into the
|
||||
// output stream.
|
||||
//
|
||||
// FinishAndPad() emits all data, including the last partial byte and
|
||||
// any necessary padding. In effect, it establishes a byte-alignment
|
||||
// barrier. To support bzip2, FinishAndPad() should be called only once
|
||||
// for a bz2 file, after the last bit of data has been written through
|
||||
// this adapter. Other binary file formats may use byte-alignment at
|
||||
// various points within the file, and FinishAndPad() would support that
|
||||
// scenario.
|
||||
//
|
||||
// The internal fn Reset() is used to reset the state of the adapter;
|
||||
// this class is used by BZip2Compressor, instances of which get re-used
|
||||
// by multiple distinct threads, for different blocks of data.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Ionic.BZip2
|
||||
{
|
||||
|
||||
internal class BitWriter
|
||||
{
|
||||
uint accumulator;
|
||||
int nAccumulatedBits;
|
||||
Stream output;
|
||||
int totalBytesWrittenOut;
|
||||
|
||||
public BitWriter(Stream s)
|
||||
{
|
||||
this.output = s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delivers the remaining bits, left-aligned, in a byte.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This is valid only if NumRemainingBits is less than 8;
|
||||
/// in other words it is valid only after a call to Flush().
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public byte RemainingBits
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte) (this.accumulator >> (32 - this.nAccumulatedBits) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
public int NumRemainingBits
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nAccumulatedBits;
|
||||
}
|
||||
}
|
||||
|
||||
public int TotalBytesWrittenOut
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.totalBytesWrittenOut;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the BitWriter.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This is useful when the BitWriter writes into a MemoryStream, and
|
||||
/// is used by a BZip2Compressor, which itself is re-used for multiple
|
||||
/// distinct data blocks.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public void Reset()
|
||||
{
|
||||
this.accumulator = 0;
|
||||
this.nAccumulatedBits = 0;
|
||||
this.totalBytesWrittenOut = 0;
|
||||
this.output.Seek(0, SeekOrigin.Begin);
|
||||
this.output.SetLength(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write some number of bits from the given value, into the output.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The nbits value should be a max of 25, for safety. For performance
|
||||
/// reasons, this method does not check!
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public void WriteBits(int nbits, uint value)
|
||||
{
|
||||
int nAccumulated = this.nAccumulatedBits;
|
||||
uint u = this.accumulator;
|
||||
|
||||
while (nAccumulated >= 8)
|
||||
{
|
||||
this.output.WriteByte ((byte)(u >> 24 & 0xff));
|
||||
this.totalBytesWrittenOut++;
|
||||
u <<= 8;
|
||||
nAccumulated -= 8;
|
||||
}
|
||||
|
||||
this.accumulator = u | (value << (32 - nAccumulated - nbits));
|
||||
this.nAccumulatedBits = nAccumulated + nbits;
|
||||
|
||||
// Console.WriteLine("WriteBits({0}, 0x{1:X2}) => {2:X8} n({3})",
|
||||
// nbits, value, accumulator, nAccumulatedBits);
|
||||
// Console.ReadLine();
|
||||
|
||||
// At this point the accumulator may contain up to 31 bits waiting for
|
||||
// output.
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Write a full 8-bit byte into the output.
|
||||
/// </summary>
|
||||
public void WriteByte(byte b)
|
||||
{
|
||||
WriteBits(8, b);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write four 8-bit bytes into the output.
|
||||
/// </summary>
|
||||
public void WriteInt(uint u)
|
||||
{
|
||||
WriteBits(8, (u >> 24) & 0xff);
|
||||
WriteBits(8, (u >> 16) & 0xff);
|
||||
WriteBits(8, (u >> 8) & 0xff);
|
||||
WriteBits(8, u & 0xff);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write all available byte-aligned bytes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method writes no new output, but flushes any accumulated
|
||||
/// bits. At completion, the accumulator may contain up to 7
|
||||
/// bits.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This is necessary when re-assembling output from N independent
|
||||
/// compressors, one for each of N blocks. The output of any
|
||||
/// particular compressor will in general have some fragment of a byte
|
||||
/// remaining. This fragment needs to be accumulated into the
|
||||
/// parent BZip2OutputStream.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public void Flush()
|
||||
{
|
||||
WriteBits(0,0);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Writes all available bytes, and emits padding for the final byte as
|
||||
/// necessary. This must be the last method invoked on an instance of
|
||||
/// BitWriter.
|
||||
/// </summary>
|
||||
public void FinishAndPad()
|
||||
{
|
||||
Flush();
|
||||
|
||||
if (this.NumRemainingBits > 0)
|
||||
{
|
||||
byte b = (byte)((this.accumulator >> 24) & 0xff);
|
||||
this.output.WriteByte(b);
|
||||
this.totalBytesWrittenOut++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,99 +1,99 @@
|
||||
// Rand.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2011 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Last Saved: <2011-July-31 15:09:16>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines a helper class for the BZip2 classes. This code
|
||||
// is derived from the original BZip2 source code.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.BZip2
|
||||
{
|
||||
internal static class Rand
|
||||
{
|
||||
private static int[] RNUMS =
|
||||
{
|
||||
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
|
||||
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
|
||||
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
|
||||
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
|
||||
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
|
||||
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
|
||||
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
|
||||
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
|
||||
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
|
||||
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
|
||||
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
|
||||
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
|
||||
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
|
||||
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
|
||||
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
|
||||
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
|
||||
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
|
||||
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
|
||||
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
|
||||
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
|
||||
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
|
||||
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
|
||||
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
|
||||
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
|
||||
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
|
||||
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
|
||||
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
|
||||
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
|
||||
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
|
||||
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
|
||||
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
|
||||
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
|
||||
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
|
||||
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
|
||||
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
|
||||
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
|
||||
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
|
||||
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
|
||||
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
|
||||
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
|
||||
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
|
||||
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
|
||||
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
|
||||
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
|
||||
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
|
||||
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
|
||||
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
|
||||
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
|
||||
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
|
||||
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
|
||||
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
|
||||
936, 638
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the "random" number at a specific index.
|
||||
/// </summary>
|
||||
/// <param name='i'>the index</param>
|
||||
/// <returns>the random number</returns>
|
||||
internal static int Rnums(int i)
|
||||
{
|
||||
return RNUMS[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Rand.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2011 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Last Saved: <2011-July-31 15:09:16>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines a helper class for the BZip2 classes. This code
|
||||
// is derived from the original BZip2 source code.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.BZip2
|
||||
{
|
||||
internal static class Rand
|
||||
{
|
||||
private static int[] RNUMS =
|
||||
{
|
||||
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
|
||||
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
|
||||
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
|
||||
419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
|
||||
878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
|
||||
862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
|
||||
150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
|
||||
170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
|
||||
73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
|
||||
909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
|
||||
641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
|
||||
161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
|
||||
382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
|
||||
98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
|
||||
227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
|
||||
469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
|
||||
184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
|
||||
715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
|
||||
951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
|
||||
652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
|
||||
645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
|
||||
609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
|
||||
653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
|
||||
411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
|
||||
170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
|
||||
857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
|
||||
669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
|
||||
944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
|
||||
344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
|
||||
897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
|
||||
433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
|
||||
686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
|
||||
946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
|
||||
978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
|
||||
680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
|
||||
707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
|
||||
297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
|
||||
134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
|
||||
343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
|
||||
140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
|
||||
170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
|
||||
369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
|
||||
804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
|
||||
896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
|
||||
661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
|
||||
768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
|
||||
61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
|
||||
372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
|
||||
780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
|
||||
920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
|
||||
645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
|
||||
936, 638
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the "random" number at a specific index.
|
||||
/// </summary>
|
||||
/// <param name='i'>the index</param>
|
||||
/// <returns>the random number</returns>
|
||||
internal static int Rnums(int i)
|
||||
{
|
||||
return RNUMS[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,116 +1,116 @@
|
||||
// ComHelper.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-June-13 17:04:06>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines a COM Helper class.
|
||||
//
|
||||
// Created: Tue, 08 Sep 2009 22:03
|
||||
//
|
||||
|
||||
using Interop=System.Runtime.InteropServices;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// This class exposes a set of COM-accessible wrappers for static
|
||||
/// methods available on the ZipFile class. You don't need this
|
||||
/// class unless you are using DotNetZip from a COM environment.
|
||||
/// </summary>
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000F")]
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
#if !NETCF
|
||||
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
|
||||
#endif
|
||||
|
||||
public class ComHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.IsZipFile(string)">ZipFile.IsZipFile(string)</see>
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename to of the zip file to check.</param>
|
||||
/// <returns>true if the file contains a valid zip file.</returns>
|
||||
public bool IsZipFile(string filename)
|
||||
{
|
||||
return ZipFile.IsZipFile(filename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.IsZipFile(string, bool)">ZipFile.IsZipFile(string, bool)</see>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We cannot use "overloaded" Method names in COM interop.
|
||||
/// So, here, we use a unique name.
|
||||
/// </remarks>
|
||||
/// <param name="filename">The filename to of the zip file to check.</param>
|
||||
/// <returns>true if the file contains a valid zip file.</returns>
|
||||
public bool IsZipFileWithExtract(string filename)
|
||||
{
|
||||
return ZipFile.IsZipFile(filename, true);
|
||||
}
|
||||
|
||||
#if !NETCF
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.CheckZip(string)">ZipFile.CheckZip(string)</see>
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename to of the zip file to check.</param>
|
||||
///
|
||||
/// <returns>true if the named zip file checks OK. Otherwise, false. </returns>
|
||||
public bool CheckZip(string filename)
|
||||
{
|
||||
return ZipFile.CheckZip(filename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A COM-friendly wrapper for the static method <see cref="ZipFile.CheckZipPassword(string,string)"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="filename">The filename to of the zip file to check.</param>
|
||||
///
|
||||
/// <param name="password">The password to check.</param>
|
||||
///
|
||||
/// <returns>true if the named zip file checks OK. Otherwise, false. </returns>
|
||||
public bool CheckZipPassword(string filename, string password)
|
||||
{
|
||||
return ZipFile.CheckZipPassword(filename, password);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.FixZipDirectory(string)">ZipFile.FixZipDirectory(string)</see>
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename to of the zip file to fix.</param>
|
||||
public void FixZipDirectory(string filename)
|
||||
{
|
||||
ZipFile.FixZipDirectory(filename);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.LibraryVersion">ZipFile.LibraryVersion</see>
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the version number on the DotNetZip assembly, formatted as a string.
|
||||
/// </returns>
|
||||
public string GetZipLibraryVersion()
|
||||
{
|
||||
return ZipFile.LibraryVersion.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
// ComHelper.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-June-13 17:04:06>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines a COM Helper class.
|
||||
//
|
||||
// Created: Tue, 08 Sep 2009 22:03
|
||||
//
|
||||
|
||||
using Interop=System.Runtime.InteropServices;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// This class exposes a set of COM-accessible wrappers for static
|
||||
/// methods available on the ZipFile class. You don't need this
|
||||
/// class unless you are using DotNetZip from a COM environment.
|
||||
/// </summary>
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000F")]
|
||||
[System.Runtime.InteropServices.ComVisible(true)]
|
||||
#if !NETCF
|
||||
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
|
||||
#endif
|
||||
|
||||
public class ComHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.IsZipFile(string)">ZipFile.IsZipFile(string)</see>
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename to of the zip file to check.</param>
|
||||
/// <returns>true if the file contains a valid zip file.</returns>
|
||||
public bool IsZipFile(string filename)
|
||||
{
|
||||
return ZipFile.IsZipFile(filename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.IsZipFile(string, bool)">ZipFile.IsZipFile(string, bool)</see>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We cannot use "overloaded" Method names in COM interop.
|
||||
/// So, here, we use a unique name.
|
||||
/// </remarks>
|
||||
/// <param name="filename">The filename to of the zip file to check.</param>
|
||||
/// <returns>true if the file contains a valid zip file.</returns>
|
||||
public bool IsZipFileWithExtract(string filename)
|
||||
{
|
||||
return ZipFile.IsZipFile(filename, true);
|
||||
}
|
||||
|
||||
#if !NETCF
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.CheckZip(string)">ZipFile.CheckZip(string)</see>
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename to of the zip file to check.</param>
|
||||
///
|
||||
/// <returns>true if the named zip file checks OK. Otherwise, false. </returns>
|
||||
public bool CheckZip(string filename)
|
||||
{
|
||||
return ZipFile.CheckZip(filename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A COM-friendly wrapper for the static method <see cref="ZipFile.CheckZipPassword(string,string)"/>.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="filename">The filename to of the zip file to check.</param>
|
||||
///
|
||||
/// <param name="password">The password to check.</param>
|
||||
///
|
||||
/// <returns>true if the named zip file checks OK. Otherwise, false. </returns>
|
||||
public bool CheckZipPassword(string filename, string password)
|
||||
{
|
||||
return ZipFile.CheckZipPassword(filename, password);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.FixZipDirectory(string)">ZipFile.FixZipDirectory(string)</see>
|
||||
/// </summary>
|
||||
/// <param name="filename">The filename to of the zip file to fix.</param>
|
||||
public void FixZipDirectory(string filename)
|
||||
{
|
||||
ZipFile.FixZipDirectory(filename);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// A wrapper for <see cref="ZipFile.LibraryVersion">ZipFile.LibraryVersion</see>
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// the version number on the DotNetZip assembly, formatted as a string.
|
||||
/// </returns>
|
||||
public string GetZipLibraryVersion()
|
||||
{
|
||||
return ZipFile.LibraryVersion.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,135 +1,135 @@
|
||||
// EncryptionAlgorithm.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-October-21 17:24:45>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the EncryptionAgorithm enum
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// An enum that provides the various encryption algorithms supported by this
|
||||
/// library.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// <c>PkzipWeak</c> implies the use of Zip 2.0 encryption, which is known to be
|
||||
/// weak and subvertible.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// A note on interoperability: Values of <c>PkzipWeak</c> and <c>None</c> are
|
||||
/// specified in <see
|
||||
/// href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">PKWARE's zip
|
||||
/// specification</see>, and are considered to be "standard". Zip archives
|
||||
/// produced using these options will be interoperable with many other zip tools
|
||||
/// and libraries, including Windows Explorer.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Values of <c>WinZipAes128</c> and <c>WinZipAes256</c> are not part of the Zip
|
||||
/// specification, but rather imply the use of a vendor-specific extension from
|
||||
/// WinZip. If you want to produce interoperable Zip archives, do not use these
|
||||
/// values. For example, if you produce a zip archive using WinZipAes256, you
|
||||
/// will be able to open it in Windows Explorer on Windows XP and Vista, but you
|
||||
/// will not be able to extract entries; trying this will lead to an "unspecified
|
||||
/// error". For this reason, some people have said that a zip archive that uses
|
||||
/// WinZip's AES encryption is not actually a zip archive at all. A zip archive
|
||||
/// produced this way will be readable with the WinZip tool (Version 11 and
|
||||
/// beyond).
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// There are other third-party tools and libraries, both commercial and
|
||||
/// otherwise, that support WinZip's AES encryption. These will be able to read
|
||||
/// AES-encrypted zip archives produced by DotNetZip, and conversely applications
|
||||
/// that use DotNetZip to read zip archives will be able to read AES-encrypted
|
||||
/// archives produced by those tools or libraries. Consult the documentation for
|
||||
/// those other tools and libraries to find out if WinZip's AES encryption is
|
||||
/// supported.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// In case you care: According to <see
|
||||
/// href="http://www.winzip.com/aes_info.htm">the WinZip specification</see>, the
|
||||
/// actual AES key used is derived from the <see cref="ZipEntry.Password"/> via an
|
||||
/// algorithm that complies with <see
|
||||
/// href="http://www.ietf.org/rfc/rfc2898.txt">RFC 2898</see>, using an iteration
|
||||
/// count of 1000. The algorithm is sometimes referred to as PBKDF2, which stands
|
||||
/// for "Password Based Key Derivation Function #2".
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// A word about password strength and length: The AES encryption technology is
|
||||
/// very good, but any system is only as secure as the weakest link. If you want
|
||||
/// to secure your data, be sure to use a password that is hard to guess. To make
|
||||
/// it harder to guess (increase its "entropy"), you should make it longer. If
|
||||
/// you use normal characters from an ASCII keyboard, a password of length 20 will
|
||||
/// be strong enough that it will be impossible to guess. For more information on
|
||||
/// that, I'd encourage you to read <see
|
||||
/// href="http://www.redkestrel.co.uk/Articles/RandomPasswordStrength.html">this
|
||||
/// article.</see>
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The WinZip AES algorithms are not supported with the version of DotNetZip that
|
||||
/// runs on the .NET Compact Framework. This is because .NET CF lacks the
|
||||
/// HMACSHA1 class that is required for producing the archive.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public enum EncryptionAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// No encryption at all.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Traditional or Classic pkzip encryption.
|
||||
/// </summary>
|
||||
PkzipWeak,
|
||||
|
||||
#if AESCRYPTO
|
||||
/// <summary>
|
||||
/// WinZip AES encryption (128 key bits).
|
||||
/// </summary>
|
||||
WinZipAes128,
|
||||
|
||||
/// <summary>
|
||||
/// WinZip AES encryption (256 key bits).
|
||||
/// </summary>
|
||||
WinZipAes256,
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// An encryption algorithm that is not supported by DotNetZip.
|
||||
/// </summary>
|
||||
Unsupported = 4,
|
||||
|
||||
|
||||
// others... not implemented (yet?)
|
||||
}
|
||||
|
||||
}
|
||||
// EncryptionAlgorithm.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-October-21 17:24:45>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the EncryptionAgorithm enum
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// An enum that provides the various encryption algorithms supported by this
|
||||
/// library.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// <c>PkzipWeak</c> implies the use of Zip 2.0 encryption, which is known to be
|
||||
/// weak and subvertible.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// A note on interoperability: Values of <c>PkzipWeak</c> and <c>None</c> are
|
||||
/// specified in <see
|
||||
/// href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">PKWARE's zip
|
||||
/// specification</see>, and are considered to be "standard". Zip archives
|
||||
/// produced using these options will be interoperable with many other zip tools
|
||||
/// and libraries, including Windows Explorer.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Values of <c>WinZipAes128</c> and <c>WinZipAes256</c> are not part of the Zip
|
||||
/// specification, but rather imply the use of a vendor-specific extension from
|
||||
/// WinZip. If you want to produce interoperable Zip archives, do not use these
|
||||
/// values. For example, if you produce a zip archive using WinZipAes256, you
|
||||
/// will be able to open it in Windows Explorer on Windows XP and Vista, but you
|
||||
/// will not be able to extract entries; trying this will lead to an "unspecified
|
||||
/// error". For this reason, some people have said that a zip archive that uses
|
||||
/// WinZip's AES encryption is not actually a zip archive at all. A zip archive
|
||||
/// produced this way will be readable with the WinZip tool (Version 11 and
|
||||
/// beyond).
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// There are other third-party tools and libraries, both commercial and
|
||||
/// otherwise, that support WinZip's AES encryption. These will be able to read
|
||||
/// AES-encrypted zip archives produced by DotNetZip, and conversely applications
|
||||
/// that use DotNetZip to read zip archives will be able to read AES-encrypted
|
||||
/// archives produced by those tools or libraries. Consult the documentation for
|
||||
/// those other tools and libraries to find out if WinZip's AES encryption is
|
||||
/// supported.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// In case you care: According to <see
|
||||
/// href="http://www.winzip.com/aes_info.htm">the WinZip specification</see>, the
|
||||
/// actual AES key used is derived from the <see cref="ZipEntry.Password"/> via an
|
||||
/// algorithm that complies with <see
|
||||
/// href="http://www.ietf.org/rfc/rfc2898.txt">RFC 2898</see>, using an iteration
|
||||
/// count of 1000. The algorithm is sometimes referred to as PBKDF2, which stands
|
||||
/// for "Password Based Key Derivation Function #2".
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// A word about password strength and length: The AES encryption technology is
|
||||
/// very good, but any system is only as secure as the weakest link. If you want
|
||||
/// to secure your data, be sure to use a password that is hard to guess. To make
|
||||
/// it harder to guess (increase its "entropy"), you should make it longer. If
|
||||
/// you use normal characters from an ASCII keyboard, a password of length 20 will
|
||||
/// be strong enough that it will be impossible to guess. For more information on
|
||||
/// that, I'd encourage you to read <see
|
||||
/// href="http://www.redkestrel.co.uk/Articles/RandomPasswordStrength.html">this
|
||||
/// article.</see>
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The WinZip AES algorithms are not supported with the version of DotNetZip that
|
||||
/// runs on the .NET Compact Framework. This is because .NET CF lacks the
|
||||
/// HMACSHA1 class that is required for producing the archive.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public enum EncryptionAlgorithm
|
||||
{
|
||||
/// <summary>
|
||||
/// No encryption at all.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Traditional or Classic pkzip encryption.
|
||||
/// </summary>
|
||||
PkzipWeak,
|
||||
|
||||
#if AESCRYPTO
|
||||
/// <summary>
|
||||
/// WinZip AES encryption (128 key bits).
|
||||
/// </summary>
|
||||
WinZipAes128,
|
||||
|
||||
/// <summary>
|
||||
/// WinZip AES encryption (256 key bits).
|
||||
/// </summary>
|
||||
WinZipAes256,
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// An encryption algorithm that is not supported by DotNetZip.
|
||||
/// </summary>
|
||||
Unsupported = 4,
|
||||
|
||||
|
||||
// others... not implemented (yet?)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,300 +1,300 @@
|
||||
// Exceptions.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2008, 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-12 12:19:10>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines exceptions used in the class library.
|
||||
//
|
||||
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
#if !NETCF
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
///// <summary>
|
||||
///// Base exception type for all custom exceptions in the Zip library. It acts as a marker class.
|
||||
///// </summary>
|
||||
//[AttributeUsage(AttributeTargets.Class)]
|
||||
//public class ZipExceptionAttribute : Attribute { }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Issued when an <c>ZipEntry.ExtractWithPassword()</c> method is invoked
|
||||
/// with an incorrect password.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000B")]
|
||||
public class BadPasswordException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public BadPasswordException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public BadPasswordException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
/// <param name="innerException">The innerException for this exception.</param>
|
||||
public BadPasswordException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected BadPasswordException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a read was attempted on a stream, and bad or incomplete data was
|
||||
/// received.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000A")]
|
||||
public class BadReadException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public BadReadException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public BadReadException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
/// <param name="innerException">The innerException for this exception.</param>
|
||||
public BadReadException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected BadReadException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Issued when an CRC check fails upon extracting an entry from a zip archive.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00009")]
|
||||
public class BadCrcException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public BadCrcException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public BadCrcException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected BadCrcException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Issued when errors occur saving a self-extracting archive.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00008")]
|
||||
public class SfxGenerationException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public SfxGenerationException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public SfxGenerationException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected SfxGenerationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an operation was attempted on a ZipFile which was not possible
|
||||
/// given the state of the instance. For example, if you call <c>Save()</c> on a ZipFile
|
||||
/// which has no filename set, you can get this exception.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00007")]
|
||||
public class BadStateException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public BadStateException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public BadStateException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
/// <param name="innerException">The innerException for this exception.</param>
|
||||
public BadStateException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{}
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected BadStateException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all exceptions defined by and throw by the Zip library.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00006")]
|
||||
public class ZipException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public ZipException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public ZipException(String message) : base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
/// <param name="innerException">The innerException for this exception.</param>
|
||||
public ZipException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected ZipException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// Exceptions.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2008, 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-12 12:19:10>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines exceptions used in the class library.
|
||||
//
|
||||
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
#if !NETCF
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
///// <summary>
|
||||
///// Base exception type for all custom exceptions in the Zip library. It acts as a marker class.
|
||||
///// </summary>
|
||||
//[AttributeUsage(AttributeTargets.Class)]
|
||||
//public class ZipExceptionAttribute : Attribute { }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Issued when an <c>ZipEntry.ExtractWithPassword()</c> method is invoked
|
||||
/// with an incorrect password.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000B")]
|
||||
public class BadPasswordException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public BadPasswordException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public BadPasswordException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
/// <param name="innerException">The innerException for this exception.</param>
|
||||
public BadPasswordException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected BadPasswordException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a read was attempted on a stream, and bad or incomplete data was
|
||||
/// received.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000A")]
|
||||
public class BadReadException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public BadReadException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public BadReadException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
/// <param name="innerException">The innerException for this exception.</param>
|
||||
public BadReadException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected BadReadException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Issued when an CRC check fails upon extracting an entry from a zip archive.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00009")]
|
||||
public class BadCrcException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public BadCrcException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public BadCrcException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected BadCrcException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Issued when errors occur saving a self-extracting archive.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00008")]
|
||||
public class SfxGenerationException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public SfxGenerationException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public SfxGenerationException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected SfxGenerationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that an operation was attempted on a ZipFile which was not possible
|
||||
/// given the state of the instance. For example, if you call <c>Save()</c> on a ZipFile
|
||||
/// which has no filename set, you can get this exception.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00007")]
|
||||
public class BadStateException : ZipException
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public BadStateException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public BadStateException(String message)
|
||||
: base(message)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
/// <param name="innerException">The innerException for this exception.</param>
|
||||
public BadStateException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{}
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected BadStateException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class for all exceptions defined by and throw by the Zip library.
|
||||
/// </summary>
|
||||
#if !SILVERLIGHT
|
||||
[Serializable]
|
||||
#endif
|
||||
[System.Runtime.InteropServices.GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d00006")]
|
||||
public class ZipException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Default ctor.
|
||||
/// </summary>
|
||||
public ZipException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
public ZipException(String message) : base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="message">The message in the exception.</param>
|
||||
/// <param name="innerException">The innerException for this exception.</param>
|
||||
public ZipException(String message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{ }
|
||||
|
||||
#if ! (NETCF || SILVERLIGHT)
|
||||
/// <summary>
|
||||
/// Come on, you know how exceptions work. Why are you looking at this documentation?
|
||||
/// </summary>
|
||||
/// <param name="info">The serialization info for the exception.</param>
|
||||
/// <param name="context">The streaming context from which to deserialize.</param>
|
||||
protected ZipException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
// ExtractExistingFileAction.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-August-25 08:44:37>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the ExtractExistingFileAction enum
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// An enum for the options when extracting an entry would overwrite an existing file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This enum describes the actions that the library can take when an
|
||||
/// <c>Extract()</c> or <c>ExtractWithPassword()</c> method is called to extract an
|
||||
/// entry to a filesystem, and the extraction would overwrite an existing filesystem
|
||||
/// file.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
///
|
||||
public enum ExtractExistingFileAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Throw an exception when extraction would overwrite an existing file. (For
|
||||
/// COM clients, this is a 0 (zero).)
|
||||
/// </summary>
|
||||
Throw,
|
||||
|
||||
/// <summary>
|
||||
/// When extraction would overwrite an existing file, overwrite the file silently.
|
||||
/// The overwrite will happen even if the target file is marked as read-only.
|
||||
/// (For COM clients, this is a 1.)
|
||||
/// </summary>
|
||||
OverwriteSilently,
|
||||
|
||||
/// <summary>
|
||||
/// When extraction would overwrite an existing file, don't overwrite the file, silently.
|
||||
/// (For COM clients, this is a 2.)
|
||||
/// </summary>
|
||||
DoNotOverwrite,
|
||||
|
||||
/// <summary>
|
||||
/// When extraction would overwrite an existing file, invoke the ExtractProgress
|
||||
/// event, using an event type of <see
|
||||
/// cref="ZipProgressEventType.Extracting_ExtractEntryWouldOverwrite"/>. In
|
||||
/// this way, the application can decide, just-in-time, whether to overwrite the
|
||||
/// file. For example, a GUI application may wish to pop up a dialog to allow
|
||||
/// the user to choose. You may want to examine the <see
|
||||
/// cref="ExtractProgressEventArgs.ExtractLocation"/> property before making
|
||||
/// the decision. If, after your processing in the Extract progress event, you
|
||||
/// want to NOT extract the file, set <see cref="ZipEntry.ExtractExistingFile"/>
|
||||
/// on the <c>ZipProgressEventArgs.CurrentEntry</c> to <c>DoNotOverwrite</c>.
|
||||
/// If you do want to extract the file, set <c>ZipEntry.ExtractExistingFile</c>
|
||||
/// to <c>OverwriteSilently</c>. If you want to cancel the Extraction, set
|
||||
/// <c>ZipProgressEventArgs.Cancel</c> to true. Cancelling differs from using
|
||||
/// DoNotOverwrite in that a cancel will not extract any further entries, if
|
||||
/// there are any. (For COM clients, the value of this enum is a 3.)
|
||||
/// </summary>
|
||||
InvokeExtractProgressEvent,
|
||||
}
|
||||
|
||||
}
|
||||
// ExtractExistingFileAction.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-August-25 08:44:37>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the ExtractExistingFileAction enum
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// An enum for the options when extracting an entry would overwrite an existing file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This enum describes the actions that the library can take when an
|
||||
/// <c>Extract()</c> or <c>ExtractWithPassword()</c> method is called to extract an
|
||||
/// entry to a filesystem, and the extraction would overwrite an existing filesystem
|
||||
/// file.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
///
|
||||
public enum ExtractExistingFileAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Throw an exception when extraction would overwrite an existing file. (For
|
||||
/// COM clients, this is a 0 (zero).)
|
||||
/// </summary>
|
||||
Throw,
|
||||
|
||||
/// <summary>
|
||||
/// When extraction would overwrite an existing file, overwrite the file silently.
|
||||
/// The overwrite will happen even if the target file is marked as read-only.
|
||||
/// (For COM clients, this is a 1.)
|
||||
/// </summary>
|
||||
OverwriteSilently,
|
||||
|
||||
/// <summary>
|
||||
/// When extraction would overwrite an existing file, don't overwrite the file, silently.
|
||||
/// (For COM clients, this is a 2.)
|
||||
/// </summary>
|
||||
DoNotOverwrite,
|
||||
|
||||
/// <summary>
|
||||
/// When extraction would overwrite an existing file, invoke the ExtractProgress
|
||||
/// event, using an event type of <see
|
||||
/// cref="ZipProgressEventType.Extracting_ExtractEntryWouldOverwrite"/>. In
|
||||
/// this way, the application can decide, just-in-time, whether to overwrite the
|
||||
/// file. For example, a GUI application may wish to pop up a dialog to allow
|
||||
/// the user to choose. You may want to examine the <see
|
||||
/// cref="ExtractProgressEventArgs.ExtractLocation"/> property before making
|
||||
/// the decision. If, after your processing in the Extract progress event, you
|
||||
/// want to NOT extract the file, set <see cref="ZipEntry.ExtractExistingFile"/>
|
||||
/// on the <c>ZipProgressEventArgs.CurrentEntry</c> to <c>DoNotOverwrite</c>.
|
||||
/// If you do want to extract the file, set <c>ZipEntry.ExtractExistingFile</c>
|
||||
/// to <c>OverwriteSilently</c>. If you want to cancel the Extraction, set
|
||||
/// <c>ZipProgressEventArgs.Cancel</c> to true. Cancelling differs from using
|
||||
/// DoNotOverwrite in that a cancel will not extract any further entries, if
|
||||
/// there are any. (For COM clients, the value of this enum is a 3.)
|
||||
/// </summary>
|
||||
InvokeExtractProgressEvent,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,114 +1,114 @@
|
||||
// OffsetStream.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-August-27 12:50:35>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines logic for handling reading of zip archives embedded
|
||||
// into larger streams. The initial position of the stream serves as
|
||||
// the base offset for all future Seek() operations.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
internal class OffsetStream : System.IO.Stream, System.IDisposable
|
||||
{
|
||||
private Int64 _originalPosition;
|
||||
private Stream _innerStream;
|
||||
|
||||
public OffsetStream(Stream s)
|
||||
: base()
|
||||
{
|
||||
_originalPosition = s.Position;
|
||||
_innerStream = s;
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
return _innerStream.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return _innerStream.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return _innerStream.CanSeek; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
_innerStream.Flush();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _innerStream.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return _innerStream.Position - _originalPosition; }
|
||||
set { _innerStream.Position = _originalPosition + value; }
|
||||
}
|
||||
|
||||
|
||||
public override long Seek(long offset, System.IO.SeekOrigin origin)
|
||||
{
|
||||
return _innerStream.Seek(_originalPosition + offset, origin) - _originalPosition;
|
||||
}
|
||||
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
base.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// OffsetStream.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-August-27 12:50:35>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines logic for handling reading of zip archives embedded
|
||||
// into larger streams. The initial position of the stream serves as
|
||||
// the base offset for all future Seek() operations.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
internal class OffsetStream : System.IO.Stream, System.IDisposable
|
||||
{
|
||||
private Int64 _originalPosition;
|
||||
private Stream _innerStream;
|
||||
|
||||
public OffsetStream(Stream s)
|
||||
: base()
|
||||
{
|
||||
_originalPosition = s.Position;
|
||||
_innerStream = s;
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
return _innerStream.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return _innerStream.CanRead; }
|
||||
}
|
||||
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return _innerStream.CanSeek; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
_innerStream.Flush();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return _innerStream.Length;
|
||||
}
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { return _innerStream.Position - _originalPosition; }
|
||||
set { _innerStream.Position = _originalPosition + value; }
|
||||
}
|
||||
|
||||
|
||||
public override long Seek(long offset, System.IO.SeekOrigin origin)
|
||||
{
|
||||
return _innerStream.Seek(_originalPosition + offset, origin) - _originalPosition;
|
||||
}
|
||||
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
base.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,51 +1,51 @@
|
||||
// ZipConstants.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2006, 2007, 2008, 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-August-27 23:22:32>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines a few constants that are used in the project.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
static class ZipConstants
|
||||
{
|
||||
public const UInt32 PackedToRemovableMedia = 0x30304b50;
|
||||
public const UInt32 Zip64EndOfCentralDirectoryRecordSignature = 0x06064b50;
|
||||
public const UInt32 Zip64EndOfCentralDirectoryLocatorSignature = 0x07064b50;
|
||||
public const UInt32 EndOfCentralDirectorySignature = 0x06054b50;
|
||||
public const int ZipEntrySignature = 0x04034b50;
|
||||
public const int ZipEntryDataDescriptorSignature = 0x08074b50;
|
||||
public const int SplitArchiveSignature = 0x08074b50;
|
||||
public const int ZipDirEntrySignature = 0x02014b50;
|
||||
|
||||
|
||||
// These are dictated by the Zip Spec.See APPNOTE.txt
|
||||
public const int AesKeySize = 192; // 128, 192, 256
|
||||
public const int AesBlockSize = 128; // ???
|
||||
|
||||
public const UInt16 AesAlgId128 = 0x660E;
|
||||
public const UInt16 AesAlgId192 = 0x660F;
|
||||
public const UInt16 AesAlgId256 = 0x6610;
|
||||
|
||||
}
|
||||
}
|
||||
// ZipConstants.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2006, 2007, 2008, 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-August-27 23:22:32>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines a few constants that are used in the project.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
static class ZipConstants
|
||||
{
|
||||
public const UInt32 PackedToRemovableMedia = 0x30304b50;
|
||||
public const UInt32 Zip64EndOfCentralDirectoryRecordSignature = 0x06064b50;
|
||||
public const UInt32 Zip64EndOfCentralDirectoryLocatorSignature = 0x07064b50;
|
||||
public const UInt32 EndOfCentralDirectorySignature = 0x06054b50;
|
||||
public const int ZipEntrySignature = 0x04034b50;
|
||||
public const int ZipEntryDataDescriptorSignature = 0x08074b50;
|
||||
public const int SplitArchiveSignature = 0x08074b50;
|
||||
public const int ZipDirEntrySignature = 0x02014b50;
|
||||
|
||||
|
||||
// These are dictated by the Zip Spec.See APPNOTE.txt
|
||||
public const int AesKeySize = 192; // 128, 192, 256
|
||||
public const int AesBlockSize = 128; // ???
|
||||
|
||||
public const UInt16 AesAlgId128 = 0x660E;
|
||||
public const UInt16 AesAlgId192 = 0x660F;
|
||||
public const UInt16 AesAlgId256 = 0x6610;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,455 +1,455 @@
|
||||
// ZipCrypto.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2008, 2009, 2011 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-28 06:30:59>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module provides the implementation for "traditional" Zip encryption.
|
||||
//
|
||||
// Created Tue Apr 15 17:39:56 2008
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// This class implements the "traditional" or "classic" PKZip encryption,
|
||||
/// which today is considered to be weak. On the other hand it is
|
||||
/// ubiquitous. This class is intended for use only by the DotNetZip
|
||||
/// library.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Most uses of the DotNetZip library will not involve direct calls into
|
||||
/// the ZipCrypto class. Instead, the ZipCrypto class is instantiated and
|
||||
/// used by the ZipEntry() class when encryption or decryption on an entry
|
||||
/// is employed. If for some reason you really wanted to use a weak
|
||||
/// encryption algorithm in some other application, you might use this
|
||||
/// library. But you would be much better off using one of the built-in
|
||||
/// strong encryption libraries in the .NET Framework, like the AES
|
||||
/// algorithm or SHA.
|
||||
/// </remarks>
|
||||
internal class ZipCrypto
|
||||
{
|
||||
/// <summary>
|
||||
/// The default constructor for ZipCrypto.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This class is intended for internal use by the library only. It's
|
||||
/// probably not useful to you. Seriously. Stop reading this
|
||||
/// documentation. It's a waste of your time. Go do something else.
|
||||
/// Check the football scores. Go get an ice cream with a friend.
|
||||
/// Seriously.
|
||||
/// </remarks>
|
||||
///
|
||||
private ZipCrypto() { }
|
||||
|
||||
public static ZipCrypto ForWrite(string password)
|
||||
{
|
||||
ZipCrypto z = new ZipCrypto();
|
||||
if (password == null)
|
||||
throw new BadPasswordException("This entry requires a password.");
|
||||
z.InitCipher(password);
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
public static ZipCrypto ForRead(string password, ZipEntry e)
|
||||
{
|
||||
System.IO.Stream s = e._archiveStream;
|
||||
e._WeakEncryptionHeader = new byte[12];
|
||||
byte[] eh = e._WeakEncryptionHeader;
|
||||
ZipCrypto z = new ZipCrypto();
|
||||
|
||||
if (password == null)
|
||||
throw new BadPasswordException("This entry requires a password.");
|
||||
|
||||
z.InitCipher(password);
|
||||
|
||||
ZipEntry.ReadWeakEncryptionHeader(s, eh);
|
||||
|
||||
// Decrypt the header. This has a side effect of "further initializing the
|
||||
// encryption keys" in the traditional zip encryption.
|
||||
byte[] DecryptedHeader = z.DecryptMessage(eh, eh.Length);
|
||||
|
||||
// CRC check
|
||||
// According to the pkzip spec, the final byte in the decrypted header
|
||||
// is the highest-order byte in the CRC. We check it here.
|
||||
if (DecryptedHeader[11] != (byte)((e._Crc32 >> 24) & 0xff))
|
||||
{
|
||||
// In the case that bit 3 of the general purpose bit flag is set to
|
||||
// indicate the presence of an 'Extended File Header' or a 'data
|
||||
// descriptor' (signature 0x08074b50), the last byte of the decrypted
|
||||
// header is sometimes compared with the high-order byte of the
|
||||
// lastmodified time, rather than the high-order byte of the CRC, to
|
||||
// verify the password.
|
||||
//
|
||||
// This is not documented in the PKWare Appnote.txt. It was
|
||||
// discovered this by analysis of the Crypt.c source file in the
|
||||
// InfoZip library http://www.info-zip.org/pub/infozip/
|
||||
//
|
||||
// The reason for this is that the CRC for a file cannot be known
|
||||
// until the entire contents of the file have been streamed. This
|
||||
// means a tool would have to read the file content TWICE in its
|
||||
// entirety in order to perform PKZIP encryption - once to compute
|
||||
// the CRC, and again to actually encrypt.
|
||||
//
|
||||
// This is so important for performance that using the timeblob as
|
||||
// the verification should be the standard practice for DotNetZip
|
||||
// when using PKZIP encryption. This implies that bit 3 must be
|
||||
// set. The downside is that some tools still cannot cope with ZIP
|
||||
// files that use bit 3. Therefore, DotNetZip DOES NOT force bit 3
|
||||
// when PKZIP encryption is in use, and instead, reads the stream
|
||||
// twice.
|
||||
//
|
||||
|
||||
if ((e._BitField & 0x0008) != 0x0008)
|
||||
{
|
||||
throw new BadPasswordException("The password did not match.");
|
||||
}
|
||||
else if (DecryptedHeader[11] != (byte)((e._TimeBlob >> 8) & 0xff))
|
||||
{
|
||||
throw new BadPasswordException("The password did not match.");
|
||||
}
|
||||
|
||||
// We have a good password.
|
||||
}
|
||||
else
|
||||
{
|
||||
// A-OK
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// From AppNote.txt:
|
||||
/// unsigned char decrypt_byte()
|
||||
/// local unsigned short temp
|
||||
/// temp :=- Key(2) | 2
|
||||
/// decrypt_byte := (temp * (temp ^ 1)) bitshift-right 8
|
||||
/// end decrypt_byte
|
||||
/// </summary>
|
||||
private byte MagicByte
|
||||
{
|
||||
get
|
||||
{
|
||||
UInt16 t = (UInt16)((UInt16)(_Keys[2] & 0xFFFF) | 2);
|
||||
return (byte)((t * (t ^ 1)) >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
// Decrypting:
|
||||
// From AppNote.txt:
|
||||
// loop for i from 0 to 11
|
||||
// C := buffer(i) ^ decrypt_byte()
|
||||
// update_keys(C)
|
||||
// buffer(i) := C
|
||||
// end loop
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Call this method on a cipher text to render the plaintext. You must
|
||||
/// first initialize the cipher with a call to InitCipher.
|
||||
/// </summary>
|
||||
///
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// var cipher = new ZipCrypto();
|
||||
/// cipher.InitCipher(Password);
|
||||
/// // Decrypt the header. This has a side effect of "further initializing the
|
||||
/// // encryption keys" in the traditional zip encryption.
|
||||
/// byte[] DecryptedMessage = cipher.DecryptMessage(EncryptedMessage);
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <param name="cipherText">The encrypted buffer.</param>
|
||||
/// <param name="length">
|
||||
/// The number of bytes to encrypt.
|
||||
/// Should be less than or equal to CipherText.Length.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>The plaintext.</returns>
|
||||
public byte[] DecryptMessage(byte[] cipherText, int length)
|
||||
{
|
||||
if (cipherText == null)
|
||||
throw new ArgumentNullException("cipherText");
|
||||
|
||||
if (length > cipherText.Length)
|
||||
throw new ArgumentOutOfRangeException("length",
|
||||
"Bad length during Decryption: the length parameter must be smaller than or equal to the size of the destination array.");
|
||||
|
||||
byte[] plainText = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
byte C = (byte)(cipherText[i] ^ MagicByte);
|
||||
UpdateKeys(C);
|
||||
plainText[i] = C;
|
||||
}
|
||||
return plainText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the converse of DecryptMessage. It encrypts the plaintext
|
||||
/// and produces a ciphertext.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="plainText">The plain text buffer.</param>
|
||||
///
|
||||
/// <param name="length">
|
||||
/// The number of bytes to encrypt.
|
||||
/// Should be less than or equal to plainText.Length.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>The ciphertext.</returns>
|
||||
public byte[] EncryptMessage(byte[] plainText, int length)
|
||||
{
|
||||
if (plainText == null)
|
||||
throw new ArgumentNullException("plaintext");
|
||||
|
||||
if (length > plainText.Length)
|
||||
throw new ArgumentOutOfRangeException("length",
|
||||
"Bad length during Encryption: The length parameter must be smaller than or equal to the size of the destination array.");
|
||||
|
||||
byte[] cipherText = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
byte C = plainText[i];
|
||||
cipherText[i] = (byte)(plainText[i] ^ MagicByte);
|
||||
UpdateKeys(C);
|
||||
}
|
||||
return cipherText;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This initializes the cipher with the given password.
|
||||
/// See AppNote.txt for details.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="passphrase">
|
||||
/// The passphrase for encrypting or decrypting with this cipher.
|
||||
/// </param>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <code>
|
||||
/// Step 1 - Initializing the encryption keys
|
||||
/// -----------------------------------------
|
||||
/// Start with these keys:
|
||||
/// Key(0) := 305419896 (0x12345678)
|
||||
/// Key(1) := 591751049 (0x23456789)
|
||||
/// Key(2) := 878082192 (0x34567890)
|
||||
///
|
||||
/// Then, initialize the keys with a password:
|
||||
///
|
||||
/// loop for i from 0 to length(password)-1
|
||||
/// update_keys(password(i))
|
||||
/// end loop
|
||||
///
|
||||
/// Where update_keys() is defined as:
|
||||
///
|
||||
/// update_keys(char):
|
||||
/// Key(0) := crc32(key(0),char)
|
||||
/// Key(1) := Key(1) + (Key(0) bitwiseAND 000000ffH)
|
||||
/// Key(1) := Key(1) * 134775813 + 1
|
||||
/// Key(2) := crc32(key(2),key(1) rightshift 24)
|
||||
/// end update_keys
|
||||
///
|
||||
/// Where crc32(old_crc,char) is a routine that given a CRC value and a
|
||||
/// character, returns an updated CRC value after applying the CRC-32
|
||||
/// algorithm described elsewhere in this document.
|
||||
///
|
||||
/// </code>
|
||||
///
|
||||
/// <para>
|
||||
/// After the keys are initialized, then you can use the cipher to
|
||||
/// encrypt the plaintext.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Essentially we encrypt the password with the keys, then discard the
|
||||
/// ciphertext for the password. This initializes the keys for later use.
|
||||
/// </para>
|
||||
///
|
||||
/// </remarks>
|
||||
public void InitCipher(string passphrase)
|
||||
{
|
||||
byte[] p = SharedUtilities.StringToByteArray(passphrase);
|
||||
for (int i = 0; i < passphrase.Length; i++)
|
||||
UpdateKeys(p[i]);
|
||||
}
|
||||
|
||||
|
||||
private void UpdateKeys(byte byteValue)
|
||||
{
|
||||
_Keys[0] = (UInt32)crc32.ComputeCrc32((int)_Keys[0], byteValue);
|
||||
_Keys[1] = _Keys[1] + (byte)_Keys[0];
|
||||
_Keys[1] = _Keys[1] * 0x08088405 + 1;
|
||||
_Keys[2] = (UInt32)crc32.ComputeCrc32((int)_Keys[2], (byte)(_Keys[1] >> 24));
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// The byte array representing the seed keys used.
|
||||
///// Get this after calling InitCipher. The 12 bytes represents
|
||||
///// what the zip spec calls the "EncryptionHeader".
|
||||
///// </summary>
|
||||
//public byte[] KeyHeader
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// byte[] result = new byte[12];
|
||||
// result[0] = (byte)(_Keys[0] & 0xff);
|
||||
// result[1] = (byte)((_Keys[0] >> 8) & 0xff);
|
||||
// result[2] = (byte)((_Keys[0] >> 16) & 0xff);
|
||||
// result[3] = (byte)((_Keys[0] >> 24) & 0xff);
|
||||
// result[4] = (byte)(_Keys[1] & 0xff);
|
||||
// result[5] = (byte)((_Keys[1] >> 8) & 0xff);
|
||||
// result[6] = (byte)((_Keys[1] >> 16) & 0xff);
|
||||
// result[7] = (byte)((_Keys[1] >> 24) & 0xff);
|
||||
// result[8] = (byte)(_Keys[2] & 0xff);
|
||||
// result[9] = (byte)((_Keys[2] >> 8) & 0xff);
|
||||
// result[10] = (byte)((_Keys[2] >> 16) & 0xff);
|
||||
// result[11] = (byte)((_Keys[2] >> 24) & 0xff);
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
|
||||
// private fields for the crypto stuff:
|
||||
private UInt32[] _Keys = { 0x12345678, 0x23456789, 0x34567890 };
|
||||
private Ionic.Crc.CRC32 crc32 = new Ionic.Crc.CRC32();
|
||||
|
||||
}
|
||||
|
||||
internal enum CryptoMode
|
||||
{
|
||||
Encrypt,
|
||||
Decrypt
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Stream for reading and concurrently decrypting data from a zip file,
|
||||
/// or for writing and concurrently encrypting data to a zip file.
|
||||
/// </summary>
|
||||
internal class ZipCipherStream : System.IO.Stream
|
||||
{
|
||||
private ZipCrypto _cipher;
|
||||
private System.IO.Stream _s;
|
||||
private CryptoMode _mode;
|
||||
|
||||
/// <summary> The constructor. </summary>
|
||||
/// <param name="s">The underlying stream</param>
|
||||
/// <param name="mode">To either encrypt or decrypt.</param>
|
||||
/// <param name="cipher">The pre-initialized ZipCrypto object.</param>
|
||||
public ZipCipherStream(System.IO.Stream s, ZipCrypto cipher, CryptoMode mode)
|
||||
: base()
|
||||
{
|
||||
_cipher = cipher;
|
||||
_s = s;
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (_mode == CryptoMode.Encrypt)
|
||||
throw new NotSupportedException("This stream does not encrypt via Read()");
|
||||
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer");
|
||||
|
||||
byte[] db = new byte[count];
|
||||
int n = _s.Read(db, 0, count);
|
||||
byte[] decrypted = _cipher.DecryptMessage(db, n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
buffer[offset + i] = decrypted[i];
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (_mode == CryptoMode.Decrypt)
|
||||
throw new NotSupportedException("This stream does not Decrypt via Write()");
|
||||
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer");
|
||||
|
||||
// workitem 7696
|
||||
if (count == 0) return;
|
||||
|
||||
byte[] plaintext = null;
|
||||
if (offset != 0)
|
||||
{
|
||||
plaintext = new byte[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
plaintext[i] = buffer[offset + i];
|
||||
}
|
||||
}
|
||||
else plaintext = buffer;
|
||||
|
||||
byte[] encrypted = _cipher.EncryptMessage(plaintext, count);
|
||||
_s.Write(encrypted, 0, encrypted.Length);
|
||||
}
|
||||
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return (_mode == CryptoMode.Decrypt); }
|
||||
}
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return (_mode == CryptoMode.Encrypt); }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
//throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
public override long Seek(long offset, System.IO.SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ZipCrypto.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2008, 2009, 2011 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-28 06:30:59>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module provides the implementation for "traditional" Zip encryption.
|
||||
//
|
||||
// Created Tue Apr 15 17:39:56 2008
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// This class implements the "traditional" or "classic" PKZip encryption,
|
||||
/// which today is considered to be weak. On the other hand it is
|
||||
/// ubiquitous. This class is intended for use only by the DotNetZip
|
||||
/// library.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// Most uses of the DotNetZip library will not involve direct calls into
|
||||
/// the ZipCrypto class. Instead, the ZipCrypto class is instantiated and
|
||||
/// used by the ZipEntry() class when encryption or decryption on an entry
|
||||
/// is employed. If for some reason you really wanted to use a weak
|
||||
/// encryption algorithm in some other application, you might use this
|
||||
/// library. But you would be much better off using one of the built-in
|
||||
/// strong encryption libraries in the .NET Framework, like the AES
|
||||
/// algorithm or SHA.
|
||||
/// </remarks>
|
||||
internal class ZipCrypto
|
||||
{
|
||||
/// <summary>
|
||||
/// The default constructor for ZipCrypto.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This class is intended for internal use by the library only. It's
|
||||
/// probably not useful to you. Seriously. Stop reading this
|
||||
/// documentation. It's a waste of your time. Go do something else.
|
||||
/// Check the football scores. Go get an ice cream with a friend.
|
||||
/// Seriously.
|
||||
/// </remarks>
|
||||
///
|
||||
private ZipCrypto() { }
|
||||
|
||||
public static ZipCrypto ForWrite(string password)
|
||||
{
|
||||
ZipCrypto z = new ZipCrypto();
|
||||
if (password == null)
|
||||
throw new BadPasswordException("This entry requires a password.");
|
||||
z.InitCipher(password);
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
public static ZipCrypto ForRead(string password, ZipEntry e)
|
||||
{
|
||||
System.IO.Stream s = e._archiveStream;
|
||||
e._WeakEncryptionHeader = new byte[12];
|
||||
byte[] eh = e._WeakEncryptionHeader;
|
||||
ZipCrypto z = new ZipCrypto();
|
||||
|
||||
if (password == null)
|
||||
throw new BadPasswordException("This entry requires a password.");
|
||||
|
||||
z.InitCipher(password);
|
||||
|
||||
ZipEntry.ReadWeakEncryptionHeader(s, eh);
|
||||
|
||||
// Decrypt the header. This has a side effect of "further initializing the
|
||||
// encryption keys" in the traditional zip encryption.
|
||||
byte[] DecryptedHeader = z.DecryptMessage(eh, eh.Length);
|
||||
|
||||
// CRC check
|
||||
// According to the pkzip spec, the final byte in the decrypted header
|
||||
// is the highest-order byte in the CRC. We check it here.
|
||||
if (DecryptedHeader[11] != (byte)((e._Crc32 >> 24) & 0xff))
|
||||
{
|
||||
// In the case that bit 3 of the general purpose bit flag is set to
|
||||
// indicate the presence of an 'Extended File Header' or a 'data
|
||||
// descriptor' (signature 0x08074b50), the last byte of the decrypted
|
||||
// header is sometimes compared with the high-order byte of the
|
||||
// lastmodified time, rather than the high-order byte of the CRC, to
|
||||
// verify the password.
|
||||
//
|
||||
// This is not documented in the PKWare Appnote.txt. It was
|
||||
// discovered this by analysis of the Crypt.c source file in the
|
||||
// InfoZip library http://www.info-zip.org/pub/infozip/
|
||||
//
|
||||
// The reason for this is that the CRC for a file cannot be known
|
||||
// until the entire contents of the file have been streamed. This
|
||||
// means a tool would have to read the file content TWICE in its
|
||||
// entirety in order to perform PKZIP encryption - once to compute
|
||||
// the CRC, and again to actually encrypt.
|
||||
//
|
||||
// This is so important for performance that using the timeblob as
|
||||
// the verification should be the standard practice for DotNetZip
|
||||
// when using PKZIP encryption. This implies that bit 3 must be
|
||||
// set. The downside is that some tools still cannot cope with ZIP
|
||||
// files that use bit 3. Therefore, DotNetZip DOES NOT force bit 3
|
||||
// when PKZIP encryption is in use, and instead, reads the stream
|
||||
// twice.
|
||||
//
|
||||
|
||||
if ((e._BitField & 0x0008) != 0x0008)
|
||||
{
|
||||
throw new BadPasswordException("The password did not match.");
|
||||
}
|
||||
else if (DecryptedHeader[11] != (byte)((e._TimeBlob >> 8) & 0xff))
|
||||
{
|
||||
throw new BadPasswordException("The password did not match.");
|
||||
}
|
||||
|
||||
// We have a good password.
|
||||
}
|
||||
else
|
||||
{
|
||||
// A-OK
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// From AppNote.txt:
|
||||
/// unsigned char decrypt_byte()
|
||||
/// local unsigned short temp
|
||||
/// temp :=- Key(2) | 2
|
||||
/// decrypt_byte := (temp * (temp ^ 1)) bitshift-right 8
|
||||
/// end decrypt_byte
|
||||
/// </summary>
|
||||
private byte MagicByte
|
||||
{
|
||||
get
|
||||
{
|
||||
UInt16 t = (UInt16)((UInt16)(_Keys[2] & 0xFFFF) | 2);
|
||||
return (byte)((t * (t ^ 1)) >> 8);
|
||||
}
|
||||
}
|
||||
|
||||
// Decrypting:
|
||||
// From AppNote.txt:
|
||||
// loop for i from 0 to 11
|
||||
// C := buffer(i) ^ decrypt_byte()
|
||||
// update_keys(C)
|
||||
// buffer(i) := C
|
||||
// end loop
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Call this method on a cipher text to render the plaintext. You must
|
||||
/// first initialize the cipher with a call to InitCipher.
|
||||
/// </summary>
|
||||
///
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// var cipher = new ZipCrypto();
|
||||
/// cipher.InitCipher(Password);
|
||||
/// // Decrypt the header. This has a side effect of "further initializing the
|
||||
/// // encryption keys" in the traditional zip encryption.
|
||||
/// byte[] DecryptedMessage = cipher.DecryptMessage(EncryptedMessage);
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <param name="cipherText">The encrypted buffer.</param>
|
||||
/// <param name="length">
|
||||
/// The number of bytes to encrypt.
|
||||
/// Should be less than or equal to CipherText.Length.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>The plaintext.</returns>
|
||||
public byte[] DecryptMessage(byte[] cipherText, int length)
|
||||
{
|
||||
if (cipherText == null)
|
||||
throw new ArgumentNullException("cipherText");
|
||||
|
||||
if (length > cipherText.Length)
|
||||
throw new ArgumentOutOfRangeException("length",
|
||||
"Bad length during Decryption: the length parameter must be smaller than or equal to the size of the destination array.");
|
||||
|
||||
byte[] plainText = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
byte C = (byte)(cipherText[i] ^ MagicByte);
|
||||
UpdateKeys(C);
|
||||
plainText[i] = C;
|
||||
}
|
||||
return plainText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the converse of DecryptMessage. It encrypts the plaintext
|
||||
/// and produces a ciphertext.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="plainText">The plain text buffer.</param>
|
||||
///
|
||||
/// <param name="length">
|
||||
/// The number of bytes to encrypt.
|
||||
/// Should be less than or equal to plainText.Length.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>The ciphertext.</returns>
|
||||
public byte[] EncryptMessage(byte[] plainText, int length)
|
||||
{
|
||||
if (plainText == null)
|
||||
throw new ArgumentNullException("plaintext");
|
||||
|
||||
if (length > plainText.Length)
|
||||
throw new ArgumentOutOfRangeException("length",
|
||||
"Bad length during Encryption: The length parameter must be smaller than or equal to the size of the destination array.");
|
||||
|
||||
byte[] cipherText = new byte[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
byte C = plainText[i];
|
||||
cipherText[i] = (byte)(plainText[i] ^ MagicByte);
|
||||
UpdateKeys(C);
|
||||
}
|
||||
return cipherText;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This initializes the cipher with the given password.
|
||||
/// See AppNote.txt for details.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="passphrase">
|
||||
/// The passphrase for encrypting or decrypting with this cipher.
|
||||
/// </param>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <code>
|
||||
/// Step 1 - Initializing the encryption keys
|
||||
/// -----------------------------------------
|
||||
/// Start with these keys:
|
||||
/// Key(0) := 305419896 (0x12345678)
|
||||
/// Key(1) := 591751049 (0x23456789)
|
||||
/// Key(2) := 878082192 (0x34567890)
|
||||
///
|
||||
/// Then, initialize the keys with a password:
|
||||
///
|
||||
/// loop for i from 0 to length(password)-1
|
||||
/// update_keys(password(i))
|
||||
/// end loop
|
||||
///
|
||||
/// Where update_keys() is defined as:
|
||||
///
|
||||
/// update_keys(char):
|
||||
/// Key(0) := crc32(key(0),char)
|
||||
/// Key(1) := Key(1) + (Key(0) bitwiseAND 000000ffH)
|
||||
/// Key(1) := Key(1) * 134775813 + 1
|
||||
/// Key(2) := crc32(key(2),key(1) rightshift 24)
|
||||
/// end update_keys
|
||||
///
|
||||
/// Where crc32(old_crc,char) is a routine that given a CRC value and a
|
||||
/// character, returns an updated CRC value after applying the CRC-32
|
||||
/// algorithm described elsewhere in this document.
|
||||
///
|
||||
/// </code>
|
||||
///
|
||||
/// <para>
|
||||
/// After the keys are initialized, then you can use the cipher to
|
||||
/// encrypt the plaintext.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Essentially we encrypt the password with the keys, then discard the
|
||||
/// ciphertext for the password. This initializes the keys for later use.
|
||||
/// </para>
|
||||
///
|
||||
/// </remarks>
|
||||
public void InitCipher(string passphrase)
|
||||
{
|
||||
byte[] p = SharedUtilities.StringToByteArray(passphrase);
|
||||
for (int i = 0; i < passphrase.Length; i++)
|
||||
UpdateKeys(p[i]);
|
||||
}
|
||||
|
||||
|
||||
private void UpdateKeys(byte byteValue)
|
||||
{
|
||||
_Keys[0] = (UInt32)crc32.ComputeCrc32((int)_Keys[0], byteValue);
|
||||
_Keys[1] = _Keys[1] + (byte)_Keys[0];
|
||||
_Keys[1] = _Keys[1] * 0x08088405 + 1;
|
||||
_Keys[2] = (UInt32)crc32.ComputeCrc32((int)_Keys[2], (byte)(_Keys[1] >> 24));
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// The byte array representing the seed keys used.
|
||||
///// Get this after calling InitCipher. The 12 bytes represents
|
||||
///// what the zip spec calls the "EncryptionHeader".
|
||||
///// </summary>
|
||||
//public byte[] KeyHeader
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// byte[] result = new byte[12];
|
||||
// result[0] = (byte)(_Keys[0] & 0xff);
|
||||
// result[1] = (byte)((_Keys[0] >> 8) & 0xff);
|
||||
// result[2] = (byte)((_Keys[0] >> 16) & 0xff);
|
||||
// result[3] = (byte)((_Keys[0] >> 24) & 0xff);
|
||||
// result[4] = (byte)(_Keys[1] & 0xff);
|
||||
// result[5] = (byte)((_Keys[1] >> 8) & 0xff);
|
||||
// result[6] = (byte)((_Keys[1] >> 16) & 0xff);
|
||||
// result[7] = (byte)((_Keys[1] >> 24) & 0xff);
|
||||
// result[8] = (byte)(_Keys[2] & 0xff);
|
||||
// result[9] = (byte)((_Keys[2] >> 8) & 0xff);
|
||||
// result[10] = (byte)((_Keys[2] >> 16) & 0xff);
|
||||
// result[11] = (byte)((_Keys[2] >> 24) & 0xff);
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
|
||||
// private fields for the crypto stuff:
|
||||
private UInt32[] _Keys = { 0x12345678, 0x23456789, 0x34567890 };
|
||||
private Ionic.Crc.CRC32 crc32 = new Ionic.Crc.CRC32();
|
||||
|
||||
}
|
||||
|
||||
internal enum CryptoMode
|
||||
{
|
||||
Encrypt,
|
||||
Decrypt
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Stream for reading and concurrently decrypting data from a zip file,
|
||||
/// or for writing and concurrently encrypting data to a zip file.
|
||||
/// </summary>
|
||||
internal class ZipCipherStream : System.IO.Stream
|
||||
{
|
||||
private ZipCrypto _cipher;
|
||||
private System.IO.Stream _s;
|
||||
private CryptoMode _mode;
|
||||
|
||||
/// <summary> The constructor. </summary>
|
||||
/// <param name="s">The underlying stream</param>
|
||||
/// <param name="mode">To either encrypt or decrypt.</param>
|
||||
/// <param name="cipher">The pre-initialized ZipCrypto object.</param>
|
||||
public ZipCipherStream(System.IO.Stream s, ZipCrypto cipher, CryptoMode mode)
|
||||
: base()
|
||||
{
|
||||
_cipher = cipher;
|
||||
_s = s;
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (_mode == CryptoMode.Encrypt)
|
||||
throw new NotSupportedException("This stream does not encrypt via Read()");
|
||||
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer");
|
||||
|
||||
byte[] db = new byte[count];
|
||||
int n = _s.Read(db, 0, count);
|
||||
byte[] decrypted = _cipher.DecryptMessage(db, n);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
buffer[offset + i] = decrypted[i];
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (_mode == CryptoMode.Decrypt)
|
||||
throw new NotSupportedException("This stream does not Decrypt via Write()");
|
||||
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer");
|
||||
|
||||
// workitem 7696
|
||||
if (count == 0) return;
|
||||
|
||||
byte[] plaintext = null;
|
||||
if (offset != 0)
|
||||
{
|
||||
plaintext = new byte[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
plaintext[i] = buffer[offset + i];
|
||||
}
|
||||
}
|
||||
else plaintext = buffer;
|
||||
|
||||
byte[] encrypted = _cipher.EncryptMessage(plaintext, count);
|
||||
_s.Write(encrypted, 0, encrypted.Length);
|
||||
}
|
||||
|
||||
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return (_mode == CryptoMode.Decrypt); }
|
||||
}
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return (_mode == CryptoMode.Encrypt); }
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
//throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override long Length
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public override long Position
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
public override long Seek(long offset, System.IO.SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,381 +1,381 @@
|
||||
// ZipDirEntry.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2006-2011 Dino Chiesa .
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-11 12:03:03>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines members of the ZipEntry class for reading the
|
||||
// Zip file central directory.
|
||||
//
|
||||
// Created: Tue, 27 Mar 2007 15:30
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
|
||||
partial class ZipEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// True if the referenced entry is a directory.
|
||||
/// </summary>
|
||||
internal bool AttributesIndicateDirectory
|
||||
{
|
||||
get { return ((_InternalFileAttrs == 0) && ((_ExternalFileAttrs & 0x0010) == 0x0010)); }
|
||||
}
|
||||
|
||||
|
||||
internal void ResetDirEntry()
|
||||
{
|
||||
// __FileDataPosition is the position of the file data for an entry.
|
||||
// It is _RelativeOffsetOfLocalHeader + size of local header.
|
||||
|
||||
// We cannot know the __FileDataPosition until we read the local
|
||||
// header.
|
||||
|
||||
// The local header is not necessarily the same length as the record
|
||||
// in the central directory.
|
||||
|
||||
// Set to -1, to indicate we need to read this later.
|
||||
this.__FileDataPosition = -1;
|
||||
|
||||
// set _LengthOfHeader to 0, to indicate we need to read later.
|
||||
this._LengthOfHeader = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a human-readable string with information about the ZipEntry.
|
||||
/// </summary>
|
||||
public string Info
|
||||
{
|
||||
get
|
||||
{
|
||||
var builder = new System.Text.StringBuilder();
|
||||
builder
|
||||
.Append(string.Format(" ZipEntry: {0}\n", this.FileName))
|
||||
.Append(string.Format(" Version Made By: {0}\n", this._VersionMadeBy))
|
||||
.Append(string.Format(" Needed to extract: {0}\n", this.VersionNeeded));
|
||||
|
||||
if (this._IsDirectory)
|
||||
builder.Append(" Entry type: directory\n");
|
||||
else
|
||||
{
|
||||
builder.Append(string.Format(" File type: {0}\n", this._IsText? "text":"binary"))
|
||||
.Append(string.Format(" Compression: {0}\n", this.CompressionMethod))
|
||||
.Append(string.Format(" Compressed: 0x{0:X}\n", this.CompressedSize))
|
||||
.Append(string.Format(" Uncompressed: 0x{0:X}\n", this.UncompressedSize))
|
||||
.Append(string.Format(" CRC32: 0x{0:X8}\n", this._Crc32));
|
||||
}
|
||||
builder.Append(string.Format(" Disk Number: {0}\n", this._diskNumber));
|
||||
if (this._RelativeOffsetOfLocalHeader > 0xFFFFFFFF)
|
||||
builder
|
||||
.Append(string.Format(" Relative Offset: 0x{0:X16}\n", this._RelativeOffsetOfLocalHeader));
|
||||
else
|
||||
builder
|
||||
.Append(string.Format(" Relative Offset: 0x{0:X8}\n", this._RelativeOffsetOfLocalHeader));
|
||||
|
||||
builder
|
||||
.Append(string.Format(" Bit Field: 0x{0:X4}\n", this._BitField))
|
||||
.Append(string.Format(" Encrypted?: {0}\n", this._sourceIsEncrypted))
|
||||
.Append(string.Format(" Timeblob: 0x{0:X8}\n", this._TimeBlob))
|
||||
.Append(string.Format(" Time: {0}\n", Ionic.Zip.SharedUtilities.PackedToDateTime(this._TimeBlob)));
|
||||
|
||||
builder.Append(string.Format(" Is Zip64?: {0}\n", this._InputUsesZip64));
|
||||
if (!string.IsNullOrEmpty(this._Comment))
|
||||
{
|
||||
builder.Append(string.Format(" Comment: {0}\n", this._Comment));
|
||||
}
|
||||
builder.Append("\n");
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// workitem 10330
|
||||
private class CopyHelper
|
||||
{
|
||||
private static System.Text.RegularExpressions.Regex re =
|
||||
new System.Text.RegularExpressions.Regex(" \\(copy (\\d+)\\)$");
|
||||
|
||||
private static int callCount = 0;
|
||||
|
||||
internal static string AppendCopyToFileName(string f)
|
||||
{
|
||||
callCount++;
|
||||
if (callCount > 25)
|
||||
throw new OverflowException("overflow while creating filename");
|
||||
|
||||
int n = 1;
|
||||
int r = f.LastIndexOf(".");
|
||||
|
||||
if (r == -1)
|
||||
{
|
||||
// there is no extension
|
||||
System.Text.RegularExpressions.Match m = re.Match(f);
|
||||
if (m.Success)
|
||||
{
|
||||
n = Int32.Parse(m.Groups[1].Value) + 1;
|
||||
string copy = String.Format(" (copy {0})", n);
|
||||
f = f.Substring(0, m.Index) + copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
string copy = String.Format(" (copy {0})", n);
|
||||
f = f + copy;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.Console.WriteLine("HasExtension");
|
||||
System.Text.RegularExpressions.Match m = re.Match(f.Substring(0, r));
|
||||
if (m.Success)
|
||||
{
|
||||
n = Int32.Parse(m.Groups[1].Value) + 1;
|
||||
string copy = String.Format(" (copy {0})", n);
|
||||
f = f.Substring(0, m.Index) + copy + f.Substring(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
string copy = String.Format(" (copy {0})", n);
|
||||
f = f.Substring(0, r) + copy + f.Substring(r);
|
||||
}
|
||||
|
||||
//System.Console.WriteLine("returning f({0})", f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads one entry from the zip directory structure in the zip file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="zf">
|
||||
/// The zipfile for which a directory entry will be read. From this param, the
|
||||
/// method gets the ReadStream and the expected text encoding
|
||||
/// (ProvisionalAlternateEncoding) which is used if the entry is not marked
|
||||
/// UTF-8.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="previouslySeen">
|
||||
/// a list of previously seen entry names; used to prevent duplicates.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>the entry read from the archive.</returns>
|
||||
internal static ZipEntry ReadDirEntry(ZipFile zf,
|
||||
Dictionary<String,Object> previouslySeen)
|
||||
{
|
||||
System.IO.Stream s = zf.ReadStream;
|
||||
System.Text.Encoding expectedEncoding = (zf.AlternateEncodingUsage == ZipOption.Always)
|
||||
? zf.AlternateEncoding
|
||||
: ZipFile.DefaultEncoding;
|
||||
|
||||
int signature = Ionic.Zip.SharedUtilities.ReadSignature(s);
|
||||
// return null if this is not a local file header signature
|
||||
if (IsNotValidZipDirEntrySig(signature))
|
||||
{
|
||||
s.Seek(-4, System.IO.SeekOrigin.Current);
|
||||
// workitem 10178
|
||||
Ionic.Zip.SharedUtilities.Workaround_Ladybug318918(s);
|
||||
|
||||
// Getting "not a ZipDirEntry signature" here is not always wrong or an
|
||||
// error. This can happen when walking through a zipfile. After the
|
||||
// last ZipDirEntry, we expect to read an
|
||||
// EndOfCentralDirectorySignature. When we get this is how we know
|
||||
// we've reached the end of the central directory.
|
||||
if (signature != ZipConstants.EndOfCentralDirectorySignature &&
|
||||
signature != ZipConstants.Zip64EndOfCentralDirectoryRecordSignature &&
|
||||
signature != ZipConstants.ZipEntrySignature // workitem 8299
|
||||
)
|
||||
{
|
||||
throw new BadReadException(String.Format(" Bad signature (0x{0:X8}) at position 0x{1:X8}", signature, s.Position));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int bytesRead = 42 + 4;
|
||||
byte[] block = new byte[42];
|
||||
int n = s.Read(block, 0, block.Length);
|
||||
if (n != block.Length) return null;
|
||||
|
||||
int i = 0;
|
||||
ZipEntry zde = new ZipEntry();
|
||||
zde.AlternateEncoding = expectedEncoding;
|
||||
zde._Source = ZipEntrySource.ZipFile;
|
||||
zde._container = new ZipContainer(zf);
|
||||
|
||||
unchecked
|
||||
{
|
||||
zde._VersionMadeBy = (short)(block[i++] + block[i++] * 256);
|
||||
zde._VersionNeeded = (short)(block[i++] + block[i++] * 256);
|
||||
zde._BitField = (short)(block[i++] + block[i++] * 256);
|
||||
zde._CompressionMethod = (Int16)(block[i++] + block[i++] * 256);
|
||||
zde._TimeBlob = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
|
||||
zde._LastModified = Ionic.Zip.SharedUtilities.PackedToDateTime(zde._TimeBlob);
|
||||
zde._timestamp |= ZipEntryTimestamp.DOS;
|
||||
|
||||
zde._Crc32 = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
|
||||
zde._CompressedSize = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
|
||||
zde._UncompressedSize = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
|
||||
}
|
||||
|
||||
// preserve
|
||||
zde._CompressionMethod_FromZipFile = zde._CompressionMethod;
|
||||
|
||||
zde._filenameLength = (short)(block[i++] + block[i++] * 256);
|
||||
zde._extraFieldLength = (short)(block[i++] + block[i++] * 256);
|
||||
zde._commentLength = (short)(block[i++] + block[i++] * 256);
|
||||
zde._diskNumber = (UInt32)(block[i++] + block[i++] * 256);
|
||||
|
||||
zde._InternalFileAttrs = (short)(block[i++] + block[i++] * 256);
|
||||
zde._ExternalFileAttrs = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
|
||||
|
||||
zde._RelativeOffsetOfLocalHeader = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
|
||||
|
||||
// workitem 7801
|
||||
zde.IsText = ((zde._InternalFileAttrs & 0x01) == 0x01);
|
||||
|
||||
block = new byte[zde._filenameLength];
|
||||
n = s.Read(block, 0, block.Length);
|
||||
bytesRead += n;
|
||||
if ((zde._BitField & 0x0800) == 0x0800)
|
||||
{
|
||||
// UTF-8 is in use
|
||||
zde._FileNameInArchive = Ionic.Zip.SharedUtilities.Utf8StringFromBuffer(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
zde._FileNameInArchive = Ionic.Zip.SharedUtilities.StringFromBuffer(block, expectedEncoding);
|
||||
}
|
||||
|
||||
// workitem 10330
|
||||
// insure unique entry names
|
||||
while (previouslySeen.ContainsKey(zde._FileNameInArchive))
|
||||
{
|
||||
zde._FileNameInArchive = CopyHelper.AppendCopyToFileName(zde._FileNameInArchive);
|
||||
zde._metadataChanged = true;
|
||||
}
|
||||
|
||||
if (zde.AttributesIndicateDirectory)
|
||||
zde.MarkAsDirectory(); // may append a slash to filename if nec.
|
||||
// workitem 6898
|
||||
else if (zde._FileNameInArchive.EndsWith("/")) zde.MarkAsDirectory();
|
||||
|
||||
zde._CompressedFileDataSize = zde._CompressedSize;
|
||||
if ((zde._BitField & 0x01) == 0x01)
|
||||
{
|
||||
// this may change after processing the Extra field
|
||||
zde._Encryption_FromZipFile = zde._Encryption =
|
||||
EncryptionAlgorithm.PkzipWeak;
|
||||
zde._sourceIsEncrypted = true;
|
||||
}
|
||||
|
||||
if (zde._extraFieldLength > 0)
|
||||
{
|
||||
zde._InputUsesZip64 = (zde._CompressedSize == 0xFFFFFFFF ||
|
||||
zde._UncompressedSize == 0xFFFFFFFF ||
|
||||
zde._RelativeOffsetOfLocalHeader == 0xFFFFFFFF);
|
||||
|
||||
// Console.WriteLine(" Input uses Z64?: {0}", zde._InputUsesZip64);
|
||||
|
||||
bytesRead += zde.ProcessExtraField(s, zde._extraFieldLength);
|
||||
zde._CompressedFileDataSize = zde._CompressedSize;
|
||||
}
|
||||
|
||||
// we've processed the extra field, so we know the encryption method is set now.
|
||||
if (zde._Encryption == EncryptionAlgorithm.PkzipWeak)
|
||||
{
|
||||
// the "encryption header" of 12 bytes precedes the file data
|
||||
zde._CompressedFileDataSize -= 12;
|
||||
}
|
||||
#if AESCRYPTO
|
||||
else if (zde.Encryption == EncryptionAlgorithm.WinZipAes128 ||
|
||||
zde.Encryption == EncryptionAlgorithm.WinZipAes256)
|
||||
{
|
||||
zde._CompressedFileDataSize = zde.CompressedSize -
|
||||
(ZipEntry.GetLengthOfCryptoHeaderBytes(zde.Encryption) + 10);
|
||||
zde._LengthOfTrailer = 10;
|
||||
}
|
||||
#endif
|
||||
|
||||
// tally the trailing descriptor
|
||||
if ((zde._BitField & 0x0008) == 0x0008)
|
||||
{
|
||||
// sig, CRC, Comp and Uncomp sizes
|
||||
if (zde._InputUsesZip64)
|
||||
zde._LengthOfTrailer += 24;
|
||||
else
|
||||
zde._LengthOfTrailer += 16;
|
||||
}
|
||||
|
||||
// workitem 12744
|
||||
zde.AlternateEncoding = ((zde._BitField & 0x0800) == 0x0800)
|
||||
? System.Text.Encoding.UTF8
|
||||
:expectedEncoding;
|
||||
|
||||
zde.AlternateEncodingUsage = ZipOption.Always;
|
||||
|
||||
if (zde._commentLength > 0)
|
||||
{
|
||||
block = new byte[zde._commentLength];
|
||||
n = s.Read(block, 0, block.Length);
|
||||
bytesRead += n;
|
||||
if ((zde._BitField & 0x0800) == 0x0800)
|
||||
{
|
||||
// UTF-8 is in use
|
||||
zde._Comment = Ionic.Zip.SharedUtilities.Utf8StringFromBuffer(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
zde._Comment = Ionic.Zip.SharedUtilities.StringFromBuffer(block, expectedEncoding);
|
||||
}
|
||||
}
|
||||
//zde._LengthOfDirEntry = bytesRead;
|
||||
return zde;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the passed-in value is a valid signature for a ZipDirEntry.
|
||||
/// </summary>
|
||||
/// <param name="signature">the candidate 4-byte signature value.</param>
|
||||
/// <returns>true, if the signature is valid according to the PKWare spec.</returns>
|
||||
internal static bool IsNotValidZipDirEntrySig(int signature)
|
||||
{
|
||||
return (signature != ZipConstants.ZipDirEntrySignature);
|
||||
}
|
||||
|
||||
|
||||
private Int16 _VersionMadeBy;
|
||||
private Int16 _InternalFileAttrs;
|
||||
private Int32 _ExternalFileAttrs;
|
||||
|
||||
//private Int32 _LengthOfDirEntry;
|
||||
private Int16 _filenameLength;
|
||||
private Int16 _extraFieldLength;
|
||||
private Int16 _commentLength;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// ZipDirEntry.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2006-2011 Dino Chiesa .
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-11 12:03:03>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines members of the ZipEntry class for reading the
|
||||
// Zip file central directory.
|
||||
//
|
||||
// Created: Tue, 27 Mar 2007 15:30
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
|
||||
partial class ZipEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// True if the referenced entry is a directory.
|
||||
/// </summary>
|
||||
internal bool AttributesIndicateDirectory
|
||||
{
|
||||
get { return ((_InternalFileAttrs == 0) && ((_ExternalFileAttrs & 0x0010) == 0x0010)); }
|
||||
}
|
||||
|
||||
|
||||
internal void ResetDirEntry()
|
||||
{
|
||||
// __FileDataPosition is the position of the file data for an entry.
|
||||
// It is _RelativeOffsetOfLocalHeader + size of local header.
|
||||
|
||||
// We cannot know the __FileDataPosition until we read the local
|
||||
// header.
|
||||
|
||||
// The local header is not necessarily the same length as the record
|
||||
// in the central directory.
|
||||
|
||||
// Set to -1, to indicate we need to read this later.
|
||||
this.__FileDataPosition = -1;
|
||||
|
||||
// set _LengthOfHeader to 0, to indicate we need to read later.
|
||||
this._LengthOfHeader = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides a human-readable string with information about the ZipEntry.
|
||||
/// </summary>
|
||||
public string Info
|
||||
{
|
||||
get
|
||||
{
|
||||
var builder = new System.Text.StringBuilder();
|
||||
builder
|
||||
.Append(string.Format(" ZipEntry: {0}\n", this.FileName))
|
||||
.Append(string.Format(" Version Made By: {0}\n", this._VersionMadeBy))
|
||||
.Append(string.Format(" Needed to extract: {0}\n", this.VersionNeeded));
|
||||
|
||||
if (this._IsDirectory)
|
||||
builder.Append(" Entry type: directory\n");
|
||||
else
|
||||
{
|
||||
builder.Append(string.Format(" File type: {0}\n", this._IsText? "text":"binary"))
|
||||
.Append(string.Format(" Compression: {0}\n", this.CompressionMethod))
|
||||
.Append(string.Format(" Compressed: 0x{0:X}\n", this.CompressedSize))
|
||||
.Append(string.Format(" Uncompressed: 0x{0:X}\n", this.UncompressedSize))
|
||||
.Append(string.Format(" CRC32: 0x{0:X8}\n", this._Crc32));
|
||||
}
|
||||
builder.Append(string.Format(" Disk Number: {0}\n", this._diskNumber));
|
||||
if (this._RelativeOffsetOfLocalHeader > 0xFFFFFFFF)
|
||||
builder
|
||||
.Append(string.Format(" Relative Offset: 0x{0:X16}\n", this._RelativeOffsetOfLocalHeader));
|
||||
else
|
||||
builder
|
||||
.Append(string.Format(" Relative Offset: 0x{0:X8}\n", this._RelativeOffsetOfLocalHeader));
|
||||
|
||||
builder
|
||||
.Append(string.Format(" Bit Field: 0x{0:X4}\n", this._BitField))
|
||||
.Append(string.Format(" Encrypted?: {0}\n", this._sourceIsEncrypted))
|
||||
.Append(string.Format(" Timeblob: 0x{0:X8}\n", this._TimeBlob))
|
||||
.Append(string.Format(" Time: {0}\n", Ionic.Zip.SharedUtilities.PackedToDateTime(this._TimeBlob)));
|
||||
|
||||
builder.Append(string.Format(" Is Zip64?: {0}\n", this._InputUsesZip64));
|
||||
if (!string.IsNullOrEmpty(this._Comment))
|
||||
{
|
||||
builder.Append(string.Format(" Comment: {0}\n", this._Comment));
|
||||
}
|
||||
builder.Append("\n");
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// workitem 10330
|
||||
private class CopyHelper
|
||||
{
|
||||
private static System.Text.RegularExpressions.Regex re =
|
||||
new System.Text.RegularExpressions.Regex(" \\(copy (\\d+)\\)$");
|
||||
|
||||
private static int callCount = 0;
|
||||
|
||||
internal static string AppendCopyToFileName(string f)
|
||||
{
|
||||
callCount++;
|
||||
if (callCount > 25)
|
||||
throw new OverflowException("overflow while creating filename");
|
||||
|
||||
int n = 1;
|
||||
int r = f.LastIndexOf(".");
|
||||
|
||||
if (r == -1)
|
||||
{
|
||||
// there is no extension
|
||||
System.Text.RegularExpressions.Match m = re.Match(f);
|
||||
if (m.Success)
|
||||
{
|
||||
n = Int32.Parse(m.Groups[1].Value) + 1;
|
||||
string copy = String.Format(" (copy {0})", n);
|
||||
f = f.Substring(0, m.Index) + copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
string copy = String.Format(" (copy {0})", n);
|
||||
f = f + copy;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.Console.WriteLine("HasExtension");
|
||||
System.Text.RegularExpressions.Match m = re.Match(f.Substring(0, r));
|
||||
if (m.Success)
|
||||
{
|
||||
n = Int32.Parse(m.Groups[1].Value) + 1;
|
||||
string copy = String.Format(" (copy {0})", n);
|
||||
f = f.Substring(0, m.Index) + copy + f.Substring(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
string copy = String.Format(" (copy {0})", n);
|
||||
f = f.Substring(0, r) + copy + f.Substring(r);
|
||||
}
|
||||
|
||||
//System.Console.WriteLine("returning f({0})", f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reads one entry from the zip directory structure in the zip file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <param name="zf">
|
||||
/// The zipfile for which a directory entry will be read. From this param, the
|
||||
/// method gets the ReadStream and the expected text encoding
|
||||
/// (ProvisionalAlternateEncoding) which is used if the entry is not marked
|
||||
/// UTF-8.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="previouslySeen">
|
||||
/// a list of previously seen entry names; used to prevent duplicates.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>the entry read from the archive.</returns>
|
||||
internal static ZipEntry ReadDirEntry(ZipFile zf,
|
||||
Dictionary<String,Object> previouslySeen)
|
||||
{
|
||||
System.IO.Stream s = zf.ReadStream;
|
||||
System.Text.Encoding expectedEncoding = (zf.AlternateEncodingUsage == ZipOption.Always)
|
||||
? zf.AlternateEncoding
|
||||
: ZipFile.DefaultEncoding;
|
||||
|
||||
int signature = Ionic.Zip.SharedUtilities.ReadSignature(s);
|
||||
// return null if this is not a local file header signature
|
||||
if (IsNotValidZipDirEntrySig(signature))
|
||||
{
|
||||
s.Seek(-4, System.IO.SeekOrigin.Current);
|
||||
// workitem 10178
|
||||
Ionic.Zip.SharedUtilities.Workaround_Ladybug318918(s);
|
||||
|
||||
// Getting "not a ZipDirEntry signature" here is not always wrong or an
|
||||
// error. This can happen when walking through a zipfile. After the
|
||||
// last ZipDirEntry, we expect to read an
|
||||
// EndOfCentralDirectorySignature. When we get this is how we know
|
||||
// we've reached the end of the central directory.
|
||||
if (signature != ZipConstants.EndOfCentralDirectorySignature &&
|
||||
signature != ZipConstants.Zip64EndOfCentralDirectoryRecordSignature &&
|
||||
signature != ZipConstants.ZipEntrySignature // workitem 8299
|
||||
)
|
||||
{
|
||||
throw new BadReadException(String.Format(" Bad signature (0x{0:X8}) at position 0x{1:X8}", signature, s.Position));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
int bytesRead = 42 + 4;
|
||||
byte[] block = new byte[42];
|
||||
int n = s.Read(block, 0, block.Length);
|
||||
if (n != block.Length) return null;
|
||||
|
||||
int i = 0;
|
||||
ZipEntry zde = new ZipEntry();
|
||||
zde.AlternateEncoding = expectedEncoding;
|
||||
zde._Source = ZipEntrySource.ZipFile;
|
||||
zde._container = new ZipContainer(zf);
|
||||
|
||||
unchecked
|
||||
{
|
||||
zde._VersionMadeBy = (short)(block[i++] + block[i++] * 256);
|
||||
zde._VersionNeeded = (short)(block[i++] + block[i++] * 256);
|
||||
zde._BitField = (short)(block[i++] + block[i++] * 256);
|
||||
zde._CompressionMethod = (Int16)(block[i++] + block[i++] * 256);
|
||||
zde._TimeBlob = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
|
||||
zde._LastModified = Ionic.Zip.SharedUtilities.PackedToDateTime(zde._TimeBlob);
|
||||
zde._timestamp |= ZipEntryTimestamp.DOS;
|
||||
|
||||
zde._Crc32 = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
|
||||
zde._CompressedSize = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
|
||||
zde._UncompressedSize = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
|
||||
}
|
||||
|
||||
// preserve
|
||||
zde._CompressionMethod_FromZipFile = zde._CompressionMethod;
|
||||
|
||||
zde._filenameLength = (short)(block[i++] + block[i++] * 256);
|
||||
zde._extraFieldLength = (short)(block[i++] + block[i++] * 256);
|
||||
zde._commentLength = (short)(block[i++] + block[i++] * 256);
|
||||
zde._diskNumber = (UInt32)(block[i++] + block[i++] * 256);
|
||||
|
||||
zde._InternalFileAttrs = (short)(block[i++] + block[i++] * 256);
|
||||
zde._ExternalFileAttrs = block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256;
|
||||
|
||||
zde._RelativeOffsetOfLocalHeader = (uint)(block[i++] + block[i++] * 256 + block[i++] * 256 * 256 + block[i++] * 256 * 256 * 256);
|
||||
|
||||
// workitem 7801
|
||||
zde.IsText = ((zde._InternalFileAttrs & 0x01) == 0x01);
|
||||
|
||||
block = new byte[zde._filenameLength];
|
||||
n = s.Read(block, 0, block.Length);
|
||||
bytesRead += n;
|
||||
if ((zde._BitField & 0x0800) == 0x0800)
|
||||
{
|
||||
// UTF-8 is in use
|
||||
zde._FileNameInArchive = Ionic.Zip.SharedUtilities.Utf8StringFromBuffer(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
zde._FileNameInArchive = Ionic.Zip.SharedUtilities.StringFromBuffer(block, expectedEncoding);
|
||||
}
|
||||
|
||||
// workitem 10330
|
||||
// insure unique entry names
|
||||
while (previouslySeen.ContainsKey(zde._FileNameInArchive))
|
||||
{
|
||||
zde._FileNameInArchive = CopyHelper.AppendCopyToFileName(zde._FileNameInArchive);
|
||||
zde._metadataChanged = true;
|
||||
}
|
||||
|
||||
if (zde.AttributesIndicateDirectory)
|
||||
zde.MarkAsDirectory(); // may append a slash to filename if nec.
|
||||
// workitem 6898
|
||||
else if (zde._FileNameInArchive.EndsWith("/")) zde.MarkAsDirectory();
|
||||
|
||||
zde._CompressedFileDataSize = zde._CompressedSize;
|
||||
if ((zde._BitField & 0x01) == 0x01)
|
||||
{
|
||||
// this may change after processing the Extra field
|
||||
zde._Encryption_FromZipFile = zde._Encryption =
|
||||
EncryptionAlgorithm.PkzipWeak;
|
||||
zde._sourceIsEncrypted = true;
|
||||
}
|
||||
|
||||
if (zde._extraFieldLength > 0)
|
||||
{
|
||||
zde._InputUsesZip64 = (zde._CompressedSize == 0xFFFFFFFF ||
|
||||
zde._UncompressedSize == 0xFFFFFFFF ||
|
||||
zde._RelativeOffsetOfLocalHeader == 0xFFFFFFFF);
|
||||
|
||||
// Console.WriteLine(" Input uses Z64?: {0}", zde._InputUsesZip64);
|
||||
|
||||
bytesRead += zde.ProcessExtraField(s, zde._extraFieldLength);
|
||||
zde._CompressedFileDataSize = zde._CompressedSize;
|
||||
}
|
||||
|
||||
// we've processed the extra field, so we know the encryption method is set now.
|
||||
if (zde._Encryption == EncryptionAlgorithm.PkzipWeak)
|
||||
{
|
||||
// the "encryption header" of 12 bytes precedes the file data
|
||||
zde._CompressedFileDataSize -= 12;
|
||||
}
|
||||
#if AESCRYPTO
|
||||
else if (zde.Encryption == EncryptionAlgorithm.WinZipAes128 ||
|
||||
zde.Encryption == EncryptionAlgorithm.WinZipAes256)
|
||||
{
|
||||
zde._CompressedFileDataSize = zde.CompressedSize -
|
||||
(ZipEntry.GetLengthOfCryptoHeaderBytes(zde.Encryption) + 10);
|
||||
zde._LengthOfTrailer = 10;
|
||||
}
|
||||
#endif
|
||||
|
||||
// tally the trailing descriptor
|
||||
if ((zde._BitField & 0x0008) == 0x0008)
|
||||
{
|
||||
// sig, CRC, Comp and Uncomp sizes
|
||||
if (zde._InputUsesZip64)
|
||||
zde._LengthOfTrailer += 24;
|
||||
else
|
||||
zde._LengthOfTrailer += 16;
|
||||
}
|
||||
|
||||
// workitem 12744
|
||||
zde.AlternateEncoding = ((zde._BitField & 0x0800) == 0x0800)
|
||||
? System.Text.Encoding.UTF8
|
||||
:expectedEncoding;
|
||||
|
||||
zde.AlternateEncodingUsage = ZipOption.Always;
|
||||
|
||||
if (zde._commentLength > 0)
|
||||
{
|
||||
block = new byte[zde._commentLength];
|
||||
n = s.Read(block, 0, block.Length);
|
||||
bytesRead += n;
|
||||
if ((zde._BitField & 0x0800) == 0x0800)
|
||||
{
|
||||
// UTF-8 is in use
|
||||
zde._Comment = Ionic.Zip.SharedUtilities.Utf8StringFromBuffer(block);
|
||||
}
|
||||
else
|
||||
{
|
||||
zde._Comment = Ionic.Zip.SharedUtilities.StringFromBuffer(block, expectedEncoding);
|
||||
}
|
||||
}
|
||||
//zde._LengthOfDirEntry = bytesRead;
|
||||
return zde;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the passed-in value is a valid signature for a ZipDirEntry.
|
||||
/// </summary>
|
||||
/// <param name="signature">the candidate 4-byte signature value.</param>
|
||||
/// <returns>true, if the signature is valid according to the PKWare spec.</returns>
|
||||
internal static bool IsNotValidZipDirEntrySig(int signature)
|
||||
{
|
||||
return (signature != ZipConstants.ZipDirEntrySignature);
|
||||
}
|
||||
|
||||
|
||||
private Int16 _VersionMadeBy;
|
||||
private Int16 _InternalFileAttrs;
|
||||
private Int32 _ExternalFileAttrs;
|
||||
|
||||
//private Int32 _LengthOfDirEntry;
|
||||
private Int16 _filenameLength;
|
||||
private Int16 _extraFieldLength;
|
||||
private Int16 _commentLength;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,69 +1,69 @@
|
||||
// ZipEntrySource.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-November-19 11:18:42>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// An enum that specifies the source of the ZipEntry.
|
||||
/// </summary>
|
||||
public enum ZipEntrySource
|
||||
{
|
||||
/// <summary>
|
||||
/// Default value. Invalid on a bonafide ZipEntry.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The entry was instantiated by calling AddFile() or another method that
|
||||
/// added an entry from the filesystem.
|
||||
/// </summary>
|
||||
FileSystem,
|
||||
|
||||
/// <summary>
|
||||
/// The entry was instantiated via <see cref="Ionic.Zip.ZipFile.AddEntry(string,string)"/> or
|
||||
/// <see cref="Ionic.Zip.ZipFile.AddEntry(string,System.IO.Stream)"/> .
|
||||
/// </summary>
|
||||
Stream,
|
||||
|
||||
/// <summary>
|
||||
/// The ZipEntry was instantiated by reading a zipfile.
|
||||
/// </summary>
|
||||
ZipFile,
|
||||
|
||||
/// <summary>
|
||||
/// The content for the ZipEntry will be or was provided by the WriteDelegate.
|
||||
/// </summary>
|
||||
WriteDelegate,
|
||||
|
||||
/// <summary>
|
||||
/// The content for the ZipEntry will be obtained from the stream dispensed by the <c>OpenDelegate</c>.
|
||||
/// The entry was instantiated via <see cref="Ionic.Zip.ZipFile.AddEntry(string,OpenDelegate,CloseDelegate)"/>.
|
||||
/// </summary>
|
||||
JitStream,
|
||||
|
||||
/// <summary>
|
||||
/// The content for the ZipEntry will be or was obtained from a <c>ZipOutputStream</c>.
|
||||
/// </summary>
|
||||
ZipOutputStream,
|
||||
}
|
||||
|
||||
// ZipEntrySource.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-November-19 11:18:42>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// An enum that specifies the source of the ZipEntry.
|
||||
/// </summary>
|
||||
public enum ZipEntrySource
|
||||
{
|
||||
/// <summary>
|
||||
/// Default value. Invalid on a bonafide ZipEntry.
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The entry was instantiated by calling AddFile() or another method that
|
||||
/// added an entry from the filesystem.
|
||||
/// </summary>
|
||||
FileSystem,
|
||||
|
||||
/// <summary>
|
||||
/// The entry was instantiated via <see cref="Ionic.Zip.ZipFile.AddEntry(string,string)"/> or
|
||||
/// <see cref="Ionic.Zip.ZipFile.AddEntry(string,System.IO.Stream)"/> .
|
||||
/// </summary>
|
||||
Stream,
|
||||
|
||||
/// <summary>
|
||||
/// The ZipEntry was instantiated by reading a zipfile.
|
||||
/// </summary>
|
||||
ZipFile,
|
||||
|
||||
/// <summary>
|
||||
/// The content for the ZipEntry will be or was provided by the WriteDelegate.
|
||||
/// </summary>
|
||||
WriteDelegate,
|
||||
|
||||
/// <summary>
|
||||
/// The content for the ZipEntry will be obtained from the stream dispensed by the <c>OpenDelegate</c>.
|
||||
/// The entry was instantiated via <see cref="Ionic.Zip.ZipFile.AddEntry(string,OpenDelegate,CloseDelegate)"/>.
|
||||
/// </summary>
|
||||
JitStream,
|
||||
|
||||
/// <summary>
|
||||
/// The content for the ZipEntry will be or was obtained from a <c>ZipOutputStream</c>.
|
||||
/// </summary>
|
||||
ZipOutputStream,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +1,97 @@
|
||||
// ZipErrorAction.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-September-01 18:43:20>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the ZipErrorAction enum, which provides
|
||||
// an action to take when errors occur when opening or reading
|
||||
// files to be added to a zip file.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// An enum providing the options when an error occurs during opening or reading
|
||||
/// of a file or directory that is being saved to a zip file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This enum describes the actions that the library can take when an error occurs
|
||||
/// opening or reading a file, as it is being saved into a Zip archive.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// In some cases an error will occur when DotNetZip tries to open a file to be
|
||||
/// added to the zip archive. In other cases, an error might occur after the
|
||||
/// file has been successfully opened, while DotNetZip is reading the file.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The first problem might occur when calling AddDirectory() on a directory
|
||||
/// that contains a Clipper .dbf file; the file is locked by Clipper and
|
||||
/// cannot be opened by another process. An example of the second problem is
|
||||
/// the ERROR_LOCK_VIOLATION that results when a file is opened by another
|
||||
/// process, but not locked, and a range lock has been taken on the file.
|
||||
/// Microsoft Outlook takes range locks on .PST files.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public enum ZipErrorAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Throw an exception when an error occurs while zipping. This is the default
|
||||
/// behavior. (For COM clients, this is a 0 (zero).)
|
||||
/// </summary>
|
||||
Throw,
|
||||
|
||||
/// <summary>
|
||||
/// When an error occurs during zipping, for example a file cannot be opened,
|
||||
/// skip the file causing the error, and continue zipping. (For COM clients,
|
||||
/// this is a 1.)
|
||||
/// </summary>
|
||||
Skip,
|
||||
|
||||
/// <summary>
|
||||
/// When an error occurs during zipping, for example a file cannot be opened,
|
||||
/// retry the operation that caused the error. Be careful with this option. If
|
||||
/// the error is not temporary, the library will retry forever. (For COM
|
||||
/// clients, this is a 2.)
|
||||
/// </summary>
|
||||
Retry,
|
||||
|
||||
/// <summary>
|
||||
/// When an error occurs, invoke the zipError event. The event type used is
|
||||
/// <see cref="ZipProgressEventType.Error_Saving"/>. A typical use of this option:
|
||||
/// a GUI application may wish to pop up a dialog to allow the user to view the
|
||||
/// error that occurred, and choose an appropriate action. After your
|
||||
/// processing in the error event, if you want to skip the file, set <see
|
||||
/// cref="ZipEntry.ZipErrorAction"/> on the
|
||||
/// <c>ZipProgressEventArgs.CurrentEntry</c> to <c>Skip</c>. If you want the
|
||||
/// exception to be thrown, set <c>ZipErrorAction</c> on the <c>CurrentEntry</c>
|
||||
/// to <c>Throw</c>. If you want to cancel the zip, set
|
||||
/// <c>ZipProgressEventArgs.Cancel</c> to true. Cancelling differs from using
|
||||
/// Skip in that a cancel will not save any further entries, if there are any.
|
||||
/// (For COM clients, the value of this enum is a 3.)
|
||||
/// </summary>
|
||||
InvokeErrorEvent,
|
||||
}
|
||||
|
||||
}
|
||||
// ZipErrorAction.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-September-01 18:43:20>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the ZipErrorAction enum, which provides
|
||||
// an action to take when errors occur when opening or reading
|
||||
// files to be added to a zip file.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
/// <summary>
|
||||
/// An enum providing the options when an error occurs during opening or reading
|
||||
/// of a file or directory that is being saved to a zip file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This enum describes the actions that the library can take when an error occurs
|
||||
/// opening or reading a file, as it is being saved into a Zip archive.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// In some cases an error will occur when DotNetZip tries to open a file to be
|
||||
/// added to the zip archive. In other cases, an error might occur after the
|
||||
/// file has been successfully opened, while DotNetZip is reading the file.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The first problem might occur when calling AddDirectory() on a directory
|
||||
/// that contains a Clipper .dbf file; the file is locked by Clipper and
|
||||
/// cannot be opened by another process. An example of the second problem is
|
||||
/// the ERROR_LOCK_VIOLATION that results when a file is opened by another
|
||||
/// process, but not locked, and a range lock has been taken on the file.
|
||||
/// Microsoft Outlook takes range locks on .PST files.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public enum ZipErrorAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Throw an exception when an error occurs while zipping. This is the default
|
||||
/// behavior. (For COM clients, this is a 0 (zero).)
|
||||
/// </summary>
|
||||
Throw,
|
||||
|
||||
/// <summary>
|
||||
/// When an error occurs during zipping, for example a file cannot be opened,
|
||||
/// skip the file causing the error, and continue zipping. (For COM clients,
|
||||
/// this is a 1.)
|
||||
/// </summary>
|
||||
Skip,
|
||||
|
||||
/// <summary>
|
||||
/// When an error occurs during zipping, for example a file cannot be opened,
|
||||
/// retry the operation that caused the error. Be careful with this option. If
|
||||
/// the error is not temporary, the library will retry forever. (For COM
|
||||
/// clients, this is a 2.)
|
||||
/// </summary>
|
||||
Retry,
|
||||
|
||||
/// <summary>
|
||||
/// When an error occurs, invoke the zipError event. The event type used is
|
||||
/// <see cref="ZipProgressEventType.Error_Saving"/>. A typical use of this option:
|
||||
/// a GUI application may wish to pop up a dialog to allow the user to view the
|
||||
/// error that occurred, and choose an appropriate action. After your
|
||||
/// processing in the error event, if you want to skip the file, set <see
|
||||
/// cref="ZipEntry.ZipErrorAction"/> on the
|
||||
/// <c>ZipProgressEventArgs.CurrentEntry</c> to <c>Skip</c>. If you want the
|
||||
/// exception to be thrown, set <c>ZipErrorAction</c> on the <c>CurrentEntry</c>
|
||||
/// to <c>Throw</c>. If you want to cancel the zip, set
|
||||
/// <c>ZipProgressEventArgs.Cancel</c> to true. Cancelling differs from using
|
||||
/// Skip in that a cancel will not save any further entries, if there are any.
|
||||
/// (For COM clients, the value of this enum is a 3.)
|
||||
/// </summary>
|
||||
InvokeErrorEvent,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,352 +1,352 @@
|
||||
// ZipFile.Check.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009-2011 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-31 14:40:50>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the methods for doing Checks on zip files.
|
||||
// These are not necessary to include in the Reduced or CF
|
||||
// version of the library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
public partial class ZipFile
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks a zip file to see if its directory is consistent.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// In cases of data error, the directory within a zip file can get out
|
||||
/// of synch with the entries in the zip file. This method checks the
|
||||
/// given zip file and returns true if this has occurred.
|
||||
/// </para>
|
||||
///
|
||||
/// <para> This method may take a long time to run for large zip files. </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method is not supported in the Reduced or Compact Framework
|
||||
/// versions of DotNetZip.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Developers using COM can use the <see
|
||||
/// cref="ComHelper.CheckZip(String)">ComHelper.CheckZip(String)</see>
|
||||
/// method.
|
||||
/// </para>
|
||||
///
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="zipFileName">The filename to of the zip file to check.</param>
|
||||
///
|
||||
/// <returns>true if the named zip file checks OK. Otherwise, false. </returns>
|
||||
///
|
||||
/// <seealso cref="FixZipDirectory(string)"/>
|
||||
/// <seealso cref="CheckZip(string,bool,System.IO.TextWriter)"/>
|
||||
public static bool CheckZip(string zipFileName)
|
||||
{
|
||||
return CheckZip(zipFileName, false, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks a zip file to see if its directory is consistent,
|
||||
/// and optionally fixes the directory if necessary.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// In cases of data error, the directory within a zip file can get out of
|
||||
/// synch with the entries in the zip file. This method checks the given
|
||||
/// zip file, and returns true if this has occurred. It also optionally
|
||||
/// fixes the zipfile, saving the fixed copy in <em>Name</em>_Fixed.zip.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method may take a long time to run for large zip files. It
|
||||
/// will take even longer if the file actually needs to be fixed, and if
|
||||
/// <c>fixIfNecessary</c> is true.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method is not supported in the Reduced or Compact
|
||||
/// Framework versions of DotNetZip.
|
||||
/// </para>
|
||||
///
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="zipFileName">The filename to of the zip file to check.</param>
|
||||
///
|
||||
/// <param name="fixIfNecessary">If true, the method will fix the zip file if
|
||||
/// necessary.</param>
|
||||
///
|
||||
/// <param name="writer">
|
||||
/// a TextWriter in which messages generated while checking will be written.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>true if the named zip is OK; false if the file needs to be fixed.</returns>
|
||||
///
|
||||
/// <seealso cref="CheckZip(string)"/>
|
||||
/// <seealso cref="FixZipDirectory(string)"/>
|
||||
public static bool CheckZip(string zipFileName, bool fixIfNecessary,
|
||||
TextWriter writer)
|
||||
|
||||
{
|
||||
ZipFile zip1 = null, zip2 = null;
|
||||
bool isOk = true;
|
||||
try
|
||||
{
|
||||
zip1 = new ZipFile();
|
||||
zip1.FullScan = true;
|
||||
zip1.Initialize(zipFileName);
|
||||
|
||||
zip2 = ZipFile.Read(zipFileName);
|
||||
|
||||
foreach (var e1 in zip1)
|
||||
{
|
||||
foreach (var e2 in zip2)
|
||||
{
|
||||
if (e1.FileName == e2.FileName)
|
||||
{
|
||||
if (e1._RelativeOffsetOfLocalHeader != e2._RelativeOffsetOfLocalHeader)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in RelativeOffsetOfLocalHeader (0x{1:X16} != 0x{2:X16})",
|
||||
e1.FileName, e1._RelativeOffsetOfLocalHeader,
|
||||
e2._RelativeOffsetOfLocalHeader);
|
||||
}
|
||||
if (e1._CompressedSize != e2._CompressedSize)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in CompressedSize (0x{1:X16} != 0x{2:X16})",
|
||||
e1.FileName, e1._CompressedSize,
|
||||
e2._CompressedSize);
|
||||
}
|
||||
if (e1._UncompressedSize != e2._UncompressedSize)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in UncompressedSize (0x{1:X16} != 0x{2:X16})",
|
||||
e1.FileName, e1._UncompressedSize,
|
||||
e2._UncompressedSize);
|
||||
}
|
||||
if (e1.CompressionMethod != e2.CompressionMethod)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in CompressionMethod (0x{1:X4} != 0x{2:X4})",
|
||||
e1.FileName, e1.CompressionMethod,
|
||||
e2.CompressionMethod);
|
||||
}
|
||||
if (e1.Crc != e2.Crc)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in Crc32 (0x{1:X4} != 0x{2:X4})",
|
||||
e1.FileName, e1.Crc,
|
||||
e2.Crc);
|
||||
}
|
||||
|
||||
// found a match, so stop the inside loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zip2.Dispose();
|
||||
zip2 = null;
|
||||
|
||||
if (!isOk && fixIfNecessary)
|
||||
{
|
||||
string newFileName = Path.GetFileNameWithoutExtension(zipFileName);
|
||||
newFileName = System.String.Format("{0}_fixed.zip", newFileName);
|
||||
zip1.Save(newFileName);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (zip1 != null) zip1.Dispose();
|
||||
if (zip2 != null) zip2.Dispose();
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rewrite the directory within a zipfile.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// In cases of data error, the directory in a zip file can get out of
|
||||
/// synch with the entries in the zip file. This method attempts to fix
|
||||
/// the zip file if this has occurred.
|
||||
/// </para>
|
||||
///
|
||||
/// <para> This can take a long time for large zip files. </para>
|
||||
///
|
||||
/// <para> This won't work if the zip file uses a non-standard
|
||||
/// code page - neither IBM437 nor UTF-8. </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method is not supported in the Reduced or Compact Framework
|
||||
/// versions of DotNetZip.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Developers using COM can use the <see
|
||||
/// cref="ComHelper.FixZipDirectory(String)">ComHelper.FixZipDirectory(String)</see>
|
||||
/// method.
|
||||
/// </para>
|
||||
///
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="zipFileName">The filename to of the zip file to fix.</param>
|
||||
///
|
||||
/// <seealso cref="CheckZip(string)"/>
|
||||
/// <seealso cref="CheckZip(string,bool,System.IO.TextWriter)"/>
|
||||
public static void FixZipDirectory(string zipFileName)
|
||||
{
|
||||
using (var zip = new ZipFile())
|
||||
{
|
||||
zip.FullScan = true;
|
||||
zip.Initialize(zipFileName);
|
||||
zip.Save(zipFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verify the password on a zip file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Keep in mind that passwords in zipfiles are applied to
|
||||
/// zip entries, not to the entire zip file. So testing a
|
||||
/// zipfile for a particular password doesn't work in the
|
||||
/// general case. On the other hand, it's often the case
|
||||
/// that a single password will be used on all entries in a
|
||||
/// zip file. This method works for that case.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// There is no way to check a password without doing the
|
||||
/// decryption. So this code decrypts and extracts the given
|
||||
/// zipfile into <see cref="System.IO.Stream.Null"/>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="zipFileName">The filename to of the zip file to fix.</param>
|
||||
///
|
||||
/// <param name="password">The password to check.</param>
|
||||
///
|
||||
/// <returns>a bool indicating whether the password matches.</returns>
|
||||
public static bool CheckZipPassword(string zipFileName, string password)
|
||||
{
|
||||
// workitem 13664
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
using (ZipFile zip1 = ZipFile.Read(zipFileName))
|
||||
{
|
||||
foreach (var e in zip1)
|
||||
{
|
||||
if (!e.IsDirectory && e.UsesEncryption)
|
||||
{
|
||||
e.ExtractWithPassword(System.IO.Stream.Null, password);
|
||||
}
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
catch(Ionic.Zip.BadPasswordException) { }
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Provides a human-readable string with information about the ZipFile.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The information string contains 10 lines or so, about each ZipEntry,
|
||||
/// describing whether encryption is in use, the compressed and uncompressed
|
||||
/// length of the entry, the offset of the entry, and so on. As a result the
|
||||
/// information string can be very long for zip files that contain many
|
||||
/// entries.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This information is mostly useful for diagnostic purposes.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public string Info
|
||||
{
|
||||
get
|
||||
{
|
||||
var builder = new System.Text.StringBuilder();
|
||||
builder.Append(string.Format(" ZipFile: {0}\n", this.Name));
|
||||
if (!string.IsNullOrEmpty(this._Comment))
|
||||
{
|
||||
builder.Append(string.Format(" Comment: {0}\n", this._Comment));
|
||||
}
|
||||
if (this._versionMadeBy != 0)
|
||||
{
|
||||
builder.Append(string.Format(" version made by: 0x{0:X4}\n", this._versionMadeBy));
|
||||
}
|
||||
if (this._versionNeededToExtract != 0)
|
||||
{
|
||||
builder.Append(string.Format("needed to extract: 0x{0:X4}\n", this._versionNeededToExtract));
|
||||
}
|
||||
|
||||
builder.Append(string.Format(" uses ZIP64: {0}\n", this.InputUsesZip64));
|
||||
|
||||
builder.Append(string.Format(" disk with CD: {0}\n", this._diskNumberWithCd));
|
||||
if (this._OffsetOfCentralDirectory == 0xFFFFFFFF)
|
||||
builder.Append(string.Format(" CD64 offset: 0x{0:X16}\n", this._OffsetOfCentralDirectory64));
|
||||
else
|
||||
builder.Append(string.Format(" CD offset: 0x{0:X8}\n", this._OffsetOfCentralDirectory));
|
||||
builder.Append("\n");
|
||||
foreach (ZipEntry entry in this._entries.Values)
|
||||
{
|
||||
builder.Append(entry.Info);
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ZipFile.Check.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009-2011 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-31 14:40:50>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the methods for doing Checks on zip files.
|
||||
// These are not necessary to include in the Reduced or CF
|
||||
// version of the library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
public partial class ZipFile
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks a zip file to see if its directory is consistent.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// In cases of data error, the directory within a zip file can get out
|
||||
/// of synch with the entries in the zip file. This method checks the
|
||||
/// given zip file and returns true if this has occurred.
|
||||
/// </para>
|
||||
///
|
||||
/// <para> This method may take a long time to run for large zip files. </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method is not supported in the Reduced or Compact Framework
|
||||
/// versions of DotNetZip.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Developers using COM can use the <see
|
||||
/// cref="ComHelper.CheckZip(String)">ComHelper.CheckZip(String)</see>
|
||||
/// method.
|
||||
/// </para>
|
||||
///
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="zipFileName">The filename to of the zip file to check.</param>
|
||||
///
|
||||
/// <returns>true if the named zip file checks OK. Otherwise, false. </returns>
|
||||
///
|
||||
/// <seealso cref="FixZipDirectory(string)"/>
|
||||
/// <seealso cref="CheckZip(string,bool,System.IO.TextWriter)"/>
|
||||
public static bool CheckZip(string zipFileName)
|
||||
{
|
||||
return CheckZip(zipFileName, false, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks a zip file to see if its directory is consistent,
|
||||
/// and optionally fixes the directory if necessary.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// In cases of data error, the directory within a zip file can get out of
|
||||
/// synch with the entries in the zip file. This method checks the given
|
||||
/// zip file, and returns true if this has occurred. It also optionally
|
||||
/// fixes the zipfile, saving the fixed copy in <em>Name</em>_Fixed.zip.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method may take a long time to run for large zip files. It
|
||||
/// will take even longer if the file actually needs to be fixed, and if
|
||||
/// <c>fixIfNecessary</c> is true.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method is not supported in the Reduced or Compact
|
||||
/// Framework versions of DotNetZip.
|
||||
/// </para>
|
||||
///
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="zipFileName">The filename to of the zip file to check.</param>
|
||||
///
|
||||
/// <param name="fixIfNecessary">If true, the method will fix the zip file if
|
||||
/// necessary.</param>
|
||||
///
|
||||
/// <param name="writer">
|
||||
/// a TextWriter in which messages generated while checking will be written.
|
||||
/// </param>
|
||||
///
|
||||
/// <returns>true if the named zip is OK; false if the file needs to be fixed.</returns>
|
||||
///
|
||||
/// <seealso cref="CheckZip(string)"/>
|
||||
/// <seealso cref="FixZipDirectory(string)"/>
|
||||
public static bool CheckZip(string zipFileName, bool fixIfNecessary,
|
||||
TextWriter writer)
|
||||
|
||||
{
|
||||
ZipFile zip1 = null, zip2 = null;
|
||||
bool isOk = true;
|
||||
try
|
||||
{
|
||||
zip1 = new ZipFile();
|
||||
zip1.FullScan = true;
|
||||
zip1.Initialize(zipFileName);
|
||||
|
||||
zip2 = ZipFile.Read(zipFileName);
|
||||
|
||||
foreach (var e1 in zip1)
|
||||
{
|
||||
foreach (var e2 in zip2)
|
||||
{
|
||||
if (e1.FileName == e2.FileName)
|
||||
{
|
||||
if (e1._RelativeOffsetOfLocalHeader != e2._RelativeOffsetOfLocalHeader)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in RelativeOffsetOfLocalHeader (0x{1:X16} != 0x{2:X16})",
|
||||
e1.FileName, e1._RelativeOffsetOfLocalHeader,
|
||||
e2._RelativeOffsetOfLocalHeader);
|
||||
}
|
||||
if (e1._CompressedSize != e2._CompressedSize)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in CompressedSize (0x{1:X16} != 0x{2:X16})",
|
||||
e1.FileName, e1._CompressedSize,
|
||||
e2._CompressedSize);
|
||||
}
|
||||
if (e1._UncompressedSize != e2._UncompressedSize)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in UncompressedSize (0x{1:X16} != 0x{2:X16})",
|
||||
e1.FileName, e1._UncompressedSize,
|
||||
e2._UncompressedSize);
|
||||
}
|
||||
if (e1.CompressionMethod != e2.CompressionMethod)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in CompressionMethod (0x{1:X4} != 0x{2:X4})",
|
||||
e1.FileName, e1.CompressionMethod,
|
||||
e2.CompressionMethod);
|
||||
}
|
||||
if (e1.Crc != e2.Crc)
|
||||
{
|
||||
isOk = false;
|
||||
if (writer != null)
|
||||
writer.WriteLine("{0}: mismatch in Crc32 (0x{1:X4} != 0x{2:X4})",
|
||||
e1.FileName, e1.Crc,
|
||||
e2.Crc);
|
||||
}
|
||||
|
||||
// found a match, so stop the inside loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zip2.Dispose();
|
||||
zip2 = null;
|
||||
|
||||
if (!isOk && fixIfNecessary)
|
||||
{
|
||||
string newFileName = Path.GetFileNameWithoutExtension(zipFileName);
|
||||
newFileName = System.String.Format("{0}_fixed.zip", newFileName);
|
||||
zip1.Save(newFileName);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (zip1 != null) zip1.Dispose();
|
||||
if (zip2 != null) zip2.Dispose();
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rewrite the directory within a zipfile.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// In cases of data error, the directory in a zip file can get out of
|
||||
/// synch with the entries in the zip file. This method attempts to fix
|
||||
/// the zip file if this has occurred.
|
||||
/// </para>
|
||||
///
|
||||
/// <para> This can take a long time for large zip files. </para>
|
||||
///
|
||||
/// <para> This won't work if the zip file uses a non-standard
|
||||
/// code page - neither IBM437 nor UTF-8. </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method is not supported in the Reduced or Compact Framework
|
||||
/// versions of DotNetZip.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Developers using COM can use the <see
|
||||
/// cref="ComHelper.FixZipDirectory(String)">ComHelper.FixZipDirectory(String)</see>
|
||||
/// method.
|
||||
/// </para>
|
||||
///
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="zipFileName">The filename to of the zip file to fix.</param>
|
||||
///
|
||||
/// <seealso cref="CheckZip(string)"/>
|
||||
/// <seealso cref="CheckZip(string,bool,System.IO.TextWriter)"/>
|
||||
public static void FixZipDirectory(string zipFileName)
|
||||
{
|
||||
using (var zip = new ZipFile())
|
||||
{
|
||||
zip.FullScan = true;
|
||||
zip.Initialize(zipFileName);
|
||||
zip.Save(zipFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verify the password on a zip file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Keep in mind that passwords in zipfiles are applied to
|
||||
/// zip entries, not to the entire zip file. So testing a
|
||||
/// zipfile for a particular password doesn't work in the
|
||||
/// general case. On the other hand, it's often the case
|
||||
/// that a single password will be used on all entries in a
|
||||
/// zip file. This method works for that case.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// There is no way to check a password without doing the
|
||||
/// decryption. So this code decrypts and extracts the given
|
||||
/// zipfile into <see cref="System.IO.Stream.Null"/>
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
///
|
||||
/// <param name="zipFileName">The filename to of the zip file to fix.</param>
|
||||
///
|
||||
/// <param name="password">The password to check.</param>
|
||||
///
|
||||
/// <returns>a bool indicating whether the password matches.</returns>
|
||||
public static bool CheckZipPassword(string zipFileName, string password)
|
||||
{
|
||||
// workitem 13664
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
using (ZipFile zip1 = ZipFile.Read(zipFileName))
|
||||
{
|
||||
foreach (var e in zip1)
|
||||
{
|
||||
if (!e.IsDirectory && e.UsesEncryption)
|
||||
{
|
||||
e.ExtractWithPassword(System.IO.Stream.Null, password);
|
||||
}
|
||||
}
|
||||
}
|
||||
success = true;
|
||||
}
|
||||
catch(Ionic.Zip.BadPasswordException) { }
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Provides a human-readable string with information about the ZipFile.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The information string contains 10 lines or so, about each ZipEntry,
|
||||
/// describing whether encryption is in use, the compressed and uncompressed
|
||||
/// length of the entry, the offset of the entry, and so on. As a result the
|
||||
/// information string can be very long for zip files that contain many
|
||||
/// entries.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This information is mostly useful for diagnostic purposes.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public string Info
|
||||
{
|
||||
get
|
||||
{
|
||||
var builder = new System.Text.StringBuilder();
|
||||
builder.Append(string.Format(" ZipFile: {0}\n", this.Name));
|
||||
if (!string.IsNullOrEmpty(this._Comment))
|
||||
{
|
||||
builder.Append(string.Format(" Comment: {0}\n", this._Comment));
|
||||
}
|
||||
if (this._versionMadeBy != 0)
|
||||
{
|
||||
builder.Append(string.Format(" version made by: 0x{0:X4}\n", this._versionMadeBy));
|
||||
}
|
||||
if (this._versionNeededToExtract != 0)
|
||||
{
|
||||
builder.Append(string.Format("needed to extract: 0x{0:X4}\n", this._versionNeededToExtract));
|
||||
}
|
||||
|
||||
builder.Append(string.Format(" uses ZIP64: {0}\n", this.InputUsesZip64));
|
||||
|
||||
builder.Append(string.Format(" disk with CD: {0}\n", this._diskNumberWithCd));
|
||||
if (this._OffsetOfCentralDirectory == 0xFFFFFFFF)
|
||||
builder.Append(string.Format(" CD64 offset: 0x{0:X16}\n", this._OffsetOfCentralDirectory64));
|
||||
else
|
||||
builder.Append(string.Format(" CD offset: 0x{0:X8}\n", this._OffsetOfCentralDirectory));
|
||||
builder.Append("\n");
|
||||
foreach (ZipEntry entry in this._entries.Values)
|
||||
{
|
||||
builder.Append(entry.Info);
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,298 +1,298 @@
|
||||
// ZipFile.Extract.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-31 14:45:18>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the methods for Extract operations on zip files.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
|
||||
public partial class ZipFile
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all of the items in the zip archive, to the specified path in the
|
||||
/// filesystem. The path can be relative or fully-qualified.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method will extract all entries in the <c>ZipFile</c> to the
|
||||
/// specified path.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// If an extraction of a file from the zip archive would overwrite an
|
||||
/// existing file in the filesystem, the action taken is dictated by the
|
||||
/// ExtractExistingFile property, which overrides any setting you may have
|
||||
/// made on individual ZipEntry instances. By default, if you have not
|
||||
/// set that property on the <c>ZipFile</c> instance, the entry will not
|
||||
/// be extracted, the existing file will not be overwritten and an
|
||||
/// exception will be thrown. To change this, set the property, or use the
|
||||
/// <see cref="ZipFile.ExtractAll(string,
|
||||
/// Ionic.Zip.ExtractExistingFileAction)" /> overload that allows you to
|
||||
/// specify an ExtractExistingFileAction parameter.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The action to take when an extract would overwrite an existing file
|
||||
/// applies to all entries. If you want to set this on a per-entry basis,
|
||||
/// then you must use one of the <see
|
||||
/// cref="ZipEntry.Extract()">ZipEntry.Extract</see> methods.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method will send verbose output messages to the <see
|
||||
/// cref="StatusMessageTextWriter"/>, if it is set on the <c>ZipFile</c>
|
||||
/// instance.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// You may wish to take advantage of the <c>ExtractProgress</c> event.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// About timestamps: When extracting a file entry from a zip archive, the
|
||||
/// extracted file gets the last modified time of the entry as stored in
|
||||
/// the archive. The archive may also store extended file timestamp
|
||||
/// information, including last accessed and created times. If these are
|
||||
/// present in the <c>ZipEntry</c>, then the extracted file will also get
|
||||
/// these times.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// A Directory entry is somewhat different. It will get the times as
|
||||
/// described for a file entry, but, if there are file entries in the zip
|
||||
/// archive that, when extracted, appear in the just-created directory,
|
||||
/// then when those file entries are extracted, the last modified and last
|
||||
/// accessed times of the directory will change, as a side effect. The
|
||||
/// result is that after an extraction of a directory and a number of
|
||||
/// files within the directory, the last modified and last accessed
|
||||
/// timestamps on the directory will reflect the time that the last file
|
||||
/// was extracted into the directory, rather than the time stored in the
|
||||
/// zip archive for the directory.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// To compensate, when extracting an archive with <c>ExtractAll</c>,
|
||||
/// DotNetZip will extract all the file and directory entries as described
|
||||
/// above, but it will then make a second pass on the directories, and
|
||||
/// reset the times on the directories to reflect what is stored in the
|
||||
/// zip archive.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This compensation is performed only within the context of an
|
||||
/// <c>ExtractAll</c>. If you call <c>ZipEntry.Extract</c> on a directory
|
||||
/// entry, the timestamps on directory in the filesystem will reflect the
|
||||
/// times stored in the zip. If you then call <c>ZipEntry.Extract</c> on
|
||||
/// a file entry, which is extracted into the directory, the timestamps on
|
||||
/// the directory will be updated to the current time.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
///
|
||||
/// <example>
|
||||
/// This example extracts all the entries in a zip archive file, to the
|
||||
/// specified target directory. The extraction will overwrite any
|
||||
/// existing files silently.
|
||||
///
|
||||
/// <code>
|
||||
/// String TargetDirectory= "unpack";
|
||||
/// using(ZipFile zip= ZipFile.Read(ZipFileToExtract))
|
||||
/// {
|
||||
/// zip.ExtractExistingFile= ExtractExistingFileAction.OverwriteSilently;
|
||||
/// zip.ExtractAll(TargetDirectory);
|
||||
/// }
|
||||
/// </code>
|
||||
///
|
||||
/// <code lang="VB">
|
||||
/// Dim TargetDirectory As String = "unpack"
|
||||
/// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
|
||||
/// zip.ExtractExistingFile= ExtractExistingFileAction.OverwriteSilently
|
||||
/// zip.ExtractAll(TargetDirectory)
|
||||
/// End Using
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <seealso cref="Ionic.Zip.ZipFile.ExtractProgress"/>
|
||||
/// <seealso cref="Ionic.Zip.ZipFile.ExtractExistingFile"/>
|
||||
///
|
||||
/// <param name="path">
|
||||
/// The path to which the contents of the zipfile will be extracted.
|
||||
/// The path can be relative or fully-qualified.
|
||||
/// </param>
|
||||
///
|
||||
public void ExtractAll(string path)
|
||||
{
|
||||
_InternalExtractAll(path, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all of the items in the zip archive, to the specified path in the
|
||||
/// filesystem, using the specified behavior when extraction would overwrite an
|
||||
/// existing file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// This method will extract all entries in the <c>ZipFile</c> to the specified
|
||||
/// path. For an extraction that would overwrite an existing file, the behavior
|
||||
/// is dictated by <paramref name="extractExistingFile"/>, which overrides any
|
||||
/// setting you may have made on individual ZipEntry instances.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The action to take when an extract would overwrite an existing file
|
||||
/// applies to all entries. If you want to set this on a per-entry basis,
|
||||
/// then you must use <see cref="ZipEntry.Extract(String,
|
||||
/// ExtractExistingFileAction)" /> or one of the similar methods.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Calling this method is equivalent to setting the <see
|
||||
/// cref="ExtractExistingFile"/> property and then calling <see
|
||||
/// cref="ExtractAll(String)"/>.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method will send verbose output messages to the
|
||||
/// <see cref="StatusMessageTextWriter"/>, if it is set on the <c>ZipFile</c> instance.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
///
|
||||
/// <example>
|
||||
/// This example extracts all the entries in a zip archive file, to the
|
||||
/// specified target directory. It does not overwrite any existing files.
|
||||
/// <code>
|
||||
/// String TargetDirectory= "c:\\unpack";
|
||||
/// using(ZipFile zip= ZipFile.Read(ZipFileToExtract))
|
||||
/// {
|
||||
/// zip.ExtractAll(TargetDirectory, ExtractExistingFileAction.DontOverwrite);
|
||||
/// }
|
||||
/// </code>
|
||||
///
|
||||
/// <code lang="VB">
|
||||
/// Dim TargetDirectory As String = "c:\unpack"
|
||||
/// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
|
||||
/// zip.ExtractAll(TargetDirectory, ExtractExistingFileAction.DontOverwrite)
|
||||
/// End Using
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <param name="path">
|
||||
/// The path to which the contents of the zipfile will be extracted.
|
||||
/// The path can be relative or fully-qualified.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="extractExistingFile">
|
||||
/// The action to take if extraction would overwrite an existing file.
|
||||
/// </param>
|
||||
/// <seealso cref="ExtractSelectedEntries(String,ExtractExistingFileAction)"/>
|
||||
public void ExtractAll(string path, ExtractExistingFileAction extractExistingFile)
|
||||
{
|
||||
ExtractExistingFile = extractExistingFile;
|
||||
_InternalExtractAll(path, true);
|
||||
}
|
||||
|
||||
|
||||
private void _InternalExtractAll(string path, bool overrideExtractExistingProperty)
|
||||
{
|
||||
bool header = Verbose;
|
||||
_inExtractAll = true;
|
||||
try
|
||||
{
|
||||
OnExtractAllStarted(path);
|
||||
|
||||
int n = 0;
|
||||
foreach (ZipEntry e in _entries.Values)
|
||||
{
|
||||
if (header)
|
||||
{
|
||||
StatusMessageTextWriter.WriteLine("\n{1,-22} {2,-8} {3,4} {4,-8} {0}",
|
||||
"Name", "Modified", "Size", "Ratio", "Packed");
|
||||
StatusMessageTextWriter.WriteLine(new System.String('-', 72));
|
||||
header = false;
|
||||
}
|
||||
if (Verbose)
|
||||
{
|
||||
StatusMessageTextWriter.WriteLine("{1,-22} {2,-8} {3,4:F0}% {4,-8} {0}",
|
||||
e.FileName,
|
||||
e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
e.UncompressedSize,
|
||||
e.CompressionRatio,
|
||||
e.CompressedSize);
|
||||
if (!String.IsNullOrEmpty(e.Comment))
|
||||
StatusMessageTextWriter.WriteLine(" Comment: {0}", e.Comment);
|
||||
}
|
||||
e.Password = _Password; // this may be null
|
||||
OnExtractEntry(n, true, e, path);
|
||||
if (overrideExtractExistingProperty)
|
||||
e.ExtractExistingFile = this.ExtractExistingFile;
|
||||
e.Extract(path);
|
||||
n++;
|
||||
OnExtractEntry(n, false, e, path);
|
||||
if (_extractOperationCanceled)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_extractOperationCanceled)
|
||||
{
|
||||
// workitem 8264:
|
||||
// now, set times on directory entries, again.
|
||||
// The problem is, extracting a file changes the times on the parent
|
||||
// directory. So after all files have been extracted, we have to
|
||||
// run through the directories again.
|
||||
foreach (ZipEntry e in _entries.Values)
|
||||
{
|
||||
// check if it is a directory
|
||||
if ((e.IsDirectory) || (e.FileName.EndsWith("/")))
|
||||
{
|
||||
string outputFile = (e.FileName.StartsWith("/"))
|
||||
? Path.Combine(path, e.FileName.Substring(1))
|
||||
: Path.Combine(path, e.FileName);
|
||||
|
||||
e._SetTimes(outputFile, false);
|
||||
}
|
||||
}
|
||||
OnExtractAllCompleted(path);
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
_inExtractAll = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// ZipFile.Extract.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2011-July-31 14:45:18>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines the methods for Extract operations on zip files.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
|
||||
public partial class ZipFile
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all of the items in the zip archive, to the specified path in the
|
||||
/// filesystem. The path can be relative or fully-qualified.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// This method will extract all entries in the <c>ZipFile</c> to the
|
||||
/// specified path.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// If an extraction of a file from the zip archive would overwrite an
|
||||
/// existing file in the filesystem, the action taken is dictated by the
|
||||
/// ExtractExistingFile property, which overrides any setting you may have
|
||||
/// made on individual ZipEntry instances. By default, if you have not
|
||||
/// set that property on the <c>ZipFile</c> instance, the entry will not
|
||||
/// be extracted, the existing file will not be overwritten and an
|
||||
/// exception will be thrown. To change this, set the property, or use the
|
||||
/// <see cref="ZipFile.ExtractAll(string,
|
||||
/// Ionic.Zip.ExtractExistingFileAction)" /> overload that allows you to
|
||||
/// specify an ExtractExistingFileAction parameter.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The action to take when an extract would overwrite an existing file
|
||||
/// applies to all entries. If you want to set this on a per-entry basis,
|
||||
/// then you must use one of the <see
|
||||
/// cref="ZipEntry.Extract()">ZipEntry.Extract</see> methods.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method will send verbose output messages to the <see
|
||||
/// cref="StatusMessageTextWriter"/>, if it is set on the <c>ZipFile</c>
|
||||
/// instance.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// You may wish to take advantage of the <c>ExtractProgress</c> event.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// About timestamps: When extracting a file entry from a zip archive, the
|
||||
/// extracted file gets the last modified time of the entry as stored in
|
||||
/// the archive. The archive may also store extended file timestamp
|
||||
/// information, including last accessed and created times. If these are
|
||||
/// present in the <c>ZipEntry</c>, then the extracted file will also get
|
||||
/// these times.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// A Directory entry is somewhat different. It will get the times as
|
||||
/// described for a file entry, but, if there are file entries in the zip
|
||||
/// archive that, when extracted, appear in the just-created directory,
|
||||
/// then when those file entries are extracted, the last modified and last
|
||||
/// accessed times of the directory will change, as a side effect. The
|
||||
/// result is that after an extraction of a directory and a number of
|
||||
/// files within the directory, the last modified and last accessed
|
||||
/// timestamps on the directory will reflect the time that the last file
|
||||
/// was extracted into the directory, rather than the time stored in the
|
||||
/// zip archive for the directory.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// To compensate, when extracting an archive with <c>ExtractAll</c>,
|
||||
/// DotNetZip will extract all the file and directory entries as described
|
||||
/// above, but it will then make a second pass on the directories, and
|
||||
/// reset the times on the directories to reflect what is stored in the
|
||||
/// zip archive.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This compensation is performed only within the context of an
|
||||
/// <c>ExtractAll</c>. If you call <c>ZipEntry.Extract</c> on a directory
|
||||
/// entry, the timestamps on directory in the filesystem will reflect the
|
||||
/// times stored in the zip. If you then call <c>ZipEntry.Extract</c> on
|
||||
/// a file entry, which is extracted into the directory, the timestamps on
|
||||
/// the directory will be updated to the current time.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
///
|
||||
/// <example>
|
||||
/// This example extracts all the entries in a zip archive file, to the
|
||||
/// specified target directory. The extraction will overwrite any
|
||||
/// existing files silently.
|
||||
///
|
||||
/// <code>
|
||||
/// String TargetDirectory= "unpack";
|
||||
/// using(ZipFile zip= ZipFile.Read(ZipFileToExtract))
|
||||
/// {
|
||||
/// zip.ExtractExistingFile= ExtractExistingFileAction.OverwriteSilently;
|
||||
/// zip.ExtractAll(TargetDirectory);
|
||||
/// }
|
||||
/// </code>
|
||||
///
|
||||
/// <code lang="VB">
|
||||
/// Dim TargetDirectory As String = "unpack"
|
||||
/// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
|
||||
/// zip.ExtractExistingFile= ExtractExistingFileAction.OverwriteSilently
|
||||
/// zip.ExtractAll(TargetDirectory)
|
||||
/// End Using
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <seealso cref="Ionic.Zip.ZipFile.ExtractProgress"/>
|
||||
/// <seealso cref="Ionic.Zip.ZipFile.ExtractExistingFile"/>
|
||||
///
|
||||
/// <param name="path">
|
||||
/// The path to which the contents of the zipfile will be extracted.
|
||||
/// The path can be relative or fully-qualified.
|
||||
/// </param>
|
||||
///
|
||||
public void ExtractAll(string path)
|
||||
{
|
||||
_InternalExtractAll(path, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all of the items in the zip archive, to the specified path in the
|
||||
/// filesystem, using the specified behavior when extraction would overwrite an
|
||||
/// existing file.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
///
|
||||
/// <para>
|
||||
/// This method will extract all entries in the <c>ZipFile</c> to the specified
|
||||
/// path. For an extraction that would overwrite an existing file, the behavior
|
||||
/// is dictated by <paramref name="extractExistingFile"/>, which overrides any
|
||||
/// setting you may have made on individual ZipEntry instances.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// The action to take when an extract would overwrite an existing file
|
||||
/// applies to all entries. If you want to set this on a per-entry basis,
|
||||
/// then you must use <see cref="ZipEntry.Extract(String,
|
||||
/// ExtractExistingFileAction)" /> or one of the similar methods.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// Calling this method is equivalent to setting the <see
|
||||
/// cref="ExtractExistingFile"/> property and then calling <see
|
||||
/// cref="ExtractAll(String)"/>.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This method will send verbose output messages to the
|
||||
/// <see cref="StatusMessageTextWriter"/>, if it is set on the <c>ZipFile</c> instance.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
///
|
||||
/// <example>
|
||||
/// This example extracts all the entries in a zip archive file, to the
|
||||
/// specified target directory. It does not overwrite any existing files.
|
||||
/// <code>
|
||||
/// String TargetDirectory= "c:\\unpack";
|
||||
/// using(ZipFile zip= ZipFile.Read(ZipFileToExtract))
|
||||
/// {
|
||||
/// zip.ExtractAll(TargetDirectory, ExtractExistingFileAction.DontOverwrite);
|
||||
/// }
|
||||
/// </code>
|
||||
///
|
||||
/// <code lang="VB">
|
||||
/// Dim TargetDirectory As String = "c:\unpack"
|
||||
/// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
|
||||
/// zip.ExtractAll(TargetDirectory, ExtractExistingFileAction.DontOverwrite)
|
||||
/// End Using
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <param name="path">
|
||||
/// The path to which the contents of the zipfile will be extracted.
|
||||
/// The path can be relative or fully-qualified.
|
||||
/// </param>
|
||||
///
|
||||
/// <param name="extractExistingFile">
|
||||
/// The action to take if extraction would overwrite an existing file.
|
||||
/// </param>
|
||||
/// <seealso cref="ExtractSelectedEntries(String,ExtractExistingFileAction)"/>
|
||||
public void ExtractAll(string path, ExtractExistingFileAction extractExistingFile)
|
||||
{
|
||||
ExtractExistingFile = extractExistingFile;
|
||||
_InternalExtractAll(path, true);
|
||||
}
|
||||
|
||||
|
||||
private void _InternalExtractAll(string path, bool overrideExtractExistingProperty)
|
||||
{
|
||||
bool header = Verbose;
|
||||
_inExtractAll = true;
|
||||
try
|
||||
{
|
||||
OnExtractAllStarted(path);
|
||||
|
||||
int n = 0;
|
||||
foreach (ZipEntry e in _entries.Values)
|
||||
{
|
||||
if (header)
|
||||
{
|
||||
StatusMessageTextWriter.WriteLine("\n{1,-22} {2,-8} {3,4} {4,-8} {0}",
|
||||
"Name", "Modified", "Size", "Ratio", "Packed");
|
||||
StatusMessageTextWriter.WriteLine(new System.String('-', 72));
|
||||
header = false;
|
||||
}
|
||||
if (Verbose)
|
||||
{
|
||||
StatusMessageTextWriter.WriteLine("{1,-22} {2,-8} {3,4:F0}% {4,-8} {0}",
|
||||
e.FileName,
|
||||
e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
e.UncompressedSize,
|
||||
e.CompressionRatio,
|
||||
e.CompressedSize);
|
||||
if (!String.IsNullOrEmpty(e.Comment))
|
||||
StatusMessageTextWriter.WriteLine(" Comment: {0}", e.Comment);
|
||||
}
|
||||
e.Password = _Password; // this may be null
|
||||
OnExtractEntry(n, true, e, path);
|
||||
if (overrideExtractExistingProperty)
|
||||
e.ExtractExistingFile = this.ExtractExistingFile;
|
||||
e.Extract(path);
|
||||
n++;
|
||||
OnExtractEntry(n, false, e, path);
|
||||
if (_extractOperationCanceled)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_extractOperationCanceled)
|
||||
{
|
||||
// workitem 8264:
|
||||
// now, set times on directory entries, again.
|
||||
// The problem is, extracting a file changes the times on the parent
|
||||
// directory. So after all files have been extracted, we have to
|
||||
// run through the directories again.
|
||||
foreach (ZipEntry e in _entries.Values)
|
||||
{
|
||||
// check if it is a directory
|
||||
if ((e.IsDirectory) || (e.FileName.EndsWith("/")))
|
||||
{
|
||||
string outputFile = (e.FileName.StartsWith("/"))
|
||||
? Path.Combine(path, e.FileName.Substring(1))
|
||||
: Path.Combine(path, e.FileName);
|
||||
|
||||
e._SetTimes(outputFile, false);
|
||||
}
|
||||
}
|
||||
OnExtractAllCompleted(path);
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
_inExtractAll = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,154 +1,154 @@
|
||||
// ZipFile.x-IEnumerable.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2006, 2007, 2008, 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-December-26 15:13:26>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines smoe methods for IEnumerable support. It is
|
||||
// particularly important for COM to have these things in a separate module.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
|
||||
// For some weird reason, the method with the DispId(-4) attribute, which is used as
|
||||
// the _NewEnum() method, and which is required to get enumeration to work from COM
|
||||
// environments like VBScript and Javascript (etc) must be the LAST MEMBER in the
|
||||
// source. In the event of Partial classes, it needs to be the last member defined
|
||||
// in the last source module. The source modules are ordered alphabetically by
|
||||
// filename. Not sure why this is true. In any case, we put the enumeration stuff
|
||||
// here in this oddly-named module, for this reason.
|
||||
//
|
||||
|
||||
|
||||
|
||||
public partial class ZipFile
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Generic IEnumerator support, for use of a ZipFile in an enumeration.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// You probably do not want to call <c>GetEnumerator</c> explicitly. Instead
|
||||
/// it is implicitly called when you use a <see langword="foreach"/> loop in C#, or a
|
||||
/// <c>For Each</c> loop in VB.NET.
|
||||
/// </remarks>
|
||||
///
|
||||
/// <example>
|
||||
/// This example reads a zipfile of a given name, then enumerates the
|
||||
/// entries in that zip file, and displays the information about each
|
||||
/// entry on the Console.
|
||||
/// <code>
|
||||
/// using (ZipFile zip = ZipFile.Read(zipfile))
|
||||
/// {
|
||||
/// bool header = true;
|
||||
/// foreach (ZipEntry e in zip)
|
||||
/// {
|
||||
/// if (header)
|
||||
/// {
|
||||
/// System.Console.WriteLine("Zipfile: {0}", zip.Name);
|
||||
/// System.Console.WriteLine("Version Needed: 0x{0:X2}", e.VersionNeeded);
|
||||
/// System.Console.WriteLine("BitField: 0x{0:X2}", e.BitField);
|
||||
/// System.Console.WriteLine("Compression Method: 0x{0:X2}", e.CompressionMethod);
|
||||
/// System.Console.WriteLine("\n{1,-22} {2,-6} {3,4} {4,-8} {0}",
|
||||
/// "Filename", "Modified", "Size", "Ratio", "Packed");
|
||||
/// System.Console.WriteLine(new System.String('-', 72));
|
||||
/// header = false;
|
||||
/// }
|
||||
///
|
||||
/// System.Console.WriteLine("{1,-22} {2,-6} {3,4:F0}% {4,-8} {0}",
|
||||
/// e.FileName,
|
||||
/// e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
/// e.UncompressedSize,
|
||||
/// e.CompressionRatio,
|
||||
/// e.CompressedSize);
|
||||
///
|
||||
/// e.Extract();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
///
|
||||
/// <code lang="VB">
|
||||
/// Dim ZipFileToExtract As String = "c:\foo.zip"
|
||||
/// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
|
||||
/// Dim header As Boolean = True
|
||||
/// Dim e As ZipEntry
|
||||
/// For Each e In zip
|
||||
/// If header Then
|
||||
/// Console.WriteLine("Zipfile: {0}", zip.Name)
|
||||
/// Console.WriteLine("Version Needed: 0x{0:X2}", e.VersionNeeded)
|
||||
/// Console.WriteLine("BitField: 0x{0:X2}", e.BitField)
|
||||
/// Console.WriteLine("Compression Method: 0x{0:X2}", e.CompressionMethod)
|
||||
/// Console.WriteLine(ChrW(10) & "{1,-22} {2,-6} {3,4} {4,-8} {0}", _
|
||||
/// "Filename", "Modified", "Size", "Ratio", "Packed" )
|
||||
/// Console.WriteLine(New String("-"c, 72))
|
||||
/// header = False
|
||||
/// End If
|
||||
/// Console.WriteLine("{1,-22} {2,-6} {3,4:F0}% {4,-8} {0}", _
|
||||
/// e.FileName, _
|
||||
/// e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"), _
|
||||
/// e.UncompressedSize, _
|
||||
/// e.CompressionRatio, _
|
||||
/// e.CompressedSize )
|
||||
/// e.Extract
|
||||
/// Next
|
||||
/// End Using
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <returns>A generic enumerator suitable for use within a foreach loop.</returns>
|
||||
public System.Collections.Generic.IEnumerator<ZipEntry> GetEnumerator()
|
||||
{
|
||||
foreach (ZipEntry e in _entries.Values)
|
||||
yield return e;
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// An IEnumerator, for use of a ZipFile in a foreach construct.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This method is included for COM support. An application generally does not call
|
||||
/// this method directly. It is called implicitly by COM clients when enumerating
|
||||
/// the entries in the ZipFile instance. In VBScript, this is done with a <c>For Each</c>
|
||||
/// statement. In Javascript, this is done with <c>new Enumerator(zipfile)</c>.
|
||||
/// </remarks>
|
||||
///
|
||||
/// <returns>
|
||||
/// The IEnumerator over the entries in the ZipFile.
|
||||
/// </returns>
|
||||
[System.Runtime.InteropServices.DispId(-4)]
|
||||
public System.Collections.IEnumerator GetNewEnum() // the name of this method is not significant
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// ZipFile.x-IEnumerable.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2006, 2007, 2008, 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-December-26 15:13:26>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines smoe methods for IEnumerable support. It is
|
||||
// particularly important for COM to have these things in a separate module.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Ionic.Zip
|
||||
{
|
||||
|
||||
// For some weird reason, the method with the DispId(-4) attribute, which is used as
|
||||
// the _NewEnum() method, and which is required to get enumeration to work from COM
|
||||
// environments like VBScript and Javascript (etc) must be the LAST MEMBER in the
|
||||
// source. In the event of Partial classes, it needs to be the last member defined
|
||||
// in the last source module. The source modules are ordered alphabetically by
|
||||
// filename. Not sure why this is true. In any case, we put the enumeration stuff
|
||||
// here in this oddly-named module, for this reason.
|
||||
//
|
||||
|
||||
|
||||
|
||||
public partial class ZipFile
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Generic IEnumerator support, for use of a ZipFile in an enumeration.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// You probably do not want to call <c>GetEnumerator</c> explicitly. Instead
|
||||
/// it is implicitly called when you use a <see langword="foreach"/> loop in C#, or a
|
||||
/// <c>For Each</c> loop in VB.NET.
|
||||
/// </remarks>
|
||||
///
|
||||
/// <example>
|
||||
/// This example reads a zipfile of a given name, then enumerates the
|
||||
/// entries in that zip file, and displays the information about each
|
||||
/// entry on the Console.
|
||||
/// <code>
|
||||
/// using (ZipFile zip = ZipFile.Read(zipfile))
|
||||
/// {
|
||||
/// bool header = true;
|
||||
/// foreach (ZipEntry e in zip)
|
||||
/// {
|
||||
/// if (header)
|
||||
/// {
|
||||
/// System.Console.WriteLine("Zipfile: {0}", zip.Name);
|
||||
/// System.Console.WriteLine("Version Needed: 0x{0:X2}", e.VersionNeeded);
|
||||
/// System.Console.WriteLine("BitField: 0x{0:X2}", e.BitField);
|
||||
/// System.Console.WriteLine("Compression Method: 0x{0:X2}", e.CompressionMethod);
|
||||
/// System.Console.WriteLine("\n{1,-22} {2,-6} {3,4} {4,-8} {0}",
|
||||
/// "Filename", "Modified", "Size", "Ratio", "Packed");
|
||||
/// System.Console.WriteLine(new System.String('-', 72));
|
||||
/// header = false;
|
||||
/// }
|
||||
///
|
||||
/// System.Console.WriteLine("{1,-22} {2,-6} {3,4:F0}% {4,-8} {0}",
|
||||
/// e.FileName,
|
||||
/// e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
/// e.UncompressedSize,
|
||||
/// e.CompressionRatio,
|
||||
/// e.CompressedSize);
|
||||
///
|
||||
/// e.Extract();
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
///
|
||||
/// <code lang="VB">
|
||||
/// Dim ZipFileToExtract As String = "c:\foo.zip"
|
||||
/// Using zip As ZipFile = ZipFile.Read(ZipFileToExtract)
|
||||
/// Dim header As Boolean = True
|
||||
/// Dim e As ZipEntry
|
||||
/// For Each e In zip
|
||||
/// If header Then
|
||||
/// Console.WriteLine("Zipfile: {0}", zip.Name)
|
||||
/// Console.WriteLine("Version Needed: 0x{0:X2}", e.VersionNeeded)
|
||||
/// Console.WriteLine("BitField: 0x{0:X2}", e.BitField)
|
||||
/// Console.WriteLine("Compression Method: 0x{0:X2}", e.CompressionMethod)
|
||||
/// Console.WriteLine(ChrW(10) & "{1,-22} {2,-6} {3,4} {4,-8} {0}", _
|
||||
/// "Filename", "Modified", "Size", "Ratio", "Packed" )
|
||||
/// Console.WriteLine(New String("-"c, 72))
|
||||
/// header = False
|
||||
/// End If
|
||||
/// Console.WriteLine("{1,-22} {2,-6} {3,4:F0}% {4,-8} {0}", _
|
||||
/// e.FileName, _
|
||||
/// e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"), _
|
||||
/// e.UncompressedSize, _
|
||||
/// e.CompressionRatio, _
|
||||
/// e.CompressedSize )
|
||||
/// e.Extract
|
||||
/// Next
|
||||
/// End Using
|
||||
/// </code>
|
||||
/// </example>
|
||||
///
|
||||
/// <returns>A generic enumerator suitable for use within a foreach loop.</returns>
|
||||
public System.Collections.Generic.IEnumerator<ZipEntry> GetEnumerator()
|
||||
{
|
||||
foreach (ZipEntry e in _entries.Values)
|
||||
yield return e;
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// An IEnumerator, for use of a ZipFile in a foreach construct.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks>
|
||||
/// This method is included for COM support. An application generally does not call
|
||||
/// this method directly. It is called implicitly by COM clients when enumerating
|
||||
/// the entries in the ZipFile instance. In VBScript, this is done with a <c>For Each</c>
|
||||
/// statement. In Javascript, this is done with <c>new Enumerator(zipfile)</c>.
|
||||
/// </remarks>
|
||||
///
|
||||
/// <returns>
|
||||
/// The IEnumerator over the entries in the ZipFile.
|
||||
/// </returns>
|
||||
[System.Runtime.InteropServices.DispId(-4)]
|
||||
public System.Collections.IEnumerator GetNewEnum() // the name of this method is not significant
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,436 +1,436 @@
|
||||
// Inftree.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-October-28 12:43:54>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines classes used in decompression. This code is derived
|
||||
// from the jzlib implementation of zlib. In keeping with the license for jzlib,
|
||||
// the copyright to that code is below.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in
|
||||
// the documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The names of the authors may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
// This program is based on zlib-1.1.3; credit to authors
|
||||
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||
// and contributors of zlib.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
using System;
|
||||
namespace Ionic.Zlib
|
||||
{
|
||||
|
||||
sealed class InfTree
|
||||
{
|
||||
|
||||
private const int MANY = 1440;
|
||||
|
||||
private const int Z_OK = 0;
|
||||
private const int Z_STREAM_END = 1;
|
||||
private const int Z_NEED_DICT = 2;
|
||||
private const int Z_ERRNO = - 1;
|
||||
private const int Z_STREAM_ERROR = - 2;
|
||||
private const int Z_DATA_ERROR = - 3;
|
||||
private const int Z_MEM_ERROR = - 4;
|
||||
private const int Z_BUF_ERROR = - 5;
|
||||
private const int Z_VERSION_ERROR = - 6;
|
||||
|
||||
internal const int fixed_bl = 9;
|
||||
internal const int fixed_bd = 5;
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'fixed_tl'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186,
|
||||
0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8,
|
||||
14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255};
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'fixed_td'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] fixed_td = new int[]{80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577};
|
||||
|
||||
// Tables for deflate from PKZIP's appnote.txt.
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cplens'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cplens = new int[]{3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
|
||||
// see note #13 above about 258
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cplext'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cplext = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112};
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cpdist'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cpdist = new int[]{1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cpdext'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cpdext = new int[]{0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
|
||||
|
||||
// If BMAX needs to be larger than 16, then h and x[] should be uLong.
|
||||
internal const int BMAX = 15; // maximum bit length of any code
|
||||
|
||||
internal int[] hn = null; // hufts used in space
|
||||
internal int[] v = null; // work area for huft_build
|
||||
internal int[] c = null; // bit length count table
|
||||
internal int[] r = null; // table entry for structure assignment
|
||||
internal int[] u = null; // table stack
|
||||
internal int[] x = null; // bit offsets, then code stack
|
||||
|
||||
private int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v)
|
||||
{
|
||||
// Given a list of code lengths and a maximum table size, make a set of
|
||||
// tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
|
||||
// if the given code set is incomplete (the tables are still built in this
|
||||
// case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
|
||||
// lengths), or Z_MEM_ERROR if not enough memory.
|
||||
|
||||
int a; // counter for codes of length k
|
||||
int f; // i repeats in table every f entries
|
||||
int g; // maximum code length
|
||||
int h; // table level
|
||||
int i; // counter, current code
|
||||
int j; // counter
|
||||
int k; // number of bits in current code
|
||||
int l; // bits per table (returned in m)
|
||||
int mask; // (1 << w) - 1, to avoid cc -O bug on HP
|
||||
int p; // pointer into c[], b[], or v[]
|
||||
int q; // points to current table
|
||||
int w; // bits before this table == (l * h)
|
||||
int xp; // pointer into x
|
||||
int y; // number of dummy codes added
|
||||
int z; // number of entries in current table
|
||||
|
||||
// Generate counts for each bit length
|
||||
|
||||
p = 0; i = n;
|
||||
do
|
||||
{
|
||||
c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX
|
||||
}
|
||||
while (i != 0);
|
||||
|
||||
if (c[0] == n)
|
||||
{
|
||||
// null input--all zero length codes
|
||||
t[0] = - 1;
|
||||
m[0] = 0;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
// Find minimum and maximum length, bound *m by those
|
||||
l = m[0];
|
||||
for (j = 1; j <= BMAX; j++)
|
||||
if (c[j] != 0)
|
||||
break;
|
||||
k = j; // minimum code length
|
||||
if (l < j)
|
||||
{
|
||||
l = j;
|
||||
}
|
||||
for (i = BMAX; i != 0; i--)
|
||||
{
|
||||
if (c[i] != 0)
|
||||
break;
|
||||
}
|
||||
g = i; // maximum code length
|
||||
if (l > i)
|
||||
{
|
||||
l = i;
|
||||
}
|
||||
m[0] = l;
|
||||
|
||||
// Adjust last length count to fill out codes, if needed
|
||||
for (y = 1 << j; j < i; j++, y <<= 1)
|
||||
{
|
||||
if ((y -= c[j]) < 0)
|
||||
{
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
}
|
||||
if ((y -= c[i]) < 0)
|
||||
{
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
c[i] += y;
|
||||
|
||||
// Generate starting offsets into the value table for each length
|
||||
x[1] = j = 0;
|
||||
p = 1; xp = 2;
|
||||
while (--i != 0)
|
||||
{
|
||||
// note that i == g from above
|
||||
x[xp] = (j += c[p]);
|
||||
xp++;
|
||||
p++;
|
||||
}
|
||||
|
||||
// Make a table of values in order of bit lengths
|
||||
i = 0; p = 0;
|
||||
do
|
||||
{
|
||||
if ((j = b[bindex + p]) != 0)
|
||||
{
|
||||
v[x[j]++] = i;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
while (++i < n);
|
||||
n = x[g]; // set n to length of v
|
||||
|
||||
// Generate the Huffman codes and for each, make the table entries
|
||||
x[0] = i = 0; // first Huffman code is zero
|
||||
p = 0; // grab values in bit order
|
||||
h = - 1; // no tables yet--level -1
|
||||
w = - l; // bits decoded == (l * h)
|
||||
u[0] = 0; // just to keep compilers happy
|
||||
q = 0; // ditto
|
||||
z = 0; // ditto
|
||||
|
||||
// go through the bit lengths (k already is bits in shortest code)
|
||||
for (; k <= g; k++)
|
||||
{
|
||||
a = c[k];
|
||||
while (a-- != 0)
|
||||
{
|
||||
// here i is the Huffman code of length k bits for value *p
|
||||
// make tables up to required level
|
||||
while (k > w + l)
|
||||
{
|
||||
h++;
|
||||
w += l; // previous table always l bits
|
||||
// compute minimum size table less than or equal to l bits
|
||||
z = g - w;
|
||||
z = (z > l)?l:z; // table size upper limit
|
||||
if ((f = 1 << (j = k - w)) > a + 1)
|
||||
{
|
||||
// try a k-w bit table
|
||||
// too few codes for k-w bit table
|
||||
f -= (a + 1); // deduct codes from patterns left
|
||||
xp = k;
|
||||
if (j < z)
|
||||
{
|
||||
while (++j < z)
|
||||
{
|
||||
// try smaller tables up to z bits
|
||||
if ((f <<= 1) <= c[++xp])
|
||||
break; // enough codes to use up j bits
|
||||
f -= c[xp]; // else deduct codes from patterns
|
||||
}
|
||||
}
|
||||
}
|
||||
z = 1 << j; // table entries for j-bit table
|
||||
|
||||
// allocate new table
|
||||
if (hn[0] + z > MANY)
|
||||
{
|
||||
// (note: doesn't matter for fixed)
|
||||
return Z_DATA_ERROR; // overflow of MANY
|
||||
}
|
||||
u[h] = q = hn[0]; // DEBUG
|
||||
hn[0] += z;
|
||||
|
||||
// connect to last table, if there is one
|
||||
if (h != 0)
|
||||
{
|
||||
x[h] = i; // save pattern for backing up
|
||||
r[0] = (sbyte) j; // bits in this table
|
||||
r[1] = (sbyte) l; // bits to dump before this table
|
||||
j = SharedUtils.URShift(i, (w - l));
|
||||
r[2] = (int) (q - u[h - 1] - j); // offset to this table
|
||||
Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table
|
||||
}
|
||||
else
|
||||
{
|
||||
t[0] = q; // first table is returned result
|
||||
}
|
||||
}
|
||||
|
||||
// set up table entry in r
|
||||
r[1] = (sbyte) (k - w);
|
||||
if (p >= n)
|
||||
{
|
||||
r[0] = 128 + 64; // out of values--invalid code
|
||||
}
|
||||
else if (v[p] < s)
|
||||
{
|
||||
r[0] = (sbyte) (v[p] < 256?0:32 + 64); // 256 is end-of-block
|
||||
r[2] = v[p++]; // simple code is just the value
|
||||
}
|
||||
else
|
||||
{
|
||||
r[0] = (sbyte) (e[v[p] - s] + 16 + 64); // non-simple--look up in lists
|
||||
r[2] = d[v[p++] - s];
|
||||
}
|
||||
|
||||
// fill code-like entries with r
|
||||
f = 1 << (k - w);
|
||||
for (j = SharedUtils.URShift(i, w); j < z; j += f)
|
||||
{
|
||||
Array.Copy(r, 0, hp, (q + j) * 3, 3);
|
||||
}
|
||||
|
||||
// backwards increment the k-bit code i
|
||||
for (j = 1 << (k - 1); (i & j) != 0; j = SharedUtils.URShift(j, 1))
|
||||
{
|
||||
i ^= j;
|
||||
}
|
||||
i ^= j;
|
||||
|
||||
// backup over finished tables
|
||||
mask = (1 << w) - 1; // needed on HP, cc -O bug
|
||||
while ((i & mask) != x[h])
|
||||
{
|
||||
h--; // don't need to update q
|
||||
w -= l;
|
||||
mask = (1 << w) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Return Z_BUF_ERROR if we were given an incomplete table
|
||||
return y != 0 && g != 1?Z_BUF_ERROR:Z_OK;
|
||||
}
|
||||
|
||||
internal int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZlibCodec z)
|
||||
{
|
||||
int result;
|
||||
initWorkArea(19);
|
||||
hn[0] = 0;
|
||||
result = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);
|
||||
|
||||
if (result == Z_DATA_ERROR)
|
||||
{
|
||||
z.Message = "oversubscribed dynamic bit lengths tree";
|
||||
}
|
||||
else if (result == Z_BUF_ERROR || bb[0] == 0)
|
||||
{
|
||||
z.Message = "incomplete dynamic bit lengths tree";
|
||||
result = Z_DATA_ERROR;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZlibCodec z)
|
||||
{
|
||||
int result;
|
||||
|
||||
// build literal/length tree
|
||||
initWorkArea(288);
|
||||
hn[0] = 0;
|
||||
result = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
|
||||
if (result != Z_OK || bl[0] == 0)
|
||||
{
|
||||
if (result == Z_DATA_ERROR)
|
||||
{
|
||||
z.Message = "oversubscribed literal/length tree";
|
||||
}
|
||||
else if (result != Z_MEM_ERROR)
|
||||
{
|
||||
z.Message = "incomplete literal/length tree";
|
||||
result = Z_DATA_ERROR;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// build distance tree
|
||||
initWorkArea(288);
|
||||
result = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);
|
||||
|
||||
if (result != Z_OK || (bd[0] == 0 && nl > 257))
|
||||
{
|
||||
if (result == Z_DATA_ERROR)
|
||||
{
|
||||
z.Message = "oversubscribed distance tree";
|
||||
}
|
||||
else if (result == Z_BUF_ERROR)
|
||||
{
|
||||
z.Message = "incomplete distance tree";
|
||||
result = Z_DATA_ERROR;
|
||||
}
|
||||
else if (result != Z_MEM_ERROR)
|
||||
{
|
||||
z.Message = "empty distance tree with lengths";
|
||||
result = Z_DATA_ERROR;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZlibCodec z)
|
||||
{
|
||||
bl[0] = fixed_bl;
|
||||
bd[0] = fixed_bd;
|
||||
tl[0] = fixed_tl;
|
||||
td[0] = fixed_td;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
private void initWorkArea(int vsize)
|
||||
{
|
||||
if (hn == null)
|
||||
{
|
||||
hn = new int[1];
|
||||
v = new int[vsize];
|
||||
c = new int[BMAX + 1];
|
||||
r = new int[3];
|
||||
u = new int[BMAX];
|
||||
x = new int[BMAX + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (v.Length < vsize)
|
||||
{
|
||||
v = new int[vsize];
|
||||
}
|
||||
Array.Clear(v,0,vsize);
|
||||
Array.Clear(c,0,BMAX+1);
|
||||
r[0]=0; r[1]=0; r[2]=0;
|
||||
// for(int i=0; i<BMAX; i++){u[i]=0;}
|
||||
//Array.Copy(c, 0, u, 0, BMAX);
|
||||
Array.Clear(u,0,BMAX);
|
||||
// for(int i=0; i<BMAX+1; i++){x[i]=0;}
|
||||
//Array.Copy(c, 0, x, 0, BMAX + 1);
|
||||
Array.Clear(x,0,BMAX+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Inftree.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-October-28 12:43:54>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines classes used in decompression. This code is derived
|
||||
// from the jzlib implementation of zlib. In keeping with the license for jzlib,
|
||||
// the copyright to that code is below.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in
|
||||
// the documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The names of the authors may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
// This program is based on zlib-1.1.3; credit to authors
|
||||
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||
// and contributors of zlib.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
using System;
|
||||
namespace Ionic.Zlib
|
||||
{
|
||||
|
||||
sealed class InfTree
|
||||
{
|
||||
|
||||
private const int MANY = 1440;
|
||||
|
||||
private const int Z_OK = 0;
|
||||
private const int Z_STREAM_END = 1;
|
||||
private const int Z_NEED_DICT = 2;
|
||||
private const int Z_ERRNO = - 1;
|
||||
private const int Z_STREAM_ERROR = - 2;
|
||||
private const int Z_DATA_ERROR = - 3;
|
||||
private const int Z_MEM_ERROR = - 4;
|
||||
private const int Z_BUF_ERROR = - 5;
|
||||
private const int Z_VERSION_ERROR = - 6;
|
||||
|
||||
internal const int fixed_bl = 9;
|
||||
internal const int fixed_bd = 5;
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'fixed_tl'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] fixed_tl = new int[]{96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186,
|
||||
0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8,
|
||||
14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255};
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'fixed_td'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] fixed_td = new int[]{80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577};
|
||||
|
||||
// Tables for deflate from PKZIP's appnote.txt.
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cplens'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cplens = new int[]{3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
|
||||
// see note #13 above about 258
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cplext'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cplext = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112};
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cpdist'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cpdist = new int[]{1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
|
||||
|
||||
//UPGRADE_NOTE: Final was removed from the declaration of 'cpdext'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
|
||||
internal static readonly int[] cpdext = new int[]{0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
|
||||
|
||||
// If BMAX needs to be larger than 16, then h and x[] should be uLong.
|
||||
internal const int BMAX = 15; // maximum bit length of any code
|
||||
|
||||
internal int[] hn = null; // hufts used in space
|
||||
internal int[] v = null; // work area for huft_build
|
||||
internal int[] c = null; // bit length count table
|
||||
internal int[] r = null; // table entry for structure assignment
|
||||
internal int[] u = null; // table stack
|
||||
internal int[] x = null; // bit offsets, then code stack
|
||||
|
||||
private int huft_build(int[] b, int bindex, int n, int s, int[] d, int[] e, int[] t, int[] m, int[] hp, int[] hn, int[] v)
|
||||
{
|
||||
// Given a list of code lengths and a maximum table size, make a set of
|
||||
// tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
|
||||
// if the given code set is incomplete (the tables are still built in this
|
||||
// case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
|
||||
// lengths), or Z_MEM_ERROR if not enough memory.
|
||||
|
||||
int a; // counter for codes of length k
|
||||
int f; // i repeats in table every f entries
|
||||
int g; // maximum code length
|
||||
int h; // table level
|
||||
int i; // counter, current code
|
||||
int j; // counter
|
||||
int k; // number of bits in current code
|
||||
int l; // bits per table (returned in m)
|
||||
int mask; // (1 << w) - 1, to avoid cc -O bug on HP
|
||||
int p; // pointer into c[], b[], or v[]
|
||||
int q; // points to current table
|
||||
int w; // bits before this table == (l * h)
|
||||
int xp; // pointer into x
|
||||
int y; // number of dummy codes added
|
||||
int z; // number of entries in current table
|
||||
|
||||
// Generate counts for each bit length
|
||||
|
||||
p = 0; i = n;
|
||||
do
|
||||
{
|
||||
c[b[bindex + p]]++; p++; i--; // assume all entries <= BMAX
|
||||
}
|
||||
while (i != 0);
|
||||
|
||||
if (c[0] == n)
|
||||
{
|
||||
// null input--all zero length codes
|
||||
t[0] = - 1;
|
||||
m[0] = 0;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
// Find minimum and maximum length, bound *m by those
|
||||
l = m[0];
|
||||
for (j = 1; j <= BMAX; j++)
|
||||
if (c[j] != 0)
|
||||
break;
|
||||
k = j; // minimum code length
|
||||
if (l < j)
|
||||
{
|
||||
l = j;
|
||||
}
|
||||
for (i = BMAX; i != 0; i--)
|
||||
{
|
||||
if (c[i] != 0)
|
||||
break;
|
||||
}
|
||||
g = i; // maximum code length
|
||||
if (l > i)
|
||||
{
|
||||
l = i;
|
||||
}
|
||||
m[0] = l;
|
||||
|
||||
// Adjust last length count to fill out codes, if needed
|
||||
for (y = 1 << j; j < i; j++, y <<= 1)
|
||||
{
|
||||
if ((y -= c[j]) < 0)
|
||||
{
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
}
|
||||
if ((y -= c[i]) < 0)
|
||||
{
|
||||
return Z_DATA_ERROR;
|
||||
}
|
||||
c[i] += y;
|
||||
|
||||
// Generate starting offsets into the value table for each length
|
||||
x[1] = j = 0;
|
||||
p = 1; xp = 2;
|
||||
while (--i != 0)
|
||||
{
|
||||
// note that i == g from above
|
||||
x[xp] = (j += c[p]);
|
||||
xp++;
|
||||
p++;
|
||||
}
|
||||
|
||||
// Make a table of values in order of bit lengths
|
||||
i = 0; p = 0;
|
||||
do
|
||||
{
|
||||
if ((j = b[bindex + p]) != 0)
|
||||
{
|
||||
v[x[j]++] = i;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
while (++i < n);
|
||||
n = x[g]; // set n to length of v
|
||||
|
||||
// Generate the Huffman codes and for each, make the table entries
|
||||
x[0] = i = 0; // first Huffman code is zero
|
||||
p = 0; // grab values in bit order
|
||||
h = - 1; // no tables yet--level -1
|
||||
w = - l; // bits decoded == (l * h)
|
||||
u[0] = 0; // just to keep compilers happy
|
||||
q = 0; // ditto
|
||||
z = 0; // ditto
|
||||
|
||||
// go through the bit lengths (k already is bits in shortest code)
|
||||
for (; k <= g; k++)
|
||||
{
|
||||
a = c[k];
|
||||
while (a-- != 0)
|
||||
{
|
||||
// here i is the Huffman code of length k bits for value *p
|
||||
// make tables up to required level
|
||||
while (k > w + l)
|
||||
{
|
||||
h++;
|
||||
w += l; // previous table always l bits
|
||||
// compute minimum size table less than or equal to l bits
|
||||
z = g - w;
|
||||
z = (z > l)?l:z; // table size upper limit
|
||||
if ((f = 1 << (j = k - w)) > a + 1)
|
||||
{
|
||||
// try a k-w bit table
|
||||
// too few codes for k-w bit table
|
||||
f -= (a + 1); // deduct codes from patterns left
|
||||
xp = k;
|
||||
if (j < z)
|
||||
{
|
||||
while (++j < z)
|
||||
{
|
||||
// try smaller tables up to z bits
|
||||
if ((f <<= 1) <= c[++xp])
|
||||
break; // enough codes to use up j bits
|
||||
f -= c[xp]; // else deduct codes from patterns
|
||||
}
|
||||
}
|
||||
}
|
||||
z = 1 << j; // table entries for j-bit table
|
||||
|
||||
// allocate new table
|
||||
if (hn[0] + z > MANY)
|
||||
{
|
||||
// (note: doesn't matter for fixed)
|
||||
return Z_DATA_ERROR; // overflow of MANY
|
||||
}
|
||||
u[h] = q = hn[0]; // DEBUG
|
||||
hn[0] += z;
|
||||
|
||||
// connect to last table, if there is one
|
||||
if (h != 0)
|
||||
{
|
||||
x[h] = i; // save pattern for backing up
|
||||
r[0] = (sbyte) j; // bits in this table
|
||||
r[1] = (sbyte) l; // bits to dump before this table
|
||||
j = SharedUtils.URShift(i, (w - l));
|
||||
r[2] = (int) (q - u[h - 1] - j); // offset to this table
|
||||
Array.Copy(r, 0, hp, (u[h - 1] + j) * 3, 3); // connect to last table
|
||||
}
|
||||
else
|
||||
{
|
||||
t[0] = q; // first table is returned result
|
||||
}
|
||||
}
|
||||
|
||||
// set up table entry in r
|
||||
r[1] = (sbyte) (k - w);
|
||||
if (p >= n)
|
||||
{
|
||||
r[0] = 128 + 64; // out of values--invalid code
|
||||
}
|
||||
else if (v[p] < s)
|
||||
{
|
||||
r[0] = (sbyte) (v[p] < 256?0:32 + 64); // 256 is end-of-block
|
||||
r[2] = v[p++]; // simple code is just the value
|
||||
}
|
||||
else
|
||||
{
|
||||
r[0] = (sbyte) (e[v[p] - s] + 16 + 64); // non-simple--look up in lists
|
||||
r[2] = d[v[p++] - s];
|
||||
}
|
||||
|
||||
// fill code-like entries with r
|
||||
f = 1 << (k - w);
|
||||
for (j = SharedUtils.URShift(i, w); j < z; j += f)
|
||||
{
|
||||
Array.Copy(r, 0, hp, (q + j) * 3, 3);
|
||||
}
|
||||
|
||||
// backwards increment the k-bit code i
|
||||
for (j = 1 << (k - 1); (i & j) != 0; j = SharedUtils.URShift(j, 1))
|
||||
{
|
||||
i ^= j;
|
||||
}
|
||||
i ^= j;
|
||||
|
||||
// backup over finished tables
|
||||
mask = (1 << w) - 1; // needed on HP, cc -O bug
|
||||
while ((i & mask) != x[h])
|
||||
{
|
||||
h--; // don't need to update q
|
||||
w -= l;
|
||||
mask = (1 << w) - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Return Z_BUF_ERROR if we were given an incomplete table
|
||||
return y != 0 && g != 1?Z_BUF_ERROR:Z_OK;
|
||||
}
|
||||
|
||||
internal int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZlibCodec z)
|
||||
{
|
||||
int result;
|
||||
initWorkArea(19);
|
||||
hn[0] = 0;
|
||||
result = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);
|
||||
|
||||
if (result == Z_DATA_ERROR)
|
||||
{
|
||||
z.Message = "oversubscribed dynamic bit lengths tree";
|
||||
}
|
||||
else if (result == Z_BUF_ERROR || bb[0] == 0)
|
||||
{
|
||||
z.Message = "incomplete dynamic bit lengths tree";
|
||||
result = Z_DATA_ERROR;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZlibCodec z)
|
||||
{
|
||||
int result;
|
||||
|
||||
// build literal/length tree
|
||||
initWorkArea(288);
|
||||
hn[0] = 0;
|
||||
result = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
|
||||
if (result != Z_OK || bl[0] == 0)
|
||||
{
|
||||
if (result == Z_DATA_ERROR)
|
||||
{
|
||||
z.Message = "oversubscribed literal/length tree";
|
||||
}
|
||||
else if (result != Z_MEM_ERROR)
|
||||
{
|
||||
z.Message = "incomplete literal/length tree";
|
||||
result = Z_DATA_ERROR;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// build distance tree
|
||||
initWorkArea(288);
|
||||
result = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);
|
||||
|
||||
if (result != Z_OK || (bd[0] == 0 && nl > 257))
|
||||
{
|
||||
if (result == Z_DATA_ERROR)
|
||||
{
|
||||
z.Message = "oversubscribed distance tree";
|
||||
}
|
||||
else if (result == Z_BUF_ERROR)
|
||||
{
|
||||
z.Message = "incomplete distance tree";
|
||||
result = Z_DATA_ERROR;
|
||||
}
|
||||
else if (result != Z_MEM_ERROR)
|
||||
{
|
||||
z.Message = "empty distance tree with lengths";
|
||||
result = Z_DATA_ERROR;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZlibCodec z)
|
||||
{
|
||||
bl[0] = fixed_bl;
|
||||
bd[0] = fixed_bd;
|
||||
tl[0] = fixed_tl;
|
||||
td[0] = fixed_td;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
private void initWorkArea(int vsize)
|
||||
{
|
||||
if (hn == null)
|
||||
{
|
||||
hn = new int[1];
|
||||
v = new int[vsize];
|
||||
c = new int[BMAX + 1];
|
||||
r = new int[3];
|
||||
u = new int[BMAX];
|
||||
x = new int[BMAX + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (v.Length < vsize)
|
||||
{
|
||||
v = new int[vsize];
|
||||
}
|
||||
Array.Clear(v,0,vsize);
|
||||
Array.Clear(c,0,BMAX+1);
|
||||
r[0]=0; r[1]=0; r[2]=0;
|
||||
// for(int i=0; i<BMAX; i++){u[i]=0;}
|
||||
//Array.Copy(c, 0, u, 0, BMAX);
|
||||
Array.Clear(u,0,BMAX);
|
||||
// for(int i=0; i<BMAX+1; i++){x[i]=0;}
|
||||
//Array.Copy(c, 0, x, 0, BMAX + 1);
|
||||
Array.Clear(x,0,BMAX+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,423 +1,423 @@
|
||||
// Tree.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-October-28 13:29:50>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines classes for zlib compression and
|
||||
// decompression. This code is derived from the jzlib implementation of
|
||||
// zlib. In keeping with the license for jzlib, the copyright to that
|
||||
// code is below.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in
|
||||
// the documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The names of the authors may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
// This program is based on zlib-1.1.3; credit to authors
|
||||
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||
// and contributors of zlib.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace Ionic.Zlib
|
||||
{
|
||||
sealed class Tree
|
||||
{
|
||||
private static readonly int HEAP_SIZE = (2 * InternalConstants.L_CODES + 1);
|
||||
|
||||
// extra bits for each length code
|
||||
internal static readonly int[] ExtraLengthBits = new int[]
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
|
||||
};
|
||||
|
||||
// extra bits for each distance code
|
||||
internal static readonly int[] ExtraDistanceBits = new int[]
|
||||
{
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13
|
||||
};
|
||||
|
||||
// extra bits for each bit length code
|
||||
internal static readonly int[] extra_blbits = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7};
|
||||
|
||||
internal static readonly sbyte[] bl_order = new sbyte[]{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
||||
|
||||
|
||||
// The lengths of the bit length codes are sent in order of decreasing
|
||||
// probability, to avoid transmitting the lengths for unused bit
|
||||
// length codes.
|
||||
|
||||
internal const int Buf_size = 8 * 2;
|
||||
|
||||
// see definition of array dist_code below
|
||||
//internal const int DIST_CODE_LEN = 512;
|
||||
|
||||
private static readonly sbyte[] _dist_code = new sbyte[]
|
||||
{
|
||||
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||
};
|
||||
|
||||
internal static readonly sbyte[] LengthCode = new sbyte[]
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15,
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17,
|
||||
18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
|
||||
};
|
||||
|
||||
|
||||
internal static readonly int[] LengthBase = new int[]
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28,
|
||||
32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0
|
||||
};
|
||||
|
||||
|
||||
internal static readonly int[] DistanceBase = new int[]
|
||||
{
|
||||
0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192,
|
||||
256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Map from a distance to a distance code.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// No side effects. _dist_code[256] and _dist_code[257] are never used.
|
||||
/// </remarks>
|
||||
internal static int DistanceCode(int dist)
|
||||
{
|
||||
return (dist < 256)
|
||||
? _dist_code[dist]
|
||||
: _dist_code[256 + SharedUtils.URShift(dist, 7)];
|
||||
}
|
||||
|
||||
internal short[] dyn_tree; // the dynamic tree
|
||||
internal int max_code; // largest code with non zero frequency
|
||||
internal StaticTree staticTree; // the corresponding static tree
|
||||
|
||||
// Compute the optimal bit lengths for a tree and update the total bit length
|
||||
// for the current block.
|
||||
// IN assertion: the fields freq and dad are set, heap[heap_max] and
|
||||
// above are the tree nodes sorted by increasing frequency.
|
||||
// OUT assertions: the field len is set to the optimal bit length, the
|
||||
// array bl_count contains the frequencies for each bit length.
|
||||
// The length opt_len is updated; static_len is also updated if stree is
|
||||
// not null.
|
||||
internal void gen_bitlen(DeflateManager s)
|
||||
{
|
||||
short[] tree = dyn_tree;
|
||||
short[] stree = staticTree.treeCodes;
|
||||
int[] extra = staticTree.extraBits;
|
||||
int base_Renamed = staticTree.extraBase;
|
||||
int max_length = staticTree.maxLength;
|
||||
int h; // heap index
|
||||
int n, m; // iterate over the tree elements
|
||||
int bits; // bit length
|
||||
int xbits; // extra bits
|
||||
short f; // frequency
|
||||
int overflow = 0; // number of elements with bit length too large
|
||||
|
||||
for (bits = 0; bits <= InternalConstants.MAX_BITS; bits++)
|
||||
s.bl_count[bits] = 0;
|
||||
|
||||
// In a first pass, compute the optimal bit lengths (which may
|
||||
// overflow in the case of the bit length tree).
|
||||
tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap
|
||||
|
||||
for (h = s.heap_max + 1; h < HEAP_SIZE; h++)
|
||||
{
|
||||
n = s.heap[h];
|
||||
bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;
|
||||
if (bits > max_length)
|
||||
{
|
||||
bits = max_length; overflow++;
|
||||
}
|
||||
tree[n * 2 + 1] = (short) bits;
|
||||
// We overwrite tree[n*2+1] which is no longer needed
|
||||
|
||||
if (n > max_code)
|
||||
continue; // not a leaf node
|
||||
|
||||
s.bl_count[bits]++;
|
||||
xbits = 0;
|
||||
if (n >= base_Renamed)
|
||||
xbits = extra[n - base_Renamed];
|
||||
f = tree[n * 2];
|
||||
s.opt_len += f * (bits + xbits);
|
||||
if (stree != null)
|
||||
s.static_len += f * (stree[n * 2 + 1] + xbits);
|
||||
}
|
||||
if (overflow == 0)
|
||||
return ;
|
||||
|
||||
// This happens for example on obj2 and pic of the Calgary corpus
|
||||
// Find the first bit length which could increase:
|
||||
do
|
||||
{
|
||||
bits = max_length - 1;
|
||||
while (s.bl_count[bits] == 0)
|
||||
bits--;
|
||||
s.bl_count[bits]--; // move one leaf down the tree
|
||||
s.bl_count[bits + 1] = (short) (s.bl_count[bits + 1] + 2); // move one overflow item as its brother
|
||||
s.bl_count[max_length]--;
|
||||
// The brother of the overflow item also moves one step up,
|
||||
// but this does not affect bl_count[max_length]
|
||||
overflow -= 2;
|
||||
}
|
||||
while (overflow > 0);
|
||||
|
||||
for (bits = max_length; bits != 0; bits--)
|
||||
{
|
||||
n = s.bl_count[bits];
|
||||
while (n != 0)
|
||||
{
|
||||
m = s.heap[--h];
|
||||
if (m > max_code)
|
||||
continue;
|
||||
if (tree[m * 2 + 1] != bits)
|
||||
{
|
||||
s.opt_len = (int) (s.opt_len + ((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]);
|
||||
tree[m * 2 + 1] = (short) bits;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Construct one Huffman tree and assigns the code bit strings and lengths.
|
||||
// Update the total bit length for the current block.
|
||||
// IN assertion: the field freq is set for all tree elements.
|
||||
// OUT assertions: the fields len and code are set to the optimal bit length
|
||||
// and corresponding code. The length opt_len is updated; static_len is
|
||||
// also updated if stree is not null. The field max_code is set.
|
||||
internal void build_tree(DeflateManager s)
|
||||
{
|
||||
short[] tree = dyn_tree;
|
||||
short[] stree = staticTree.treeCodes;
|
||||
int elems = staticTree.elems;
|
||||
int n, m; // iterate over heap elements
|
||||
int max_code = -1; // largest code with non zero frequency
|
||||
int node; // new node being created
|
||||
|
||||
// Construct the initial heap, with least frequent element in
|
||||
// heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
|
||||
// heap[0] is not used.
|
||||
s.heap_len = 0;
|
||||
s.heap_max = HEAP_SIZE;
|
||||
|
||||
for (n = 0; n < elems; n++)
|
||||
{
|
||||
if (tree[n * 2] != 0)
|
||||
{
|
||||
s.heap[++s.heap_len] = max_code = n;
|
||||
s.depth[n] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tree[n * 2 + 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// The pkzip format requires that at least one distance code exists,
|
||||
// and that at least one bit should be sent even if there is only one
|
||||
// possible code. So to avoid special checks later on we force at least
|
||||
// two codes of non zero frequency.
|
||||
while (s.heap_len < 2)
|
||||
{
|
||||
node = s.heap[++s.heap_len] = (max_code < 2?++max_code:0);
|
||||
tree[node * 2] = 1;
|
||||
s.depth[node] = 0;
|
||||
s.opt_len--;
|
||||
if (stree != null)
|
||||
s.static_len -= stree[node * 2 + 1];
|
||||
// node is 0 or 1 so it does not have extra bits
|
||||
}
|
||||
this.max_code = max_code;
|
||||
|
||||
// The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
|
||||
// establish sub-heaps of increasing lengths:
|
||||
|
||||
for (n = s.heap_len / 2; n >= 1; n--)
|
||||
s.pqdownheap(tree, n);
|
||||
|
||||
// Construct the Huffman tree by repeatedly combining the least two
|
||||
// frequent nodes.
|
||||
|
||||
node = elems; // next internal node of the tree
|
||||
do
|
||||
{
|
||||
// n = node of least frequency
|
||||
n = s.heap[1];
|
||||
s.heap[1] = s.heap[s.heap_len--];
|
||||
s.pqdownheap(tree, 1);
|
||||
m = s.heap[1]; // m = node of next least frequency
|
||||
|
||||
s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency
|
||||
s.heap[--s.heap_max] = m;
|
||||
|
||||
// Create a new node father of n and m
|
||||
tree[node * 2] = unchecked((short) (tree[n * 2] + tree[m * 2]));
|
||||
s.depth[node] = (sbyte) (System.Math.Max((byte) s.depth[n], (byte) s.depth[m]) + 1);
|
||||
tree[n * 2 + 1] = tree[m * 2 + 1] = (short) node;
|
||||
|
||||
// and insert the new node in the heap
|
||||
s.heap[1] = node++;
|
||||
s.pqdownheap(tree, 1);
|
||||
}
|
||||
while (s.heap_len >= 2);
|
||||
|
||||
s.heap[--s.heap_max] = s.heap[1];
|
||||
|
||||
// At this point, the fields freq and dad are set. We can now
|
||||
// generate the bit lengths.
|
||||
|
||||
gen_bitlen(s);
|
||||
|
||||
// The field len is now set, we can generate the bit codes
|
||||
gen_codes(tree, max_code, s.bl_count);
|
||||
}
|
||||
|
||||
// Generate the codes for a given tree and bit counts (which need not be
|
||||
// optimal).
|
||||
// IN assertion: the array bl_count contains the bit length statistics for
|
||||
// the given tree and the field len is set for all tree elements.
|
||||
// OUT assertion: the field code is set for all tree elements of non
|
||||
// zero code length.
|
||||
internal static void gen_codes(short[] tree, int max_code, short[] bl_count)
|
||||
{
|
||||
short[] next_code = new short[InternalConstants.MAX_BITS + 1]; // next code value for each bit length
|
||||
short code = 0; // running code value
|
||||
int bits; // bit index
|
||||
int n; // code index
|
||||
|
||||
// The distribution counts are first used to generate the code values
|
||||
// without bit reversal.
|
||||
for (bits = 1; bits <= InternalConstants.MAX_BITS; bits++)
|
||||
unchecked {
|
||||
next_code[bits] = code = (short) ((code + bl_count[bits - 1]) << 1);
|
||||
}
|
||||
|
||||
// Check that the bit counts in bl_count are consistent. The last code
|
||||
// must be all ones.
|
||||
//Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
|
||||
// "inconsistent bit counts");
|
||||
//Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
||||
|
||||
for (n = 0; n <= max_code; n++)
|
||||
{
|
||||
int len = tree[n * 2 + 1];
|
||||
if (len == 0)
|
||||
continue;
|
||||
// Now reverse the bits
|
||||
tree[n * 2] = unchecked((short) (bi_reverse(next_code[len]++, len)));
|
||||
}
|
||||
}
|
||||
|
||||
// Reverse the first len bits of a code, using straightforward code (a faster
|
||||
// method would use a table)
|
||||
// IN assertion: 1 <= len <= 15
|
||||
internal static int bi_reverse(int code, int len)
|
||||
{
|
||||
int res = 0;
|
||||
do
|
||||
{
|
||||
res |= code & 1;
|
||||
code >>= 1; //SharedUtils.URShift(code, 1);
|
||||
res <<= 1;
|
||||
}
|
||||
while (--len > 0);
|
||||
return res >> 1;
|
||||
}
|
||||
}
|
||||
// Tree.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-October-28 13:29:50>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines classes for zlib compression and
|
||||
// decompression. This code is derived from the jzlib implementation of
|
||||
// zlib. In keeping with the license for jzlib, the copyright to that
|
||||
// code is below.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in
|
||||
// the documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The names of the authors may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
// This program is based on zlib-1.1.3; credit to authors
|
||||
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||
// and contributors of zlib.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace Ionic.Zlib
|
||||
{
|
||||
sealed class Tree
|
||||
{
|
||||
private static readonly int HEAP_SIZE = (2 * InternalConstants.L_CODES + 1);
|
||||
|
||||
// extra bits for each length code
|
||||
internal static readonly int[] ExtraLengthBits = new int[]
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
|
||||
};
|
||||
|
||||
// extra bits for each distance code
|
||||
internal static readonly int[] ExtraDistanceBits = new int[]
|
||||
{
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13
|
||||
};
|
||||
|
||||
// extra bits for each bit length code
|
||||
internal static readonly int[] extra_blbits = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7};
|
||||
|
||||
internal static readonly sbyte[] bl_order = new sbyte[]{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
||||
|
||||
|
||||
// The lengths of the bit length codes are sent in order of decreasing
|
||||
// probability, to avoid transmitting the lengths for unused bit
|
||||
// length codes.
|
||||
|
||||
internal const int Buf_size = 8 * 2;
|
||||
|
||||
// see definition of array dist_code below
|
||||
//internal const int DIST_CODE_LEN = 512;
|
||||
|
||||
private static readonly sbyte[] _dist_code = new sbyte[]
|
||||
{
|
||||
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
|
||||
8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||
13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
|
||||
0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||
};
|
||||
|
||||
internal static readonly sbyte[] LengthCode = new sbyte[]
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15,
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17,
|
||||
18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
|
||||
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
|
||||
};
|
||||
|
||||
|
||||
internal static readonly int[] LengthBase = new int[]
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28,
|
||||
32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0
|
||||
};
|
||||
|
||||
|
||||
internal static readonly int[] DistanceBase = new int[]
|
||||
{
|
||||
0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192,
|
||||
256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Map from a distance to a distance code.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// No side effects. _dist_code[256] and _dist_code[257] are never used.
|
||||
/// </remarks>
|
||||
internal static int DistanceCode(int dist)
|
||||
{
|
||||
return (dist < 256)
|
||||
? _dist_code[dist]
|
||||
: _dist_code[256 + SharedUtils.URShift(dist, 7)];
|
||||
}
|
||||
|
||||
internal short[] dyn_tree; // the dynamic tree
|
||||
internal int max_code; // largest code with non zero frequency
|
||||
internal StaticTree staticTree; // the corresponding static tree
|
||||
|
||||
// Compute the optimal bit lengths for a tree and update the total bit length
|
||||
// for the current block.
|
||||
// IN assertion: the fields freq and dad are set, heap[heap_max] and
|
||||
// above are the tree nodes sorted by increasing frequency.
|
||||
// OUT assertions: the field len is set to the optimal bit length, the
|
||||
// array bl_count contains the frequencies for each bit length.
|
||||
// The length opt_len is updated; static_len is also updated if stree is
|
||||
// not null.
|
||||
internal void gen_bitlen(DeflateManager s)
|
||||
{
|
||||
short[] tree = dyn_tree;
|
||||
short[] stree = staticTree.treeCodes;
|
||||
int[] extra = staticTree.extraBits;
|
||||
int base_Renamed = staticTree.extraBase;
|
||||
int max_length = staticTree.maxLength;
|
||||
int h; // heap index
|
||||
int n, m; // iterate over the tree elements
|
||||
int bits; // bit length
|
||||
int xbits; // extra bits
|
||||
short f; // frequency
|
||||
int overflow = 0; // number of elements with bit length too large
|
||||
|
||||
for (bits = 0; bits <= InternalConstants.MAX_BITS; bits++)
|
||||
s.bl_count[bits] = 0;
|
||||
|
||||
// In a first pass, compute the optimal bit lengths (which may
|
||||
// overflow in the case of the bit length tree).
|
||||
tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap
|
||||
|
||||
for (h = s.heap_max + 1; h < HEAP_SIZE; h++)
|
||||
{
|
||||
n = s.heap[h];
|
||||
bits = tree[tree[n * 2 + 1] * 2 + 1] + 1;
|
||||
if (bits > max_length)
|
||||
{
|
||||
bits = max_length; overflow++;
|
||||
}
|
||||
tree[n * 2 + 1] = (short) bits;
|
||||
// We overwrite tree[n*2+1] which is no longer needed
|
||||
|
||||
if (n > max_code)
|
||||
continue; // not a leaf node
|
||||
|
||||
s.bl_count[bits]++;
|
||||
xbits = 0;
|
||||
if (n >= base_Renamed)
|
||||
xbits = extra[n - base_Renamed];
|
||||
f = tree[n * 2];
|
||||
s.opt_len += f * (bits + xbits);
|
||||
if (stree != null)
|
||||
s.static_len += f * (stree[n * 2 + 1] + xbits);
|
||||
}
|
||||
if (overflow == 0)
|
||||
return ;
|
||||
|
||||
// This happens for example on obj2 and pic of the Calgary corpus
|
||||
// Find the first bit length which could increase:
|
||||
do
|
||||
{
|
||||
bits = max_length - 1;
|
||||
while (s.bl_count[bits] == 0)
|
||||
bits--;
|
||||
s.bl_count[bits]--; // move one leaf down the tree
|
||||
s.bl_count[bits + 1] = (short) (s.bl_count[bits + 1] + 2); // move one overflow item as its brother
|
||||
s.bl_count[max_length]--;
|
||||
// The brother of the overflow item also moves one step up,
|
||||
// but this does not affect bl_count[max_length]
|
||||
overflow -= 2;
|
||||
}
|
||||
while (overflow > 0);
|
||||
|
||||
for (bits = max_length; bits != 0; bits--)
|
||||
{
|
||||
n = s.bl_count[bits];
|
||||
while (n != 0)
|
||||
{
|
||||
m = s.heap[--h];
|
||||
if (m > max_code)
|
||||
continue;
|
||||
if (tree[m * 2 + 1] != bits)
|
||||
{
|
||||
s.opt_len = (int) (s.opt_len + ((long) bits - (long) tree[m * 2 + 1]) * (long) tree[m * 2]);
|
||||
tree[m * 2 + 1] = (short) bits;
|
||||
}
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Construct one Huffman tree and assigns the code bit strings and lengths.
|
||||
// Update the total bit length for the current block.
|
||||
// IN assertion: the field freq is set for all tree elements.
|
||||
// OUT assertions: the fields len and code are set to the optimal bit length
|
||||
// and corresponding code. The length opt_len is updated; static_len is
|
||||
// also updated if stree is not null. The field max_code is set.
|
||||
internal void build_tree(DeflateManager s)
|
||||
{
|
||||
short[] tree = dyn_tree;
|
||||
short[] stree = staticTree.treeCodes;
|
||||
int elems = staticTree.elems;
|
||||
int n, m; // iterate over heap elements
|
||||
int max_code = -1; // largest code with non zero frequency
|
||||
int node; // new node being created
|
||||
|
||||
// Construct the initial heap, with least frequent element in
|
||||
// heap[1]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
|
||||
// heap[0] is not used.
|
||||
s.heap_len = 0;
|
||||
s.heap_max = HEAP_SIZE;
|
||||
|
||||
for (n = 0; n < elems; n++)
|
||||
{
|
||||
if (tree[n * 2] != 0)
|
||||
{
|
||||
s.heap[++s.heap_len] = max_code = n;
|
||||
s.depth[n] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
tree[n * 2 + 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// The pkzip format requires that at least one distance code exists,
|
||||
// and that at least one bit should be sent even if there is only one
|
||||
// possible code. So to avoid special checks later on we force at least
|
||||
// two codes of non zero frequency.
|
||||
while (s.heap_len < 2)
|
||||
{
|
||||
node = s.heap[++s.heap_len] = (max_code < 2?++max_code:0);
|
||||
tree[node * 2] = 1;
|
||||
s.depth[node] = 0;
|
||||
s.opt_len--;
|
||||
if (stree != null)
|
||||
s.static_len -= stree[node * 2 + 1];
|
||||
// node is 0 or 1 so it does not have extra bits
|
||||
}
|
||||
this.max_code = max_code;
|
||||
|
||||
// The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
|
||||
// establish sub-heaps of increasing lengths:
|
||||
|
||||
for (n = s.heap_len / 2; n >= 1; n--)
|
||||
s.pqdownheap(tree, n);
|
||||
|
||||
// Construct the Huffman tree by repeatedly combining the least two
|
||||
// frequent nodes.
|
||||
|
||||
node = elems; // next internal node of the tree
|
||||
do
|
||||
{
|
||||
// n = node of least frequency
|
||||
n = s.heap[1];
|
||||
s.heap[1] = s.heap[s.heap_len--];
|
||||
s.pqdownheap(tree, 1);
|
||||
m = s.heap[1]; // m = node of next least frequency
|
||||
|
||||
s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency
|
||||
s.heap[--s.heap_max] = m;
|
||||
|
||||
// Create a new node father of n and m
|
||||
tree[node * 2] = unchecked((short) (tree[n * 2] + tree[m * 2]));
|
||||
s.depth[node] = (sbyte) (System.Math.Max((byte) s.depth[n], (byte) s.depth[m]) + 1);
|
||||
tree[n * 2 + 1] = tree[m * 2 + 1] = (short) node;
|
||||
|
||||
// and insert the new node in the heap
|
||||
s.heap[1] = node++;
|
||||
s.pqdownheap(tree, 1);
|
||||
}
|
||||
while (s.heap_len >= 2);
|
||||
|
||||
s.heap[--s.heap_max] = s.heap[1];
|
||||
|
||||
// At this point, the fields freq and dad are set. We can now
|
||||
// generate the bit lengths.
|
||||
|
||||
gen_bitlen(s);
|
||||
|
||||
// The field len is now set, we can generate the bit codes
|
||||
gen_codes(tree, max_code, s.bl_count);
|
||||
}
|
||||
|
||||
// Generate the codes for a given tree and bit counts (which need not be
|
||||
// optimal).
|
||||
// IN assertion: the array bl_count contains the bit length statistics for
|
||||
// the given tree and the field len is set for all tree elements.
|
||||
// OUT assertion: the field code is set for all tree elements of non
|
||||
// zero code length.
|
||||
internal static void gen_codes(short[] tree, int max_code, short[] bl_count)
|
||||
{
|
||||
short[] next_code = new short[InternalConstants.MAX_BITS + 1]; // next code value for each bit length
|
||||
short code = 0; // running code value
|
||||
int bits; // bit index
|
||||
int n; // code index
|
||||
|
||||
// The distribution counts are first used to generate the code values
|
||||
// without bit reversal.
|
||||
for (bits = 1; bits <= InternalConstants.MAX_BITS; bits++)
|
||||
unchecked {
|
||||
next_code[bits] = code = (short) ((code + bl_count[bits - 1]) << 1);
|
||||
}
|
||||
|
||||
// Check that the bit counts in bl_count are consistent. The last code
|
||||
// must be all ones.
|
||||
//Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
|
||||
// "inconsistent bit counts");
|
||||
//Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
|
||||
|
||||
for (n = 0; n <= max_code; n++)
|
||||
{
|
||||
int len = tree[n * 2 + 1];
|
||||
if (len == 0)
|
||||
continue;
|
||||
// Now reverse the bits
|
||||
tree[n * 2] = unchecked((short) (bi_reverse(next_code[len]++, len)));
|
||||
}
|
||||
}
|
||||
|
||||
// Reverse the first len bits of a code, using straightforward code (a faster
|
||||
// method would use a table)
|
||||
// IN assertion: 1 <= len <= 15
|
||||
internal static int bi_reverse(int code, int len)
|
||||
{
|
||||
int res = 0;
|
||||
do
|
||||
{
|
||||
res |= code & 1;
|
||||
code >>= 1; //SharedUtils.URShift(code, 1);
|
||||
res <<= 1;
|
||||
}
|
||||
while (--len > 0);
|
||||
return res >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,128 +1,128 @@
|
||||
// ZlibConstants.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-November-03 18:50:19>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines constants used by the zlib class library. This
|
||||
// code is derived from the jzlib implementation of zlib, but
|
||||
// significantly modified. In keeping with the license for jzlib, the
|
||||
// copyright to that code is included here.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in
|
||||
// the documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The names of the authors may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
// This program is based on zlib-1.1.3; credit to authors
|
||||
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||
// and contributors of zlib.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace Ionic.Zlib
|
||||
{
|
||||
/// <summary>
|
||||
/// A bunch of constants used in the Zlib interface.
|
||||
/// </summary>
|
||||
public static class ZlibConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// The maximum number of window bits for the Deflate algorithm.
|
||||
/// </summary>
|
||||
public const int WindowBitsMax = 15; // 32K LZ77 window
|
||||
|
||||
/// <summary>
|
||||
/// The default number of window bits for the Deflate algorithm.
|
||||
/// </summary>
|
||||
public const int WindowBitsDefault = WindowBitsMax;
|
||||
|
||||
/// <summary>
|
||||
/// indicates everything is A-OK
|
||||
/// </summary>
|
||||
public const int Z_OK = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the last operation reached the end of the stream.
|
||||
/// </summary>
|
||||
public const int Z_STREAM_END = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The operation ended in need of a dictionary.
|
||||
/// </summary>
|
||||
public const int Z_NEED_DICT = 2;
|
||||
|
||||
/// <summary>
|
||||
/// There was an error with the stream - not enough data, not open and readable, etc.
|
||||
/// </summary>
|
||||
public const int Z_STREAM_ERROR = -2;
|
||||
|
||||
/// <summary>
|
||||
/// There was an error with the data - not enough data, bad data, etc.
|
||||
/// </summary>
|
||||
public const int Z_DATA_ERROR = -3;
|
||||
|
||||
/// <summary>
|
||||
/// There was an error with the working buffer.
|
||||
/// </summary>
|
||||
public const int Z_BUF_ERROR = -5;
|
||||
|
||||
/// <summary>
|
||||
/// The size of the working buffer used in the ZlibCodec class. Defaults to 8192 bytes.
|
||||
/// </summary>
|
||||
#if NETCF
|
||||
public const int WorkingBufferSizeDefault = 8192;
|
||||
#else
|
||||
public const int WorkingBufferSizeDefault = 16384;
|
||||
#endif
|
||||
/// <summary>
|
||||
/// The minimum size of the working buffer used in the ZlibCodec class. Currently it is 128 bytes.
|
||||
/// </summary>
|
||||
public const int WorkingBufferSizeMin = 1024;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ZlibConstants.cs
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2009 Dino Chiesa and Microsoft Corporation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code module is part of DotNetZip, a zipfile class library.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This code is licensed under the Microsoft Public License.
|
||||
// See the file License.txt for the license details.
|
||||
// More info on: http://dotnetzip.codeplex.com
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// last saved (in emacs):
|
||||
// Time-stamp: <2009-November-03 18:50:19>
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// This module defines constants used by the zlib class library. This
|
||||
// code is derived from the jzlib implementation of zlib, but
|
||||
// significantly modified. In keeping with the license for jzlib, the
|
||||
// copyright to that code is included here.
|
||||
//
|
||||
// ------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2000,2001,2002,2003 ymnk, JCraft,Inc. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in
|
||||
// the documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The names of the authors may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
||||
// INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
//
|
||||
// This program is based on zlib-1.1.3; credit to authors
|
||||
// Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
||||
// and contributors of zlib.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
|
||||
using System;
|
||||
|
||||
namespace Ionic.Zlib
|
||||
{
|
||||
/// <summary>
|
||||
/// A bunch of constants used in the Zlib interface.
|
||||
/// </summary>
|
||||
public static class ZlibConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// The maximum number of window bits for the Deflate algorithm.
|
||||
/// </summary>
|
||||
public const int WindowBitsMax = 15; // 32K LZ77 window
|
||||
|
||||
/// <summary>
|
||||
/// The default number of window bits for the Deflate algorithm.
|
||||
/// </summary>
|
||||
public const int WindowBitsDefault = WindowBitsMax;
|
||||
|
||||
/// <summary>
|
||||
/// indicates everything is A-OK
|
||||
/// </summary>
|
||||
public const int Z_OK = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the last operation reached the end of the stream.
|
||||
/// </summary>
|
||||
public const int Z_STREAM_END = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The operation ended in need of a dictionary.
|
||||
/// </summary>
|
||||
public const int Z_NEED_DICT = 2;
|
||||
|
||||
/// <summary>
|
||||
/// There was an error with the stream - not enough data, not open and readable, etc.
|
||||
/// </summary>
|
||||
public const int Z_STREAM_ERROR = -2;
|
||||
|
||||
/// <summary>
|
||||
/// There was an error with the data - not enough data, bad data, etc.
|
||||
/// </summary>
|
||||
public const int Z_DATA_ERROR = -3;
|
||||
|
||||
/// <summary>
|
||||
/// There was an error with the working buffer.
|
||||
/// </summary>
|
||||
public const int Z_BUF_ERROR = -5;
|
||||
|
||||
/// <summary>
|
||||
/// The size of the working buffer used in the ZlibCodec class. Defaults to 8192 bytes.
|
||||
/// </summary>
|
||||
#if NETCF
|
||||
public const int WorkingBufferSizeDefault = 8192;
|
||||
#else
|
||||
public const int WorkingBufferSizeDefault = 16384;
|
||||
#endif
|
||||
/// <summary>
|
||||
/// The minimum size of the working buffer used in the ZlibCodec class. Currently it is 128 bytes.
|
||||
/// </summary>
|
||||
public const int WorkingBufferSizeMin = 1024;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+20066
-20066
File diff suppressed because it is too large
Load Diff
+20066
-20066
File diff suppressed because it is too large
Load Diff
+11751
-11751
File diff suppressed because it is too large
Load Diff
+49291
-49291
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+11693
-11693
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,50 +1,50 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Spring.Web.Extensions</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Spring.Web.Script.Services.ScriptHandlerFactory">
|
||||
<summary>
|
||||
An <see cref="T:System.Web.IHttpHandlerFactory"/> implementation that
|
||||
creates a handler object for either ASP.NET AJAX 1.0 or Spring web services.
|
||||
</summary>
|
||||
<author>Bruno Baia</author>
|
||||
<author>Thomas Broyer</author>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Script.Services.ScriptHandlerFactory.#ctor">
|
||||
<summary>
|
||||
Creates a new instance of the <see cref="T:Spring.Web.Script.Services.ScriptHandlerFactory"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Script.Services.ScriptHandlerFactory.GetHandler(System.Web.HttpContext,System.String,System.String,System.String)">
|
||||
<summary>
|
||||
Retrieves an instance of the <see cref="T:System.Web.IHttpHandler"/>
|
||||
implementation for handling web service requests
|
||||
for both Spring and ASP.NET AJAX 1.0 web services.
|
||||
</summary>
|
||||
<param name="context">The current HTTP context.</param>
|
||||
<param name="requestType">The type of HTTP request (GET or POST).</param>
|
||||
<param name="url">The url of the web service.</param>
|
||||
<param name="pathTranslated">The physical application path for the web service.</param>
|
||||
<returns>The web service handler object.</returns>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Script.Services.ScriptHandlerFactory.ReleaseHandler(System.Web.IHttpHandler)">
|
||||
<summary>
|
||||
Enables a factory to reuse an existing handler instance.
|
||||
</summary>
|
||||
<param name="handler">The <see cref="T:System.Web.IHttpHandler"/> object to reuse.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Script.Services.ScriptHandlerFactory.CreateHandlerInstance(Spring.Context.IConfigurableApplicationContext,System.Web.HttpContext,System.String,System.String,System.String)">
|
||||
<summary>
|
||||
Create a handler instance for the given URL.
|
||||
</summary>
|
||||
<param name="appContext">the application context corresponding to the current request</param>
|
||||
<param name="context">The <see cref="T:System.Web.HttpContext"/> instance for this request.</param>
|
||||
<param name="requestType">The HTTP data transfer method (GET, POST, ...)</param>
|
||||
<param name="rawUrl">The requested <see cref="P:System.Web.HttpRequest.RawUrl"/>.</param>
|
||||
<param name="physicalPath">The physical path of the requested resource.</param>
|
||||
<returns>A handler instance for the current request.</returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Spring.Web.Extensions</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Spring.Web.Script.Services.ScriptHandlerFactory">
|
||||
<summary>
|
||||
An <see cref="T:System.Web.IHttpHandlerFactory"/> implementation that
|
||||
creates a handler object for either ASP.NET AJAX 1.0 or Spring web services.
|
||||
</summary>
|
||||
<author>Bruno Baia</author>
|
||||
<author>Thomas Broyer</author>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Script.Services.ScriptHandlerFactory.#ctor">
|
||||
<summary>
|
||||
Creates a new instance of the <see cref="T:Spring.Web.Script.Services.ScriptHandlerFactory"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Script.Services.ScriptHandlerFactory.GetHandler(System.Web.HttpContext,System.String,System.String,System.String)">
|
||||
<summary>
|
||||
Retrieves an instance of the <see cref="T:System.Web.IHttpHandler"/>
|
||||
implementation for handling web service requests
|
||||
for both Spring and ASP.NET AJAX 1.0 web services.
|
||||
</summary>
|
||||
<param name="context">The current HTTP context.</param>
|
||||
<param name="requestType">The type of HTTP request (GET or POST).</param>
|
||||
<param name="url">The url of the web service.</param>
|
||||
<param name="pathTranslated">The physical application path for the web service.</param>
|
||||
<returns>The web service handler object.</returns>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Script.Services.ScriptHandlerFactory.ReleaseHandler(System.Web.IHttpHandler)">
|
||||
<summary>
|
||||
Enables a factory to reuse an existing handler instance.
|
||||
</summary>
|
||||
<param name="handler">The <see cref="T:System.Web.IHttpHandler"/> object to reuse.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Script.Services.ScriptHandlerFactory.CreateHandlerInstance(Spring.Context.IConfigurableApplicationContext,System.Web.HttpContext,System.String,System.String,System.String)">
|
||||
<summary>
|
||||
Create a handler instance for the given URL.
|
||||
</summary>
|
||||
<param name="appContext">the application context corresponding to the current request</param>
|
||||
<param name="context">The <see cref="T:System.Web.HttpContext"/> instance for this request.</param>
|
||||
<param name="requestType">The HTTP data transfer method (GET, POST, ...)</param>
|
||||
<param name="rawUrl">The requested <see cref="P:System.Web.HttpRequest.RawUrl"/>.</param>
|
||||
<param name="physicalPath">The physical path of the requested resource.</param>
|
||||
<returns>A handler instance for the current request.</returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
||||
@@ -1,260 +1,260 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Spring.Web.Mvc</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Spring.Context.Support.MvcApplicationContext">
|
||||
<summary>
|
||||
Application Context for ASP.NET MVC Applications
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,Spring.Context.IApplicationContext,System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext with the given parent,
|
||||
loading the definitions from the given XML resources.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(Spring.Context.Support.MvcApplicationContextArgs)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
</summary>
|
||||
<param name="args">The args.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,System.String[],Spring.Core.IO.IResource[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
<param name="configurationResources">Configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcApplicationContext.ConfigurationLocations">
|
||||
<summary>
|
||||
An array of resource locations, referring to the XML object
|
||||
definition files that this context is to be built with.
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Examples of the format of the various strings that would be
|
||||
returned by accessing this property can be found in the overview
|
||||
documentation of with the <see cref="T:Spring.Context.Support.XmlApplicationContext"/>
|
||||
class.
|
||||
</p>
|
||||
</remarks>
|
||||
<returns>
|
||||
An array of resource locations, or <see langword="null"/> if none.
|
||||
</returns>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcApplicationContext.ConfigurationResources">
|
||||
<summary>
|
||||
An array of resources that this context is to be built with.
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Examples of the format of the various strings that would be
|
||||
returned by accessing this property can be found in the overview
|
||||
documentation of with the <see cref="T:Spring.Context.Support.XmlApplicationContext"/>
|
||||
class.
|
||||
</p>
|
||||
</remarks>
|
||||
<returns>
|
||||
An array of <see cref="T:Spring.Core.IO.IResource"/>s, or <see langword="null"/> if none.
|
||||
</returns>
|
||||
</member>
|
||||
<member name="T:Spring.Context.Support.MvcApplicationContextArgs">
|
||||
<summary>
|
||||
Encapsulates arguments to the <see cref="T:Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor(System.String,Spring.Context.IApplicationContext,System.String[],Spring.Core.IO.IResource[])">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
<param name="name">The name.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">The configuration locations.</param>
|
||||
<param name="configurationResources">The configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor(System.String,Spring.Context.IApplicationContext,System.String[],Spring.Core.IO.IResource[],System.Boolean)">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
<param name="name">The name.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">The configuration locations.</param>
|
||||
<param name="configurationResources">The configuration resources.</param>
|
||||
<param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
|
||||
</member>
|
||||
<member name="T:Spring.Context.Support.MvcContextHandler">
|
||||
<summary>
|
||||
Context Handler for ASP.NET MVC Applications
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcContextHandler.DefaultApplicationContextType">
|
||||
<summary>
|
||||
The <see cref="T:System.Type"/> of <see cref="T:Spring.Context.IApplicationContext"/>
|
||||
created if no <c>type</c> attribute is specified on a <c>context</c> element.
|
||||
</summary>
|
||||
<value></value>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcContextHandler.DefaultCaseSensitivity">
|
||||
<summary>
|
||||
Get the context's case-sensitivity to use if none is specified
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Derived handlers may override this property to change their default case-sensitivity.
|
||||
</p>
|
||||
<p>
|
||||
Defaults to 'true'.
|
||||
</p>
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringActionInvoker">
|
||||
<summary>
|
||||
ActionInvoker implementation that enables the <see cref="T:Spring.Context.IApplicationContext"/>to satisfy dependencies on ActionFilter attributes.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringActionInvoker.#ctor(Spring.Context.IApplicationContext)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Spring.Web.Mvc.SpringActionInvoker"/> class.
|
||||
</summary>
|
||||
<param name="context">The IApplicationContext.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringActionInvoker.GetFilters(System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor)">
|
||||
<summary>
|
||||
Retrieves information about the action filters.
|
||||
</summary>
|
||||
<param name="controllerContext">The controller context.</param>
|
||||
<param name="actionDescriptor">The action descriptor.</param>
|
||||
<returns>Information about the action filters.</returns>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringControllerFactory">
|
||||
<summary>
|
||||
Controller Factory for ASP.NET MVC
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringControllerFactory.CreateController(System.Web.Routing.RequestContext,System.String)">
|
||||
<summary>
|
||||
Creates the specified controller by using the specified request context.
|
||||
</summary>
|
||||
<param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param>
|
||||
<param name="controllerName">The name of the controller.</param>
|
||||
<returns>A reference to the controller.</returns>
|
||||
<exception cref="T:System.ArgumentNullException">The <paramref name="requestContext"/> parameter is null.</exception>
|
||||
<exception cref="T:System.ArgumentException">The <paramref name="controllerName"/> parameter is null or empty.</exception>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringControllerFactory.GetControllerInstance(System.Web.Routing.RequestContext,System.Type)">
|
||||
<summary>
|
||||
Retrieves the controller instance for the specified request context and controller type.
|
||||
</summary>
|
||||
<param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param>
|
||||
<param name="controllerType">The type of the controller.</param>
|
||||
<returns>The controller instance.</returns>
|
||||
<exception cref="T:System.Web.HttpException">
|
||||
<paramref name="controllerType"/> is null.</exception>
|
||||
<exception cref="T:System.ArgumentException">
|
||||
<paramref name="controllerType"/> cannot be assigned.</exception>
|
||||
<exception cref="T:System.InvalidOperationException">An instance of <paramref name="controllerType"/> cannot be created.</exception>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringControllerFactory.AddActionInvokerTo(System.Web.Mvc.IController)">
|
||||
<summary>
|
||||
Adds the action invoker to the controller instance.
|
||||
</summary>
|
||||
<param name="controller">The controller.</param>
|
||||
</member>
|
||||
<member name="P:Spring.Web.Mvc.SpringControllerFactory.ApplicationContext">
|
||||
<summary>
|
||||
Gets the application context.
|
||||
</summary>
|
||||
<value>The application context.</value>
|
||||
</member>
|
||||
<member name="P:Spring.Web.Mvc.SpringControllerFactory.ApplicationContextName">
|
||||
<summary>
|
||||
Gets or sets the name of the application context.
|
||||
</summary>
|
||||
<remarks>
|
||||
Defaults to using the root (default) Application Context.
|
||||
</remarks>
|
||||
<value>The name of the application context.</value>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringMvcApplication">
|
||||
<summary>
|
||||
Spring.NET-specific HttpApplication for ASP.NET MVC integration.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.Application_Start(System.Object,System.EventArgs)">
|
||||
<summary>
|
||||
Handles the Start event of the Application control.
|
||||
</summary>
|
||||
<param name="sender">The source of the event.</param>
|
||||
<param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.ConfigureApplicationContext">
|
||||
<summary>
|
||||
Configures the <see cref="T:Spring.Context.IApplicationContext"/> instance.
|
||||
</summary>
|
||||
<remarks>
|
||||
You must override this method in a derived class to control the manner in which the
|
||||
<see cref="T:Spring.Context.IApplicationContext"/> is configured.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.Init">
|
||||
<summary>
|
||||
Executes custom initialization code after all event handler modules have been added.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.RegisterAreas">
|
||||
<summary>
|
||||
Registers the areas.
|
||||
</summary>
|
||||
<remarks>
|
||||
Override this method in a derived class to modify the registered areas as neeeded.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.RegisterRoutes(System.Web.Routing.RouteCollection)">
|
||||
<summary>
|
||||
Registers the routes.
|
||||
</summary>
|
||||
<remarks>
|
||||
Override this method in a derived class to modify the registered routes as neeeded.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.RegisterSpringControllerFactory">
|
||||
<summary>
|
||||
Registers the controller factory with the Mvc Framework.
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Spring.Web.Mvc</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Spring.Context.Support.MvcApplicationContext">
|
||||
<summary>
|
||||
Application Context for ASP.NET MVC Applications
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,Spring.Context.IApplicationContext,System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext with the given parent,
|
||||
loading the definitions from the given XML resources.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(Spring.Context.Support.MvcApplicationContextArgs)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
</summary>
|
||||
<param name="args">The args.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,System.String[],Spring.Core.IO.IResource[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
<param name="configurationResources">Configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcApplicationContext.ConfigurationLocations">
|
||||
<summary>
|
||||
An array of resource locations, referring to the XML object
|
||||
definition files that this context is to be built with.
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Examples of the format of the various strings that would be
|
||||
returned by accessing this property can be found in the overview
|
||||
documentation of with the <see cref="T:Spring.Context.Support.XmlApplicationContext"/>
|
||||
class.
|
||||
</p>
|
||||
</remarks>
|
||||
<returns>
|
||||
An array of resource locations, or <see langword="null"/> if none.
|
||||
</returns>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcApplicationContext.ConfigurationResources">
|
||||
<summary>
|
||||
An array of resources that this context is to be built with.
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Examples of the format of the various strings that would be
|
||||
returned by accessing this property can be found in the overview
|
||||
documentation of with the <see cref="T:Spring.Context.Support.XmlApplicationContext"/>
|
||||
class.
|
||||
</p>
|
||||
</remarks>
|
||||
<returns>
|
||||
An array of <see cref="T:Spring.Core.IO.IResource"/>s, or <see langword="null"/> if none.
|
||||
</returns>
|
||||
</member>
|
||||
<member name="T:Spring.Context.Support.MvcApplicationContextArgs">
|
||||
<summary>
|
||||
Encapsulates arguments to the <see cref="T:Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor(System.String,Spring.Context.IApplicationContext,System.String[],Spring.Core.IO.IResource[])">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
<param name="name">The name.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">The configuration locations.</param>
|
||||
<param name="configurationResources">The configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor(System.String,Spring.Context.IApplicationContext,System.String[],Spring.Core.IO.IResource[],System.Boolean)">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
<param name="name">The name.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">The configuration locations.</param>
|
||||
<param name="configurationResources">The configuration resources.</param>
|
||||
<param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
|
||||
</member>
|
||||
<member name="T:Spring.Context.Support.MvcContextHandler">
|
||||
<summary>
|
||||
Context Handler for ASP.NET MVC Applications
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcContextHandler.DefaultApplicationContextType">
|
||||
<summary>
|
||||
The <see cref="T:System.Type"/> of <see cref="T:Spring.Context.IApplicationContext"/>
|
||||
created if no <c>type</c> attribute is specified on a <c>context</c> element.
|
||||
</summary>
|
||||
<value></value>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcContextHandler.DefaultCaseSensitivity">
|
||||
<summary>
|
||||
Get the context's case-sensitivity to use if none is specified
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Derived handlers may override this property to change their default case-sensitivity.
|
||||
</p>
|
||||
<p>
|
||||
Defaults to 'true'.
|
||||
</p>
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringActionInvoker">
|
||||
<summary>
|
||||
ActionInvoker implementation that enables the <see cref="T:Spring.Context.IApplicationContext"/>to satisfy dependencies on ActionFilter attributes.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringActionInvoker.#ctor(Spring.Context.IApplicationContext)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Spring.Web.Mvc.SpringActionInvoker"/> class.
|
||||
</summary>
|
||||
<param name="context">The IApplicationContext.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringActionInvoker.GetFilters(System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor)">
|
||||
<summary>
|
||||
Retrieves information about the action filters.
|
||||
</summary>
|
||||
<param name="controllerContext">The controller context.</param>
|
||||
<param name="actionDescriptor">The action descriptor.</param>
|
||||
<returns>Information about the action filters.</returns>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringControllerFactory">
|
||||
<summary>
|
||||
Controller Factory for ASP.NET MVC
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringControllerFactory.CreateController(System.Web.Routing.RequestContext,System.String)">
|
||||
<summary>
|
||||
Creates the specified controller by using the specified request context.
|
||||
</summary>
|
||||
<param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param>
|
||||
<param name="controllerName">The name of the controller.</param>
|
||||
<returns>A reference to the controller.</returns>
|
||||
<exception cref="T:System.ArgumentNullException">The <paramref name="requestContext"/> parameter is null.</exception>
|
||||
<exception cref="T:System.ArgumentException">The <paramref name="controllerName"/> parameter is null or empty.</exception>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringControllerFactory.GetControllerInstance(System.Web.Routing.RequestContext,System.Type)">
|
||||
<summary>
|
||||
Retrieves the controller instance for the specified request context and controller type.
|
||||
</summary>
|
||||
<param name="requestContext">The context of the HTTP request, which includes the HTTP context and route data.</param>
|
||||
<param name="controllerType">The type of the controller.</param>
|
||||
<returns>The controller instance.</returns>
|
||||
<exception cref="T:System.Web.HttpException">
|
||||
<paramref name="controllerType"/> is null.</exception>
|
||||
<exception cref="T:System.ArgumentException">
|
||||
<paramref name="controllerType"/> cannot be assigned.</exception>
|
||||
<exception cref="T:System.InvalidOperationException">An instance of <paramref name="controllerType"/> cannot be created.</exception>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringControllerFactory.AddActionInvokerTo(System.Web.Mvc.IController)">
|
||||
<summary>
|
||||
Adds the action invoker to the controller instance.
|
||||
</summary>
|
||||
<param name="controller">The controller.</param>
|
||||
</member>
|
||||
<member name="P:Spring.Web.Mvc.SpringControllerFactory.ApplicationContext">
|
||||
<summary>
|
||||
Gets the application context.
|
||||
</summary>
|
||||
<value>The application context.</value>
|
||||
</member>
|
||||
<member name="P:Spring.Web.Mvc.SpringControllerFactory.ApplicationContextName">
|
||||
<summary>
|
||||
Gets or sets the name of the application context.
|
||||
</summary>
|
||||
<remarks>
|
||||
Defaults to using the root (default) Application Context.
|
||||
</remarks>
|
||||
<value>The name of the application context.</value>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringMvcApplication">
|
||||
<summary>
|
||||
Spring.NET-specific HttpApplication for ASP.NET MVC integration.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.Application_Start(System.Object,System.EventArgs)">
|
||||
<summary>
|
||||
Handles the Start event of the Application control.
|
||||
</summary>
|
||||
<param name="sender">The source of the event.</param>
|
||||
<param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.ConfigureApplicationContext">
|
||||
<summary>
|
||||
Configures the <see cref="T:Spring.Context.IApplicationContext"/> instance.
|
||||
</summary>
|
||||
<remarks>
|
||||
You must override this method in a derived class to control the manner in which the
|
||||
<see cref="T:Spring.Context.IApplicationContext"/> is configured.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.Init">
|
||||
<summary>
|
||||
Executes custom initialization code after all event handler modules have been added.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.RegisterAreas">
|
||||
<summary>
|
||||
Registers the areas.
|
||||
</summary>
|
||||
<remarks>
|
||||
Override this method in a derived class to modify the registered areas as neeeded.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.RegisterRoutes(System.Web.Routing.RouteCollection)">
|
||||
<summary>
|
||||
Registers the routes.
|
||||
</summary>
|
||||
<remarks>
|
||||
Override this method in a derived class to modify the registered routes as neeeded.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.RegisterSpringControllerFactory">
|
||||
<summary>
|
||||
Registers the controller factory with the Mvc Framework.
|
||||
</summary>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
||||
@@ -1,218 +1,218 @@
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Spring.Web.Mvc3</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Spring.Context.Support.MvcApplicationContext">
|
||||
<summary>
|
||||
Application Context for ASP.NET MVC Applications
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,Spring.Context.IApplicationContext,System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext with the given parent,
|
||||
loading the definitions from the given XML resources.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(Spring.Context.Support.MvcApplicationContextArgs)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
</summary>
|
||||
<param name="args">The args.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,System.String[],Spring.Core.IO.IResource[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
<param name="configurationResources">Configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcApplicationContext.ConfigurationLocations">
|
||||
<summary>
|
||||
An array of resource locations, referring to the XML object
|
||||
definition files that this context is to be built with.
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Examples of the format of the various strings that would be
|
||||
returned by accessing this property can be found in the overview
|
||||
documentation of with the <see cref="T:Spring.Context.Support.XmlApplicationContext"/>
|
||||
class.
|
||||
</p>
|
||||
</remarks>
|
||||
<returns>
|
||||
An array of resource locations, or <see langword="null"/> if none.
|
||||
</returns>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcApplicationContext.ConfigurationResources">
|
||||
<summary>
|
||||
An array of resources that this context is to be built with.
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Examples of the format of the various strings that would be
|
||||
returned by accessing this property can be found in the overview
|
||||
documentation of with the <see cref="T:Spring.Context.Support.XmlApplicationContext"/>
|
||||
class.
|
||||
</p>
|
||||
</remarks>
|
||||
<returns>
|
||||
An array of <see cref="T:Spring.Core.IO.IResource"/>s, or <see langword="null"/> if none.
|
||||
</returns>
|
||||
</member>
|
||||
<member name="T:Spring.Context.Support.MvcApplicationContextArgs">
|
||||
<summary>
|
||||
Encapsulates arguments to the <see cref="T:Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor(System.String,Spring.Context.IApplicationContext,System.String[],Spring.Core.IO.IResource[])">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
<param name="name">The name.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">The configuration locations.</param>
|
||||
<param name="configurationResources">The configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor(System.String,Spring.Context.IApplicationContext,System.String[],Spring.Core.IO.IResource[],System.Boolean)">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
<param name="name">The name.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">The configuration locations.</param>
|
||||
<param name="configurationResources">The configuration resources.</param>
|
||||
<param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
|
||||
</member>
|
||||
<member name="T:Spring.Context.Support.MvcContextHandler">
|
||||
<summary>
|
||||
Context Handler for ASP.NET MVC Applications
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringMvcApplication">
|
||||
<summary>
|
||||
Spring.NET-specific HttpApplication for ASP.NET MVC integration.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.Init">
|
||||
<summary>
|
||||
Executes custom initialization code after all event handler modules have been added.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.Application_BeginRequest(System.Object,System.EventArgs)">
|
||||
<summary>
|
||||
Handles the BeginRequest event of the Application control.
|
||||
</summary>
|
||||
<param name="sender">The source of the event.</param>
|
||||
<param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.BuildDependencyResolver">
|
||||
<summary>
|
||||
Builds the dependency resolver.
|
||||
</summary>
|
||||
<returns>The <see cref="T:System.Web.Mvc.IDependencyResolver"/> instance.</returns>
|
||||
You must override this method in a derived class to control the manner in which the
|
||||
<see cref="T:System.Web.Mvc.IDependencyResolver"/> is created.
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.ConfigureApplicationContext">
|
||||
<summary>
|
||||
Configures the <see cref="T:Spring.Context.IApplicationContext"/> instance.
|
||||
</summary>
|
||||
<remarks>
|
||||
You must override this method in a derived class to control the manner in which the
|
||||
<see cref="T:Spring.Context.IApplicationContext"/> is configured.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.RegisterDependencyResolver(System.Web.Mvc.IDependencyResolver)">
|
||||
<summary>
|
||||
Registers the DependencyResolver implementation with the MVC runtime.
|
||||
<remarks>
|
||||
You must override this method in a derived class to control the manner in which the
|
||||
<see cref="T:Spring.Web.Mvc.SpringMvcDependencyResolver"/> is registered.
|
||||
</remarks>
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringMvcApplication.ThreadSafeDependencyResolverRegistrar">
|
||||
<summary>
|
||||
Thread-safe class that ensures that the <see cref="T:System.Web.Mvc.IDependencyResolver"/> is registered only once.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.ThreadSafeDependencyResolverRegistrar.Register(System.Web.Mvc.IDependencyResolver)">
|
||||
<summary>
|
||||
Registers the specified resolver.
|
||||
</summary>
|
||||
<param name="resolver">The resolver.</param>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringMvcDependencyResolver">
|
||||
<summary>
|
||||
Spring-based implementation of the <see cref="T:System.Web.Mvc.IDependencyResolver"/> interface.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcDependencyResolver.#ctor(Spring.Context.IApplicationContext)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Spring.Web.Mvc.SpringMvcDependencyResolver"/> class.
|
||||
</summary>
|
||||
<param name="context">The context.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcDependencyResolver.GetService(System.Type)">
|
||||
<summary>
|
||||
Resolves singly registered services that support arbitrary object creation.
|
||||
</summary>
|
||||
<param name="serviceType">The type of the requested service or object.</param>
|
||||
<returns>The requested service or object.</returns>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcDependencyResolver.GetServices(System.Type)">
|
||||
<summary>
|
||||
Resolves multiply registered services.
|
||||
</summary>
|
||||
<param name="serviceType">The type of the requested services.</param>
|
||||
<returns>The requested services.</returns>
|
||||
</member>
|
||||
<member name="P:Spring.Web.Mvc.SpringMvcDependencyResolver.ApplicationContext">
|
||||
<summary>
|
||||
Gets the application context.
|
||||
</summary>
|
||||
<value>The application context.</value>
|
||||
</member>
|
||||
<member name="P:Spring.Web.Mvc.SpringMvcDependencyResolver.ApplicationContextName">
|
||||
<summary>
|
||||
Gets or sets the name of the application context.
|
||||
</summary>
|
||||
<remarks>
|
||||
Defaults to using the root (default) Application Context.
|
||||
</remarks>
|
||||
<value>The name of the application context.</value>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
<?xml version="1.0"?>
|
||||
<doc>
|
||||
<assembly>
|
||||
<name>Spring.Web.Mvc3</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Spring.Context.Support.MvcApplicationContext">
|
||||
<summary>
|
||||
Application Context for ASP.NET MVC Applications
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,Spring.Context.IApplicationContext,System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext with the given parent,
|
||||
loading the definitions from the given XML resources.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(Spring.Context.Support.MvcApplicationContextArgs)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
</summary>
|
||||
<param name="args">The args.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String,System.Boolean,System.String[],Spring.Core.IO.IResource[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="name">The application context name.</param>
|
||||
<param name="caseSensitive">Flag specifying whether to make this context case sensitive or not.</param>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
<param name="configurationResources">Configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContext.#ctor(System.String[])">
|
||||
<summary>
|
||||
Create a new MvcApplicationContext, loading the definitions
|
||||
from the given XML resource.
|
||||
</summary>
|
||||
<param name="configurationLocations">Names of configuration resources.</param>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcApplicationContext.ConfigurationLocations">
|
||||
<summary>
|
||||
An array of resource locations, referring to the XML object
|
||||
definition files that this context is to be built with.
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Examples of the format of the various strings that would be
|
||||
returned by accessing this property can be found in the overview
|
||||
documentation of with the <see cref="T:Spring.Context.Support.XmlApplicationContext"/>
|
||||
class.
|
||||
</p>
|
||||
</remarks>
|
||||
<returns>
|
||||
An array of resource locations, or <see langword="null"/> if none.
|
||||
</returns>
|
||||
</member>
|
||||
<member name="P:Spring.Context.Support.MvcApplicationContext.ConfigurationResources">
|
||||
<summary>
|
||||
An array of resources that this context is to be built with.
|
||||
</summary>
|
||||
<value></value>
|
||||
<remarks>
|
||||
<p>
|
||||
Examples of the format of the various strings that would be
|
||||
returned by accessing this property can be found in the overview
|
||||
documentation of with the <see cref="T:Spring.Context.Support.XmlApplicationContext"/>
|
||||
class.
|
||||
</p>
|
||||
</remarks>
|
||||
<returns>
|
||||
An array of <see cref="T:Spring.Core.IO.IResource"/>s, or <see langword="null"/> if none.
|
||||
</returns>
|
||||
</member>
|
||||
<member name="T:Spring.Context.Support.MvcApplicationContextArgs">
|
||||
<summary>
|
||||
Encapsulates arguments to the <see cref="T:Spring.Context.Support.MvcApplicationContext"/> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor(System.String,Spring.Context.IApplicationContext,System.String[],Spring.Core.IO.IResource[])">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
<param name="name">The name.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">The configuration locations.</param>
|
||||
<param name="configurationResources">The configuration resources.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Context.Support.MvcApplicationContextArgs.#ctor(System.String,Spring.Context.IApplicationContext,System.String[],Spring.Core.IO.IResource[],System.Boolean)">
|
||||
<summary>
|
||||
Initializes a new instance of the MvcApplicationContextArgs class.
|
||||
</summary>
|
||||
<param name="name">The name.</param>
|
||||
<param name="parentContext">The parent context.</param>
|
||||
<param name="configurationLocations">The configuration locations.</param>
|
||||
<param name="configurationResources">The configuration resources.</param>
|
||||
<param name="caseSensitive">if set to <c>true</c> [case sensitive].</param>
|
||||
</member>
|
||||
<member name="T:Spring.Context.Support.MvcContextHandler">
|
||||
<summary>
|
||||
Context Handler for ASP.NET MVC Applications
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringMvcApplication">
|
||||
<summary>
|
||||
Spring.NET-specific HttpApplication for ASP.NET MVC integration.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.Init">
|
||||
<summary>
|
||||
Executes custom initialization code after all event handler modules have been added.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.Application_BeginRequest(System.Object,System.EventArgs)">
|
||||
<summary>
|
||||
Handles the BeginRequest event of the Application control.
|
||||
</summary>
|
||||
<param name="sender">The source of the event.</param>
|
||||
<param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.BuildDependencyResolver">
|
||||
<summary>
|
||||
Builds the dependency resolver.
|
||||
</summary>
|
||||
<returns>The <see cref="T:System.Web.Mvc.IDependencyResolver"/> instance.</returns>
|
||||
You must override this method in a derived class to control the manner in which the
|
||||
<see cref="T:System.Web.Mvc.IDependencyResolver"/> is created.
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.ConfigureApplicationContext">
|
||||
<summary>
|
||||
Configures the <see cref="T:Spring.Context.IApplicationContext"/> instance.
|
||||
</summary>
|
||||
<remarks>
|
||||
You must override this method in a derived class to control the manner in which the
|
||||
<see cref="T:Spring.Context.IApplicationContext"/> is configured.
|
||||
</remarks>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.RegisterDependencyResolver(System.Web.Mvc.IDependencyResolver)">
|
||||
<summary>
|
||||
Registers the DependencyResolver implementation with the MVC runtime.
|
||||
<remarks>
|
||||
You must override this method in a derived class to control the manner in which the
|
||||
<see cref="T:Spring.Web.Mvc.SpringMvcDependencyResolver"/> is registered.
|
||||
</remarks>
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringMvcApplication.ThreadSafeDependencyResolverRegistrar">
|
||||
<summary>
|
||||
Thread-safe class that ensures that the <see cref="T:System.Web.Mvc.IDependencyResolver"/> is registered only once.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcApplication.ThreadSafeDependencyResolverRegistrar.Register(System.Web.Mvc.IDependencyResolver)">
|
||||
<summary>
|
||||
Registers the specified resolver.
|
||||
</summary>
|
||||
<param name="resolver">The resolver.</param>
|
||||
</member>
|
||||
<member name="T:Spring.Web.Mvc.SpringMvcDependencyResolver">
|
||||
<summary>
|
||||
Spring-based implementation of the <see cref="T:System.Web.Mvc.IDependencyResolver"/> interface.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcDependencyResolver.#ctor(Spring.Context.IApplicationContext)">
|
||||
<summary>
|
||||
Initializes a new instance of the <see cref="T:Spring.Web.Mvc.SpringMvcDependencyResolver"/> class.
|
||||
</summary>
|
||||
<param name="context">The context.</param>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcDependencyResolver.GetService(System.Type)">
|
||||
<summary>
|
||||
Resolves singly registered services that support arbitrary object creation.
|
||||
</summary>
|
||||
<param name="serviceType">The type of the requested service or object.</param>
|
||||
<returns>The requested service or object.</returns>
|
||||
</member>
|
||||
<member name="M:Spring.Web.Mvc.SpringMvcDependencyResolver.GetServices(System.Type)">
|
||||
<summary>
|
||||
Resolves multiply registered services.
|
||||
</summary>
|
||||
<param name="serviceType">The type of the requested services.</param>
|
||||
<returns>The requested services.</returns>
|
||||
</member>
|
||||
<member name="P:Spring.Web.Mvc.SpringMvcDependencyResolver.ApplicationContext">
|
||||
<summary>
|
||||
Gets the application context.
|
||||
</summary>
|
||||
<value>The application context.</value>
|
||||
</member>
|
||||
<member name="P:Spring.Web.Mvc.SpringMvcDependencyResolver.ApplicationContextName">
|
||||
<summary>
|
||||
Gets or sets the name of the application context.
|
||||
</summary>
|
||||
<remarks>
|
||||
Defaults to using the root (default) Application Context.
|
||||
</remarks>
|
||||
<value>The name of the application context.</value>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user