Exemplo n.º 1
0
        public DRBDatabase()
        {
            this.dbFile = new FileInfo("database.mem");

            /* Since we're going to need access to this data often, lets load it into a MemoryStream.
             * With it being about 2.5MB it's fairly cheap.
             */
            this.dbReader = new SimpleBinaryReader(new FileStream("database.mem", FileMode.Open));

            /* StarSCAN's database.mem has a different endianness;
             * This detects and accounts for that as needed.
             */
            this.isStarScanDB = this.checkStarScan();

            this.makeTables();
        }
Exemplo n.º 2
0
        void ReadTableAttributes(SimpleBinaryReader reader, ref int readOffset, out uint tableOffset, out ushort rowCount, out ushort rowSize, out List <byte> colSizes)
        {
            tableOffset = dbReader.ReadUInt32(ref readOffset);
            rowCount    = dbReader.ReadUInt16(ref readOffset);
            rowSize     = dbReader.ReadUInt16(ref readOffset);

            /* While technically the 'stated' code alone was correct, it had an issue:
             * there are some columns with a size of 0! This is a waste.
             * As such, empty columns are now removed and field IDs adjusted for that. */
            byte statedColCount = dbReader.ReadUInt8(ref readOffset);

            byte[] statedColSizes = dbReader.ReadBytes(ref readOffset, statedColCount);

            /* There's actually room reserved for 27 bytes after the statedColCount,
             * so it is necessary to read past whatever bytes that go unread. */
            readOffset += 27 - statedColCount;

            colSizes = statedColSizes.Where(size => size != 0).ToList();
        }