Added getSuggestedFiletype along with code reorganizations to

support this method.
This commit is contained in:
Robert Greene 2003-02-17 04:41:06 +00:00
parent 93d73755db
commit ba4243a591
5 changed files with 92 additions and 3 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.