/// <summary> /// Creates a new FooTree from a stream. /// </summary> /// <param name="foo">FooSyncEngine instance; its configuration is used</param> /// <param name="url">fs:// URL the stream is from</param> /// <param name="input">Stream to load data from</param> /// <param name="callback">Progress callback, invoked once per file found. /// The 'total' parameter passed in is always -1, and the 'item' is the directory currently being enumerated. /// Pass 'null' if no callback is desired.</param> public FooTree(FooSyncEngine foo, string url, Stream input, Progress callback = null) { this.Foo = foo; this.Base = new FooSyncUrl(url); this.Files = new Dictionary<string, FooFileInfoBase>(); string path = string.Empty; string source = string.Empty; long mTime = 0; long size = 0; var reader = new BinaryReader(input); while (true) { path = reader.ReadString(); source = reader.ReadString(); mTime = reader.ReadInt64(); size = reader.ReadInt64(); if (path == string.Empty && source == string.Empty && mTime == 0 && size == 0) { return; } var info = new FooFileInfoBase(); info.Path = path; info.Source = source; info.MTime = new DateTime(mTime); info.Size = size; if (callback != null) { callback(Files.Count + 1, -1, path); } Files.Add(path, info); } }
public int CompareTo(FooFileInfoBase other) { if (other == null) throw new ArgumentNullException("other"); return this.MTime.CompareTo(other.MTime); }