Example #1
0
        protected static void InitializeEmptyCollection(Stream stream, int blockSize)
        {
            Verify.Argument(blockSize >= MasterBlockSize, "Invalid block size");
            var mbd = new MasterBlockData
            {
                MasterBlockId   = 0,
                BlockSize       = blockSize,
                FreeListBlockId = 0
            };

            WriteMasterBlockData(stream, mbd);
        }
Example #2
0
        private static void WriteMasterBlockData(Stream stream, MasterBlockData mbd)
        {
            var data = new byte[mbd.BlockSize];

            using (var memoryStream = new MemoryStream(data, true))
            {
                using (var writer = new BinaryWriter(memoryStream))
                {
                    writer.Write(Magic.MakeSignature(MagicSignature));
                    writer.Write(Magic.MakeSignature(mbd.ApplicationMagicSignature));
                    writer.Write(mbd.BlockSize);
                    writer.Write(mbd.MasterBlockId);
                    writer.Write(mbd.ApplicationBlockId);
                    writer.Write(mbd.FreeListBlockId);
                }
            }
            stream.Position = 0;
            stream.Write(data, 0, data.Length);
        }