mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2024-12-22 23:29:34 +00:00
Added getSuggestedFilename.
This commit is contained in:
parent
fc02bbc6e8
commit
0ce42f9f7e
@ -627,4 +627,13 @@ public class DosFormatDisk extends FormattedDisk {
|
||||
public int getLogicalDiskNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid filename for the given filename. DOS 3.3
|
||||
* pretty much allows anything - so it is cut to 30 characters
|
||||
* and trimmed (trailing whitespace may cause confusion).
|
||||
*/
|
||||
public String getSuggestedFilename(String filename) {
|
||||
return filename.toUpperCase().substring(0, 30).trim();
|
||||
}
|
||||
}
|
||||
|
@ -335,4 +335,11 @@ public abstract class FormattedDisk extends Disk {
|
||||
* volumes to distinguish.
|
||||
*/
|
||||
public abstract int getLogicalDiskNumber();
|
||||
|
||||
/**
|
||||
* Returns a valid filename for the given filename. This does not
|
||||
* necessarily guarantee a unique filename - just validity of
|
||||
* the filename.
|
||||
*/
|
||||
public abstract String getSuggestedFilename(String filename);
|
||||
}
|
||||
|
@ -687,4 +687,25 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||
public int getLogicalDiskNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid filename for the given filename. ProDOS filenames
|
||||
* have a maximum length of 15 characters, must start with a character
|
||||
* and may contain characters (A-Z), digits (0-9), or the period (.).
|
||||
*/
|
||||
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<filename.length()) {
|
||||
char ch = filename.charAt(i);
|
||||
if (Character.isLetterOrDigit(ch) || ch == '.') {
|
||||
newName.append(ch);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return newName.toString().toUpperCase().trim();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user