VCDIFF and the decoder in the Miscellaneous Utility Library

This page doesn't go into a great deal of detail about VCDIFF, as it's primarily for the sake of the reader (who shall remain anonymous) who wanted an example of its use. I'm not expecting a great deal of interest in this page - if I get a lot, I'll do more work on it! However, if you want to look at the spec the decoder implements, see RFC 3284.

The simplest way of demonstrating the decoder is probably a small program to recreate an original file given the original and a patch. The program below takes the following parameters:

using System;
using System.IO;

using MiscUtil.Compression.Vcdiff;

class DecodeFile
{
    static void Main(string[] args)
    {
        if (args.Length != 3)
        {
            Console.WriteLine ("Usage: DecodeFile <original> <patch> <target>");
            return;
        }
        
        try
        {
            using (FileStream original = File.OpenRead(args[0]))
            using (FileStream patch = File.OpenRead(args[1]))
            using (FileStream target = File.Open(args[2], 
                                                                                FileMode.OpenOrCreate,
                                                                                FileAccess.ReadWrite))
            {
                VcdiffDecoder.Decode (original, patch, target);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine ("Unexpected exception: {0}", e);
        }
    }
}

Back to the main MiscUtil page.