public void DecodeDmkHeader() { byte[] encodedHeader = {0x00, 0x28, 0x00, 0x19, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; var header = new DmkDiskHeader(new MemoryStream(encodedHeader)); Assert.AreEqual(true, header.IsWriteable); Assert.AreEqual(false, header.IsSingleDensity); Assert.AreEqual(false, header.IgnoreDensity); Assert.AreEqual(40, header.Tracks); Assert.AreEqual(1, header.Heads); Assert.AreEqual(0x1900, header.EncodedTrackLength); }
/// <summary> /// Reads a DMK disk image from a given stream. /// </summary> /// <param name="image">Stream containing the HFE disk image.</param> /// <param name="isWriteable">Allow write operations to this disk.</param> /// <returns>A disk object.</returns> public static DmkDisk Open(Stream image, bool isWriteable) { if (image == null) { throw new ArgumentNullException("image"); } if (!image.CanRead) { throw new NotSupportedException("Disk image stream does not support reading"); } if (!image.CanSeek) { throw new NotSupportedException("Disk image stream does not support seeking"); } if (isWriteable && !image.CanWrite) { throw new NotSupportedException("Disk image stream does not support writing"); } var header = new DmkDiskHeader(image); if (header.IsSingleDensity) { throw new NotSupportedException("Single density disks not supported"); } var disk = new DmkDisk(); disk.diskImageStream = image; disk.IsWriteable = isWriteable && header.IsWriteable; disk.Heads = header.Heads; disk.Tracks = header.Tracks; disk.TrackLength = header.EncodedTrackLength; return(disk); }
/// <summary> /// Reads a DMK disk image from a given stream. /// </summary> /// <param name="image">Stream containing the HFE disk image.</param> /// <param name="isWriteable">Allow write operations to this disk.</param> /// <returns>A disk object.</returns> public static DmkDisk Open(Stream image, bool isWriteable) { if (image == null) throw new ArgumentNullException("image"); if (!image.CanRead) throw new NotSupportedException("Disk image stream does not support reading"); if (!image.CanSeek) throw new NotSupportedException("Disk image stream does not support seeking"); if (isWriteable && !image.CanWrite) throw new NotSupportedException("Disk image stream does not support writing"); var header = new DmkDiskHeader(image); if (header.IsSingleDensity) throw new NotSupportedException("Single density disks not supported"); var disk = new DmkDisk(); disk.diskImageStream = image; disk.IsWriteable = isWriteable && header.IsWriteable; disk.Heads = header.Heads; disk.Tracks = header.Tracks; disk.TrackLength = header.EncodedTrackLength; return disk; }