Change FormattedDisk#fromProdosFiletype to be FormattedDisk#toNativeFiletype and updated operations to allow native file types and pass them through.

This commit is contained in:
Rob Greene
2025-07-28 10:04:38 -05:00
parent 8954b5b2d3
commit 3353d971ca
11 changed files with 30 additions and 19 deletions
@@ -415,9 +415,11 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
/**
* Provides conversation from a given ProDOS file type since as it is common across
* many archiving tools.
* many archiving tools. This should also allow "native" filetypes to just pass-through.
* (For example, a "B" in a DOS disk should just return a "B" while a "BAS" would be
* transformed to a "B" filetype.)
*/
public abstract String fromProdosFiletype(String prodosFiletype);
public abstract String toNativeFiletype(String prodosFiletype);
/**
* Provides conversation to a given ProDOS file type since as it is common across
* many archiving tools.
@@ -562,7 +562,7 @@ public class CpmFormatDisk extends FormattedDisk {
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
public String toNativeFiletype(String prodosFiletype) {
if ("TXT".equalsIgnoreCase(prodosFiletype)) {
return "TXT";
}
@@ -788,7 +788,11 @@ public class DosFormatDisk extends FormattedDisk {
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
public String toNativeFiletype(String prodosFiletype) {
if (FILE_TYPE_MAPPING.containsKey(prodosFiletype)) {
// This is really a DOS file type. Pass it back.
return prodosFiletype;
}
return FILE_TYPE_MAPPING.entrySet()
.stream()
.filter(e -> e.getValue().equals(prodosFiletype))
@@ -708,7 +708,7 @@ public class GutenbergFormatDisk extends FormattedDisk {
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
public String toNativeFiletype(String prodosFiletype) {
return "T";
}
/**
@@ -546,7 +546,7 @@ public class NakedosFormatDisk extends FormattedDisk {
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
public String toNativeFiletype(String prodosFiletype) {
return "B";
}
/**
@@ -69,11 +69,7 @@ public class PascalFormatDisk extends FormattedDisk {
DATAFILE, "BIN",
"GRAF", "BIN",
"FOTO", "BIN",
"securedir", "BIN",
// Prodos => Pascal
"BIN", DATAFILE,
"TXT", TEXTFILE
"securedir", "BIN"
);
/**
@@ -689,8 +685,17 @@ public class PascalFormatDisk extends FormattedDisk {
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
return FILE_TYPE_MAP.getOrDefault(prodosFiletype, DATAFILE);
public String toNativeFiletype(String prodosFiletype) {
// Note: Can't use the map due to the 1:N relationship, so this is somewhat manual.
for (String pascalFiletype : FILE_TYPES) {
if (prodosFiletype.equalsIgnoreCase(pascalFiletype)) {
return pascalFiletype;
}
}
if ("TXT".equalsIgnoreCase(prodosFiletype)) {
return TEXTFILE;
}
return DATAFILE;
}
/**
* Provides conversation to a given ProDOS file type since as it is common across
@@ -1463,7 +1463,7 @@ public class ProdosFormatDisk extends FormattedDisk {
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
public String toNativeFiletype(String prodosFiletype) {
return prodosFiletype;
};
/**
@@ -577,10 +577,10 @@ public class RdosFormatDisk extends FormattedDisk {
* many archiving tools.
*/
@Override
public String fromProdosFiletype(String prodosFiletype) {
public String toNativeFiletype(String prodosFiletype) {
return FILE_TYPE_MAPPING.entrySet()
.stream()
.filter(e -> e.getValue().equals(prodosFiletype))
.filter(e -> prodosFiletype.equalsIgnoreCase(e.getKey()) || prodosFiletype.equalsIgnoreCase(e.getValue()))
.map(Map.Entry::getKey)
.findFirst()
.orElse("B");
@@ -52,7 +52,7 @@ public class DosFileEntryReaderWriter implements FileEntryReader, FileEntryWrite
}
@Override
public void setProdosFiletype(String filetype) {
String dosFiletype = fileEntry.getFormattedDisk().fromProdosFiletype(filetype);
String dosFiletype = fileEntry.getFormattedDisk().toNativeFiletype(filetype);
fileEntry.setFiletype(dosFiletype);
}
@@ -50,7 +50,7 @@ public class PascalFileEntryReaderWriter implements FileEntryReader, FileEntryWr
}
@Override
public void setProdosFiletype(String filetype) {
fileEntry.setFiletype(fileEntry.getFormattedDisk().fromProdosFiletype(filetype));
fileEntry.setFiletype(fileEntry.getFormattedDisk().toNativeFiletype(filetype));
}
@Override
@@ -211,7 +211,7 @@ public class ImportSelectFilesWizardPane extends WizardPane {
AppleSingle as = AppleSingle.read(data);
suggestedFilename = Optional.ofNullable(as.getRealName())
.orElse(suggestedFilename);
suggestedFiletype = wizard.getDisk().fromProdosFiletype(
suggestedFiletype = wizard.getDisk().toNativeFiletype(
ProdosFormatDisk.getFiletype(as.getProdosFileInfo().getFileType()));
suggestedAddress = Optional.ofNullable(as.getProdosFileInfo())
.map(ProdosFileInfo::getAuxType)