public void FileNameAccess(string filesystem, string pathname, string name, string basename, string extension) { IFileName filename = null; switch (filesystem.ToLower()) { case "dragondos": filename = DragonDos.GetFileName(pathname); break; case "flex": filename = Flex.GetFileName(pathname); break; case "os9": filename = OS9.GetFileName(pathname); break; case "rsdos": filename = RsDos.GetFileName(pathname); break; default: Assert.True(false, "Unknown filesystem " + filesystem); break; } Assert.Equal(name, filename.Name); Assert.Equal(basename, filename.Base); Assert.Equal(extension, filename.Extension); //TODO Add test for Ascend method //TODO Add test for Descend method }
public void Initialize(string filesystem, int heads, int tracks, int sectors, int sectorsize, int freespace) { Assert.Equal("dragondos", filesystem); using (var disk = new MemoryDisk(heads, tracks, sectors, sectorsize)) { var dos = DragonDos.Initialize(disk); Assert.Equal(tracks, dos.Tracks); Assert.Equal(sectors * heads, dos.Sectors); dos.Check(); Assert.Equal(freespace, dos.Free()); } }
/// <summary> /// Create empty DragonDos filesystem. /// </summary> /// <param name="args">Command arguments: <disk image name> [<tracks> [<sectors>]].</param> private void CreateFilesystem(IEnumerable <string> args) { int tracks = DefaultTracks; int sectors = DefaultSectors; var ai = args.GetEnumerator(); if (!ai.MoveNext()) { Console.Error.WriteLine("ERROR: Disk image name missing."); return; } var diskname = ai.Current; if (ai.MoveNext()) { tracks = Convert.ToInt32(ai.Current); if (tracks != 40 && tracks != 80) { Console.Error.WriteLine("ERROR: DragonDos only supports 40 and 80 track diskettes."); return; } } if (ai.MoveNext()) { sectors = Convert.ToInt32(ai.Current); if (sectors != 18 && sectors != 36) { Console.Error.WriteLine("ERROR: DragonDos only supports 18 or 36 sectors per track."); return; } } int heads = sectors / 18; sectors -= (heads - 1) * 18; if (File.Exists(diskname)) { Console.Error.WriteLine("ERROR: Target file {0} already exists.", diskname); return; } using (var disk = DiskFactory.CreateDisk(diskname, heads, tracks, sectors, DefaultSectorSize)) { using (var dos = DragonDos.Initialize(disk)) { Console.WriteLine("Created empty filesystem in {0}. Capacity {1} bytes.", diskname, dos.Free()); } } }
private void Run(string[] args) { try { var files = ParseOptions(args); if (files.Count == 0) { ShowUsage(); return; } var diskFileName = files[0] + ".vdk"; if (Verbose) { Console.WriteLine("Writing output VDK disk image \"{0}\".", diskFileName); } using (var dos = DragonDos.Initialize(DiskFactory.CreateDisk(diskFileName, DiskHeads, DiskTracks, DiskSectors, DiskSectorSize))) { foreach (var file in files) { if (Verbose) { Console.WriteLine("Writing file \"{0}\" to disk image.", file); } dos.WriteFile(Path.GetFileName(file).ToUpper(), DragonDosFile.CreateDataFile(IOUtils.ReadStreamFully(new FileStream(file, FileMode.Open)))); } } } catch (DirectoryFullException e) { Console.Error.WriteLine("ERROR: Cannot write file to filesystem. The directory is full."); if (Debug) { Console.Error.WriteLine(e); } return; } catch (FileExistsException e) { Console.Error.WriteLine("ERROR: Cannot write the file as a file with the same name already exists."); if (Debug) { Console.Error.WriteLine(e); } return; } catch (FilesystemFullException e) { Console.Error.WriteLine("ERROR: Cannot write file as the filesystem is full."); if (Debug) { Console.Error.WriteLine(e); } return; } catch (InvalidFilenameException e) { Console.Error.WriteLine("ERROR: The filename {0} is invalid.", e.Filename); if (Debug) { Console.Error.WriteLine(e); } return; } catch (System.IO.IOException e) { Console.Error.WriteLine("ERROR: Local filesystem I/O error."); if (Debug) { Console.Error.WriteLine(e); } return; } catch (Exception e) { Console.Error.WriteLine("ERROR: Unexpected error."); if (Debug) { Console.Error.WriteLine(e); } return; } }