mirror of
https://github.com/AppleCommander/AppleCommander.git
synced 2025-01-22 00:32:08 +00:00
Added getSuggestedFiletype along with code reorganizations to
support this method.
This commit is contained in:
parent
93d73755db
commit
ba4243a591
@ -644,6 +644,24 @@ public class DosFormatDisk extends FormattedDisk {
|
||||
return filename.toUpperCase().substring(0, len).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid filetype for the given filename. The most simple
|
||||
* format will just assume a filetype of binary. This method is
|
||||
* available for the interface to make an intelligent first guess
|
||||
* as to the filetype.
|
||||
*/
|
||||
public String getSuggestedFiletype(String filename) {
|
||||
String filetype = "B";
|
||||
int pos = filename.lastIndexOf(".");
|
||||
if (pos > 0) {
|
||||
String what = filename.substring(pos+1);
|
||||
if ("txt".equalsIgnoreCase(what)) {
|
||||
filetype = "T";
|
||||
}
|
||||
}
|
||||
return filetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of possible file types. Since the filetype is
|
||||
* specific to each operating system, a simple String is used.
|
||||
|
@ -343,6 +343,14 @@ public abstract class FormattedDisk extends Disk {
|
||||
*/
|
||||
public abstract String getSuggestedFilename(String filename);
|
||||
|
||||
/**
|
||||
* Returns a valid filetype for the given filename. The most simple
|
||||
* format will just assume a filetype of binary. This method is
|
||||
* available for the interface to make an intelligent first guess
|
||||
* as to the filetype.
|
||||
*/
|
||||
public abstract String getSuggestedFiletype(String filename);
|
||||
|
||||
/**
|
||||
* Returns a list of possible file types. Since the filetype is
|
||||
* specific to each operating system, a simple String is used.
|
||||
|
@ -40,15 +40,21 @@ public class PascalFormatDisk extends FormattedDisk {
|
||||
* The number of Pascal blocks on a 140K disk.
|
||||
*/
|
||||
public static final int PASCAL_BLOCKS_ON_140K_DISK = 280;
|
||||
|
||||
// filetypes used elsewhere in the code:
|
||||
private static final String TEXTFILE = "textfile";
|
||||
private static final String CODEFILE = "codefile";
|
||||
private static final String DATAFILE = "datafile";
|
||||
|
||||
/**
|
||||
* The know filetypes for a Pascal disk.
|
||||
*/
|
||||
private static final String[] filetypes = {
|
||||
"xdskfile",
|
||||
"codefile",
|
||||
"textfile",
|
||||
CODEFILE,
|
||||
TEXTFILE,
|
||||
"infofile",
|
||||
"datafile",
|
||||
DATAFILE,
|
||||
"graffile",
|
||||
"fotofile",
|
||||
"securedir" };
|
||||
@ -468,6 +474,26 @@ public class PascalFormatDisk extends FormattedDisk {
|
||||
return newName.toString().toUpperCase().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid filetype for the given filename. The most simple
|
||||
* format will just assume a filetype of binary. This method is
|
||||
* available for the interface to make an intelligent first guess
|
||||
* as to the filetype.
|
||||
*/
|
||||
public String getSuggestedFiletype(String filename) {
|
||||
String filetype = DATAFILE;
|
||||
int pos = filename.lastIndexOf(".");
|
||||
if (pos > 0) {
|
||||
String what = filename.substring(pos+1);
|
||||
if ("txt".equalsIgnoreCase(what)) {
|
||||
filetype = TEXTFILE;
|
||||
} else if ("pas".equalsIgnoreCase(what)) {
|
||||
filetype = CODEFILE;
|
||||
}
|
||||
}
|
||||
return filetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of possible file types. Since the filetype is
|
||||
* specific to each operating system, a simple String is used.
|
||||
|
@ -775,6 +775,25 @@ public class ProdosFormatDisk extends FormattedDisk {
|
||||
return newName.toString().toUpperCase().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid filetype for the given filename. The most simple
|
||||
* format will just assume a filetype of binary. This method is
|
||||
* available for the interface to make an intelligent first guess
|
||||
* as to the filetype.
|
||||
*/
|
||||
public String getSuggestedFiletype(String filename) {
|
||||
String filetype = "BIN";
|
||||
int pos = filename.lastIndexOf(".");
|
||||
if (pos > 0) {
|
||||
String what = filename.substring(pos+1);
|
||||
ProdosFileType type = findFileType(what);
|
||||
if (type != null) {
|
||||
filetype = type.getString();
|
||||
}
|
||||
}
|
||||
return filetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the filetype of this file. This will be three characters,
|
||||
* according to ProDOS - a "$xx" if unknown.
|
||||
|
@ -421,6 +421,24 @@ public class RdosFormatDisk extends FormattedDisk {
|
||||
return filename.toUpperCase().substring(0, len).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid filetype for the given filename. The most simple
|
||||
* format will just assume a filetype of binary. This method is
|
||||
* available for the interface to make an intelligent first guess
|
||||
* as to the filetype.
|
||||
*/
|
||||
public String getSuggestedFiletype(String filename) {
|
||||
String filetype = "B";
|
||||
int pos = filename.lastIndexOf(".");
|
||||
if (pos > 0) {
|
||||
String what = filename.substring(pos+1);
|
||||
if ("txt".equalsIgnoreCase(what)) {
|
||||
filetype = "T";
|
||||
}
|
||||
}
|
||||
return filetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of possible file types. Since the filetype is
|
||||
* specific to each operating system, a simple String is used.
|
||||
|
Loading…
x
Reference in New Issue
Block a user