Beispiel #1
0
            public static bool TryLoadSection(Stream stream, bool alt, int sectionIndex, int blockSize, out FileSection section)
            {
                section = new FileSection(sectionIndex, blockSize, false);
                byte[] part1 = alt ? new byte[blockSize] : section._blockData;
                stream.Position = section._sectionPosition;
                IOStream.Read(stream, part1, blockSize);

                byte[] part2 = !alt ? new byte[blockSize] : section._blockData;
                stream.Position = section._sectionPosition + (section.SectionSize - blockSize);
                IOStream.Read(stream, part2, blockSize);

                section._isDirty = BinaryComparer.Compare(part1, part2) != 0;

                if (!section.CheckValid())
                {
                    section = null;
                    return(false);
                }
                return(true);
            }
 /// <summary> Returns true if the two objects are the same instance </summary>
 bool IEqualityComparer <byte[]> .Equals(byte[] x, byte[] y)
 {
     return(0 == BinaryComparer.Compare(x, y));
 }
 /// <summary> Returns a hash code the instance of the object </summary>
 int IEqualityComparer <byte[]> .GetHashCode(byte[] bytes)
 {
     return(BinaryComparer.GetHashCode(bytes));
 }
 /// <summary> Compares the contents of the byte arrays and returns the result. </summary>
 int IComparer <byte[]> .Compare(byte[] x, byte[] y)
 {
     return(BinaryComparer.Compare(x, y));
 }