Пример #1
0
        private static void GetHeaderValues(ref BinaryBufferReader reader,
                                            out int sectorSize,
                                            out int shortSectorSize,
                                            out int satSectorCount,
                                            out int firstSecIdDirectoryStream,
                                            out uint standardStreamSizeThreshold,
                                            out int firstSecIdSsat,
                                            out uint ssatSectorCount,
                                            out int firstSecIdExtendedMsat,
                                            out int msatExtraSectorCount)
        {
            if (!reader.ReadSpan(8).SequenceEqual(HEADER_SIGNATURE))
            {
                throw new CdfException(Errors.HeaderSignatureMissing);
            }

            reader.Position += 22;

            var sectorSizeExponent = reader.ReadUInt16();

            if (sectorSizeExponent < 7)
            {
                throw new CdfException(Errors.SectorSizeTooSmall);
            }
            sectorSize = (int)Math.Pow(2, sectorSizeExponent);

            var shortSectorSizeExponent = reader.ReadUInt16();

            if (shortSectorSizeExponent > sectorSizeExponent)
            {
                throw new CdfException(Errors.ShortSectorSizeGreaterThanStandardSectorSize);
            }
            shortSectorSize = (int)Math.Pow(2, shortSectorSizeExponent);

            reader.Position += 10;

            satSectorCount            = (int)reader.ReadUInt32();
            firstSecIdDirectoryStream = reader.ReadInt32();

            reader.Position += 4;

            standardStreamSizeThreshold = reader.ReadUInt32();
            firstSecIdSsat         = reader.ReadInt32();
            ssatSectorCount        = reader.ReadUInt32();
            firstSecIdExtendedMsat = reader.ReadInt32();
            msatExtraSectorCount   = reader.ReadInt32();
        }
Пример #2
0
        private static ushort GetFieldsCount(byte[] buffer)
        {
            var reader = new BinaryBufferReader(buffer, 0)
            {
                Endianness = Endianness.Big
            };

            return(reader.ReadUInt16());
        }
        public void ReadUInt16(UInt16 input)
        {
            Reset();
            _writer.Write(input);

            var val = _bufferReader.ReadUInt16();

            Assert.Equal(input, val);
        }