public void Read(FileDatabaseStream reader) { var signature = Encoding.UTF8.GetString(reader.ReadBytes(8)); if (signature != "1CDBMSV8") { throw new Exception("This file is not a 1C database"); } var versionData = reader.ReadBytes(4); var version = $"{versionData[0]}.{versionData[1]}.{versionData[2]}.{versionData[3]}"; if (version != "8.3.8.0") { throw new Exception($"{version} is unknown version"); } Signature = signature; Version = version; PagesCount = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); // skip 4 bytes of unknown value reader.ReadBytes(4); PageSize = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); }
public void Read(FileDatabaseStream reader) { var type = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); if (!(type is 0x0000FF1C)) { throw new Exception($"{type} is not a type of \"Free pages\" block"); } Type = type; PagesCount = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); Version = BinaryPrimitives.ReadInt32LittleEndian(reader.ReadBytes(4)); PageNumbers = new int[PagesCount]; for (int i = 0; i < PagesCount; i++) { var number = BinaryPrimitives.ReadInt32LittleEndian(reader.ReadBytes(4)); if (number == 0) { break; } PageNumbers[i] = number; } }
protected byte[] ReadBytes(int count) { _stream.Position = _position; if (_dataPage == -1) { GoToNextDataPage(); } var buffer = new byte[count]; // Loop till read requested quantity var read = 0; while (read < count) { read += _stream.ReadBytes(buffer, read, count - read); if (read < count) { GoToNextDataPage(); } } if (PageReadingCompleted()) { GoToNextDataPage(); } _position = _stream.Position; return(buffer); }
public virtual void Read(FileDatabaseStream reader) { DataLength = BinaryPrimitives.ReadUInt64LittleEndian(reader.ReadBytes(8)); var pageNumbers = new List <uint>(); while (true) { var pageNumber = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); if (pageNumber == 0) { break; } pageNumbers.Add(pageNumber); } PageNumbers = pageNumbers.ToArray(); }
public void Read(FileDatabaseStream reader) { Type = (InnerFileType)BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); var v1 = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); var v2 = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); var v3 = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); Version = $"{v1}.{v2}.{v3}"; DataLength = BinaryPrimitives.ReadUInt64LittleEndian(reader.ReadBytes(8)); var pageNumbers = new List <uint>(); while (true) { var pageNumber = BinaryPrimitives.ReadUInt32LittleEndian(reader.ReadBytes(4)); if (pageNumber == 0) { break; } pageNumbers.Add(pageNumber); } PageNumbers = pageNumbers.ToArray(); }