private void EraseBlocks(IEnumerable <int> blocks) { var zeroBuffer = new byte[storage.BlockSize]; foreach (var blockId in blocks) { storage.WriteBlock(blockId, zeroBuffer); } }
private FSHeader CreateFile() { var buffer = new byte[512]; var fsHeader = new FSHeader { AllocationBlock = AllocationBlockId, RootDirectoryBlock = RootDirectoryBlockId, FreeBlockCount = 0 }; storage.WriteBlock(0, new[] { fsHeader }); storage.WriteBlock(1, buffer); buffer[0] = RootDirectoryDataBlockId; storage.WriteBlock(2, buffer); var fsRoot = new DirectoryHeader { FirstEmptyItemOffset = 1, ItemsCount = 0, LastNameOffset = 0, NameBlockIndex = NameBlockIndex, ParentDirectoryBlockIndex = RootDirectoryBlockId }; storage.WriteBlock(RootDirectoryDataBlockId, new[] { new DirectoryHeaderRoot { Header = fsRoot } }); buffer[0] = 0; storage.WriteBlock(NameBlockIndex, buffer); return(fsHeader); }