//      [Theory]
        public void RenameFile(string diskimage, string filesystem, string oldfilename, string newfilename, bool writeprotected, string exception)
        {
            var readwrite = !writeprotected;

            using (var srcdisk = DiskFactory.OpenDisk(testdata + diskimage, false))
            {
                using (var dos = DiskFilesystemFactory.OpenFilesystem(ParseFilesystemID(filesystem), new MemoryDisk(srcdisk), readwrite))
                {
                    try
                    {
                        dos.RenameFile(oldfilename, newfilename);
                        Assert.True(exception == null);
                        Assert.False(dos.FileExists(oldfilename));
                        Assert.True(dos.FileExists(newfilename));
                        dos.Check();
                    }
                    catch (Exception e)
                    {
                        if (exception == null)
                        {
                            Assert.True(false, e.ToString());
                        }
                        else
                        {
                            Assert.Equal(e.GetType().FullName, exception);
                        }
                    }
                }
            }
        }
        public void OpenDiskUnknownFiletype(string imagename)
        {
            var imagepath = testdata + imagename;

            using (var disk = DiskFactory.OpenDisk(imagepath, false))
            {
                disk.Should().BeNull();
            }
        }
        public void OpenDisk(string imagename, Type imagetype)
        {
            var imagepath = testdata + imagename;

            using (var disk = DiskFactory.OpenDisk(imagepath, false))
            {
                disk.GetType().Should().Be(imagetype);
            }
        }
Exemple #4
0
 public void DiskGeometry(string imagename, Type classtype, int heads, int tracks)
 {
     using (var disk = DiskFactory.OpenDisk(testdata + imagename, false))
     {
         disk.GetType().Should().Be(classtype);
         disk.Heads.Should().Be(heads);
         disk.Tracks.Should().Be(tracks);
     }
 }
        /// <summary>
        /// Dump content of a sector to console.
        /// </summary>
        /// <param name="args">Command arguments; disk image name, head, track, sector</param>
        private void DumpSector(IEnumerable <string> args)
        {
            var ai = args.GetEnumerator();

            if (!ai.MoveNext())
            {
                Console.Error.WriteLine("ERROR: Disk image name missing");
                return;
            }
            var diskname = ai.Current;

            if (!ai.MoveNext())
            {
                Console.Error.WriteLine("ERROR: Head number missing");
                return;
            }
            var head = Convert.ToInt32(ai.Current);

            if (!ai.MoveNext())
            {
                Console.Error.WriteLine("ERROR: Track number missing");
                return;
            }
            var track = Convert.ToInt32(ai.Current);

            if (!ai.MoveNext())
            {
                Console.Error.WriteLine("ERROR: Sector number missing");
                return;
            }
            var sector = Convert.ToInt32(ai.Current);

            using (var disk = DiskFactory.OpenDisk(diskname, false))
            {
                if (disk == null)
                {
                    Console.Error.WriteLine("ERROR: Disk image file {0} is not in a supported format.", diskname);
                    return;
                }
                if (verbose)
                {
                    Console.Error.WriteLine("Reading sector data at head={0} track={1} sector={2}", head, track, sector);
                }
                var data   = disk.ReadSector(head, track, sector);
                int offset = 0;
                while (offset < data.Length)
                {
                    Console.Write("{0:x4} : ", offset);
                    for (int i = 0; i < 16 && offset < data.Length; i++)
                    {
                        Console.Write("{0:x2} ", data[offset++]);
                    }
                    Console.WriteLine();
                }
            }
        }
        /// <summary>
        /// Create an IDiskFilesystem object for accessing the filesystem on a disk in a virtual disk file.
        /// </summary>
        /// <param name="fsid">Identifies the filesystem type to create.</param>
        /// <param name="diskfilename">Name of file containing the virtual disk image.</param>
        /// <param name="iswriteable">Returns a writeable filesystem if <value>true</value>.</param>
        /// <returns>A IDiskFilesystem object for accessing the file system on the disk, or <value>null</value> if no filesystem can be created.</returns>
        public static IDiskFilesystem OpenFilesystem(DiskFilesystemIdentifier fsid, string diskfilename, bool iswriteable)
        {
            if (diskfilename == null)
            {
                throw new ArgumentNullException("diskfilename");
            }

            var disk = DiskFactory.OpenDisk(diskfilename, iswriteable);

            return((disk == null) ? null : OpenFilesystem(fsid, disk, iswriteable));
        }
Exemple #7
0
        public void EnumerateSectors(string imagename, int sectorCount)
        {
            var sectors = new Dictionary <DiskPosition, bool>();

            using (var disk = DiskFactory.OpenDisk(testdata + imagename, false))
            {
                foreach (var sector in disk)
                {
                    var pos = new DiskPosition(sector.Track, sector.Head, sector.Sector);
                    sectors.ContainsKey(pos).Should().BeFalse();
                    sectors[pos] = true;
                }
            }
            sectors.Count.Should().Be(sectorCount);
        }
Exemple #8
0
 public void ReadSectors(string imagename)
 {
     using (var disk = DiskFactory.OpenDisk(testdata + imagename, false))
     {
         foreach (var sector in disk)
         {
             int t = sector[0];
             int h = sector[1];
             int s = sector[2];
             t.Should().Be(sector.Track);
             h.Should().Be(sector.Head);
             s.Should().Be(sector.Sector);
         }
     }
 }