Exemple #1
0
 /// <summary>
 /// Reads a region from a stream.
 /// </summary>
 public static DataRegion Read(InStream Stream)
 {
     return new DataRegion
     {
         Start = Stream.ReadLong(),
         Size = Stream.ReadLong()
     };
 }
Exemple #2
0
 /// <summary>
 /// Insures that the local stream has a size of at least 1.
 /// </summary>
 private void _Feed()
 {
     while (this._LocalStreamSize == 0)
     {
         ((Disposable<InStream>)this._LocalStream).Dispose();
         Data next = this._Parts[++this._LocalPart];
         this._LocalStream = next.Read();
         this._LocalStreamSize = next.Size;
     }
 }
Exemple #3
0
 public override void Advance(long Amount)
 {
     if (Amount <= this._LocalStreamSize)
     {
         this._LocalStream.Advance(Amount);
         this._LocalStreamSize -= Amount;
     }
     else
     {
         ((Disposable<InStream>)this._LocalStream).Dispose();
         Data next;
         long size;
         while ((size = (next = this._Parts[++this._LocalPart]).Size) < Amount)
         {
             Amount -= size;
         }
         this._LocalStream = next.Read(Amount);
         this._LocalStreamSize = size - Amount;
     }
 }
Exemple #4
0
 public Stream(Data[] Parts, int LocalPart, long LocalStreamSize, InStream LocalStream)
 {
     this._Parts = Parts;
     this._LocalPart = LocalPart;
     this._LocalStreamSize = LocalStreamSize;
     this._LocalStream = LocalStream;
 }
Exemple #5
0
 /// <summary>
 /// Copies data from a source stream into this stream.
 /// </summary>
 public virtual void Write(InStream Source, long Amount)
 {
     while (Amount > 0)
     {
         this.Write(Source.Read());
         Amount--;
     }
 }
Exemple #6
0
 public override void Write(InStream Source, long Amount)
 {
     this._Count += Amount;
     Source.Advance(Amount);
 }