Exemplo n.º 1
0
        private void SetLink(int headOffset, VersionedLink value)
        {
            if (value == null)
            {
                throw new Exception("Attempted to set invalid header link");
            }
            var strm = value.Freeze();

            lock (_fslock)
            {
                _fs.Seek(MAGIC_SIZE + (VersionedLink.ByteSize * headOffset), SeekOrigin.Begin);
                strm.CopyTo(_fs);
            }
        }
Exemplo n.º 2
0
        public static void InitialiseDb([NotNull] Stream fs)
        {
            if (!fs.CanWrite)
            {
                throw new Exception("Tried to initialise a read-only stream");
            }

            fs.Seek(0, SeekOrigin.Begin);
            foreach (var b in HEADER_MAGIC)
            {
                fs.WriteByte(b);
            }

            // write disabled links for the three core chains
            var indexVersion      = new VersionedLink();
            var pathLookupVersion = new VersionedLink();
            var freeListVersion   = new VersionedLink();

            indexVersion.Freeze().CopyTo(fs);
            pathLookupVersion.Freeze().CopyTo(fs);
            freeListVersion.Freeze().CopyTo(fs);
            Flush(fs);
        }