mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2026-04-20 18:17:12 +00:00
Change FormattedDisk#fromProdosFiletype to be FormattedDisk#toNativeFiletype and updated operations to allow native file types and pass them through.
This commit is contained in:
@@ -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.
|
||||
|
||||
+1
-1
@@ -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";
|
||||
}
|
||||
|
||||
+5
-1
@@ -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))
|
||||
|
||||
+1
-1
@@ -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";
|
||||
}
|
||||
/**
|
||||
|
||||
+1
-1
@@ -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";
|
||||
}
|
||||
/**
|
||||
|
||||
+12
-7
@@ -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
|
||||
|
||||
+1
-1
@@ -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;
|
||||
};
|
||||
/**
|
||||
|
||||
+2
-2
@@ -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");
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user