*/
public class Tree
{
+ const long CurrentVersionNumber = 1;
public readonly HelpSource HelpSource;
FileStream InputStream;
/// </summary>
public Tree (HelpSource hs, string filename)
{
+ HelpSource = hs;
Encoding utf8 = new UTF8Encoding (false, true);
if (!File.Exists (filename)){
throw new Exception ("Invalid file format");
InputStream.Position = 4;
+ // Try to read version information
+ if (InputReader.ReadInt32 () == -(int)'v')
+ VersionNumber = InputReader.ReadInt64 ();
+ else
+ InputStream.Position -= 4;
+
var position = InputReader.ReadInt32 ();
rootNode = new Node (this, position);
InflateNode (rootNode);
-
- HelpSource = hs;
}
/// <summary>
Encoding utf8 = new UTF8Encoding (false, true);
using (FileStream output = File.OpenWrite (file)){
// Skip over the pointer to the first node.
- output.Position = 8;
+ output.Position = 4 + 4 + 8 + 4;
using (BinaryWriter writer = new BinaryWriter (output, utf8)) {
// Recursively dump
output.Position = 0;
writer.Write (new byte [] { (byte) 'M', (byte) 'o', (byte) 'H', (byte) 'P' });
+ writer.Write (-(int)'v');
+ writer.Write (CurrentVersionNumber);
writer.Write (rootNode.Address);
}
}
}
}
+ public long VersionNumber {
+ get;
+ private set;
+ }
+
static bool GoodSig (byte [] sig)
{
if (sig.Length != 4)