From 9d8b4be006bd2d1679b8f186aa5d035039968040 Mon Sep 17 00:00:00 2001 From: Rob Greene Date: Tue, 14 Dec 2021 21:38:39 -0600 Subject: [PATCH] Adjusting the filename checks; 'ac' now uses the checks. #59 --- .../storage/os/dos33/DosFormatDisk.java | 5 ++- .../storage/os/pascal/PascalFormatDisk.java | 38 ++++++++++--------- .../storage/os/prodos/ProdosFormatDisk.java | 6 ++- .../com/webcodepro/applecommander/ui/ac.java | 6 +-- .../storage/os/dos33/DosFormatDiskTest.java | 27 +++++++++++++ .../os/pascal/PascalFormatDiskTest.java | 27 +++++++++++++ .../os/prodos/ProdosFormatDiskTest.java | 27 +++++++++++++ 7 files changed, 113 insertions(+), 23 deletions(-) create mode 100644 src/test/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDiskTest.java create mode 100644 src/test/java/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDiskTest.java create mode 100644 src/test/java/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDiskTest.java diff --git a/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java b/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java index 320a952..7df98c0 100644 --- a/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java +++ b/src/main/java/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java @@ -172,7 +172,7 @@ public class DosFormatDisk extends FormattedDisk { /** * Create a FileEntry. */ - public FileEntry createFile() throws DiskFullException { + public DosFileEntry createFile() throws DiskFullException { byte[] vtoc = readVtoc(); int track = AppleUtil.getUnsignedByte(vtoc[1]); int sector = AppleUtil.getUnsignedByte(vtoc[2]); @@ -706,6 +706,9 @@ public class DosFormatDisk extends FormattedDisk { * and trimmed (trailing whitespace may cause confusion). */ public String getSuggestedFilename(String filename) { + if (filename.charAt(0) < '@') { + filename = "A" + filename; + } int len = Math.min(filename.length(), 30); return filename.toUpperCase().substring(0, len).trim(); } diff --git a/src/main/java/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDisk.java b/src/main/java/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDisk.java index 0f46421..6b883a7 100644 --- a/src/main/java/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDisk.java +++ b/src/main/java/com/webcodepro/applecommander/storage/os/pascal/PascalFormatDisk.java @@ -187,7 +187,7 @@ public class PascalFormatDisk extends FormattedDisk { /** * Create a new FileEntry. */ - public FileEntry createFile() throws DiskFullException { + public PascalFileEntry createFile() throws DiskFullException { // find index of largest free space int count = 0; int index = 0; int max = 0; int last = 0; int first = 0; int free = 0; @@ -574,24 +574,28 @@ public class PascalFormatDisk extends FormattedDisk { } /** - * Returns a valid filename for the given filename. This is somewhat - * of a guess, but the Pascal filenames appear to have similar - * restrictions as ProDOS. + * Returns a valid filename for the given filename. + *

+ * Summary taken from the filename description in "Apple Pascal: + * Operating System Reference Manual." + *

+ * A legal diskette filename can consist of up to 15 characters. + * Lower- case letters typed into a filename are translated to upper-case, + * and spaces and non-printing characters are removed from the filename. + * All characters are legal in filenames. However, from the keyboard you should + * not type filenames that include the following characters: + * dollar sign ($), left square bracket ([), equals sign (=) question mark, (?), + * RETURN, and the CTRL characters C, F, M, S, U, and @. + *

+ * WARNING: The Filer will not be able to access filenames containing the + * characters dollar sign ($), equals sign (=), question mark (?), + * or comma (,) */ public String getSuggestedFilename(String filename) { - StringBuffer newName = new StringBuffer(); - if (!Character.isLetter(filename.charAt(0))) { - newName.append('A'); - } - int i=0; - while (newName.length() < 15 && i