Hpdi.VssPhysicalLib.DeltaSimulator.Seek C# (CSharp) Method

Seek() public method

public Seek ( int offset ) : void
offset int
return void
        public void Seek(int offset)
        {
            if (offset != fileOffset)
            {
                if (offset < fileOffset)
                {
                    Reset();
                }
                while (fileOffset < offset && !eof)
                {
                    var seekRemaining = offset - fileOffset;
                    var operationRemaining = enumerator.Current.Length - operationOffset;
                    if (seekRemaining < operationRemaining)
                    {
                        operationOffset += seekRemaining;
                        fileOffset += seekRemaining;
                    }
                    else
                    {
                        fileOffset += operationRemaining;
                        eof = !enumerator.MoveNext();
                        operationOffset = 0;
                    }
                }
            }
        }

Usage Example

Ejemplo n.º 1
0
        public static ICollection <DeltaOperation> Merge(
            IEnumerable <DeltaOperation> lastRevision,
            IEnumerable <DeltaOperation> priorRevision)
        {
            var result = new LinkedList <DeltaOperation>();

            using (var merger = new DeltaSimulator(lastRevision))
            {
                foreach (DeltaOperation operation in priorRevision)
                {
                    switch (operation.Command)
                    {
                    case DeltaCommand.WriteLog:
                        result.AddLast(operation);
                        break;

                    case DeltaCommand.WriteSuccessor:
                        merger.Seek(operation.Offset);
                        merger.Read(operation.Length,
                                    delegate(byte[] data, int offset, int count)
                        {
                            result.AddLast(DeltaOperation.WriteLog(data, offset, count));
                            return(count);
                        },
                                    delegate(int offset, int count)
                        {
                            result.AddLast(DeltaOperation.WriteSuccessor(offset, count));
                            return(count);
                        });
                        break;
                    }
                }
            }
            return(result);
        }
All Usage Examples Of Hpdi.VssPhysicalLib.DeltaSimulator::Seek