public static void Decode(Stream original, Stream delta, Stream output, long adler) { if (original != null && (!original.CanRead || !original.CanSeek)) { throw new ArgumentException("Must be able to read and seek in original stream", "original"); } if (delta == null) { throw new ArgumentNullException("delta"); } if (!delta.CanRead) { throw new ArgumentException("Unable to read from delta stream"); } if (output == null) { throw new ArgumentNullException("output"); } if (!output.CanWrite || !output.CanRead || !output.CanSeek) { throw new ArgumentException("Must be able to read, write and seek in output stream", "output"); } VcdiffDecoder vcdiffDecoder = new VcdiffDecoder(original, delta, output); vcdiffDecoder.Decode(); if (adler != 0 && adler != vcdiffDecoder.adler.Value) { throw new Exception(); } }
/// <summary> /// Decodes an original stream and a delta stream, writing to a target stream. /// The original stream may be null, so long as the delta stream never /// refers to it. The original and delta streams must be readable, and the /// original stream (if any) and the target stream must be seekable. /// The target stream must be writable and readable. The original and target /// streams are rewound to their starts before any data is read; the relevant data /// must occur at the beginning of the original stream, and any data already present /// in the target stream may be overwritten. The delta data must begin /// wherever the delta stream is currently positioned. The delta stream must end /// after the last window. The streams are not disposed by this method. /// </summary> /// <param name="original">Stream containing delta. May be null.</param> /// <param name="delta">Stream containing delta data.</param> /// <param name="output">Stream to write resulting data to.</param> /// <param name="adler">The adler32 value of the output stream</param> public static void Decode(Stream original, Stream delta, Stream output, long adler) { #region Simple argument checking if (original != null && (!original.CanRead || !original.CanSeek)) { throw new ArgumentException("Must be able to read and seek in original stream", "original"); } if (delta == null) { throw new ArgumentNullException("delta"); } if (!delta.CanRead) { throw new ArgumentException("Unable to read from delta stream"); } if (output == null) { throw new ArgumentNullException("output"); } if (!output.CanWrite || !output.CanRead || !output.CanSeek) { throw new ArgumentException("Must be able to read, write and seek in output stream", "output"); } #endregion // Now the arguments are checked, we construct an instance of the // class and ask it to do the decoding. VcdiffDecoder instance = new VcdiffDecoder(original, delta, output); instance.Decode(); if (adler != 0 && adler != instance.adler.Value) { throw new Exception(); } }
/// <summary> /// Decodes an original stream and a delta stream, writing to a target stream. /// The original stream may be null, so long as the delta stream never /// refers to it. The original and delta streams must be readable, and the /// original stream (if any) and the target stream must be seekable. /// The target stream must be writable and readable. The original and target /// streams are rewound to their starts before any data is read; the relevant data /// must occur at the beginning of the original stream, and any data already present /// in the target stream may be overwritten. The delta data must begin /// wherever the delta stream is currently positioned. The delta stream must end /// after the last window. The streams are not disposed by this method. /// </summary> /// <param name="original">Stream containing delta. May be null.</param> /// <param name="delta">Stream containing delta data.</param> /// <param name="output">Stream to write resulting data to.</param> /// <param name="adler">The adler32 value of the output stream</param> public static void Decode(Stream original, Stream delta, Stream output, long adler) { #region Simple argument checking if (original != null && (!original.CanRead || !original.CanSeek)) { throw new ArgumentException ("Must be able to read and seek in original stream", "original"); } if (delta==null) { throw new ArgumentNullException("delta"); } if (!delta.CanRead) { throw new ArgumentException ("Unable to read from delta stream"); } if (output==null) { throw new ArgumentNullException("output"); } if (!output.CanWrite || !output.CanRead || !output.CanSeek) { throw new ArgumentException ("Must be able to read, write and seek in output stream", "output"); } #endregion // Now the arguments are checked, we construct an instance of the // class and ask it to do the decoding. VcdiffDecoder instance = new VcdiffDecoder(original, delta, output); instance.Decode(); if (adler != 0 && adler != instance.adler.Value) throw new Exception(); }