Example #1
0
 public static XZIndexRecord FromBinaryReader(BinaryReader br)
 {
     var record = new XZIndexRecord();
     record.UnpaddedSize = br.ReadXZInteger();
     record.UncompressedSize = br.ReadXZInteger();
     return record;
 }
Example #2
0
        public static BlockFilter Read(BinaryReader reader)
        {
            var filterType = (FilterTypes)reader.ReadXZInteger();
            if (!FilterMap.ContainsKey(filterType))
                throw new NotImplementedException($"Filter {filterType} has not yet been implemented");
            var filter = Activator.CreateInstance(FilterMap[filterType]) as BlockFilter;

            var sizeOfProperties = reader.ReadXZInteger();
            if (sizeOfProperties > int.MaxValue)
                throw new InvalidDataException("Block filter information too large");
            byte[] properties = reader.ReadBytes((int)sizeOfProperties);
            filter.Init(properties);
            return filter;
        }
Example #3
0
        private void ReadBlockFlags(BinaryReader reader)
        {
            var blockFlags = reader.ReadByte();
            _numFilters = (blockFlags & 0x03) + 1;
            byte reserved = (byte)(blockFlags & 0x3C);

            if (reserved != 0)
                throw new InvalidDataException("Reserved bytes used, perhaps an unknown XZ implementation");

            bool compressedSizePresent = (blockFlags & 0x40) != 0;
            bool uncompressedSizePresent = (blockFlags & 0x80) != 0;

            if (compressedSizePresent)
                CompressedSize = reader.ReadXZInteger();
            if (uncompressedSizePresent)
                UncompressedSize = reader.ReadXZInteger();
        }