示例#1
0
        /// <summary>
        /// Create a Dragon tape block object.
        /// Note that it is possible to create illegal blocks using this method by providing an unsupported block type or an invalid
        /// checksum.  Use the <see cref="Validate">Validate</see> method to verify that the block is actually valid.
        /// For supported block types, the returned object will be of the appropriate type.
        /// </summary>
        /// <param name="blocktype">Block type idenfifier.</param>
        /// <param name="data">Array containing the block payload data, or <value>null</value> for no payload.</param>
        /// <param name="offset">Offset into the data array of first byte of block payload data.</param>
        /// <param name="length">Size of the block payload data.</param>
        /// <param name="checksum">Block checksum.</param>
        /// <returns>Dragon tape block object.</returns>
        public static DragonTapeBlock CreateBlock(DragonTapeBlockType blocktype, byte[] data, int offset, int length, int checksum)
        {
            DragonTapeBlock block = null;

            switch (blocktype)
            {
            case DragonTapeBlockType.Header:
                block = new DragonTapeHeaderBlock(data, offset, length, checksum);
                break;

            case DragonTapeBlockType.Data:
                block = new DragonTapeDataBlock(data, offset, length, checksum);
                break;

            case DragonTapeBlockType.EndOfFile:
                block = new DragonTapeEofBlock(data, offset, length, checksum);
                break;

            default:
                block = new DragonTapeBlock(blocktype);
                block.SetData(data, offset, length);
                block.Checksum = checksum;
                break;
            }

            return(block);
        }
 public void CreateDragonTapeEOFBlock()
 {
     var block = new DragonTapeEofBlock();
     Assert.AreEqual(DragonTapeBlockType.EndOfFile, block.BlockType);
     Assert.AreEqual(0, block.Length);
     block.Validate();
 }
示例#3
0
        private void WriteEndOfFileBlock(DragonFile file)
        {
            var block = new DragonTapeEofBlock();

            block.WriteBlock(Tape, !file.IsGapped);
        }
示例#4
0
 private void WriteEndOfFileBlock(DragonFile file)
 {
     var block = new DragonTapeEofBlock();
     block.WriteBlock(Tape, !file.IsGapped);
 }