Example #1
0
        protected override void ReadContent(ByteReader reader)
        {
            var info = reader.ReadString(HEADER_INFO.Length);
            var ver  = reader.ReadByte();

            if (info != HEADER_INFO)
            {
                throw LiteException.InvalidDatabase();
            }
            if (ver != FILE_VERSION)
            {
                throw LiteException.InvalidDatabaseVersion(ver);
            }

            ChangeID        = reader.ReadUInt16();
            FreeEmptyPageID = reader.ReadUInt32();
            LastPageID      = reader.ReadUInt32();
            UserVersion     = reader.ReadUInt16();
            Password        = reader.ReadBytes(Password.Length);
            Salt            = reader.ReadBytes(Salt.Length);

            // read page collections references (position on end of page)
            var cols = reader.ReadByte();

            for (var i = 0; i < cols; i++)
            {
                CollectionPages.Add(reader.ReadString(), reader.ReadUInt32());
            }

            // use last page byte position for recovery mode only because i forgot to reserve area before collection names!
            // TODO: fix this in next change data structure
            reader.Position = PAGE_SIZE - 1;
            Recovery        = reader.ReadBoolean();
        }