Reverting some of the changes as the interfaces bleed outside of the

implementation. #36
This commit is contained in:
Rob Greene 2019-10-06 15:44:08 -05:00
parent 8fa9f64b6c
commit 711df891a9
12 changed files with 46 additions and 40 deletions

View File

@ -1,7 +1,7 @@
# Universal AppleCommander version number. Used for: # Universal AppleCommander version number. Used for:
# - Naming JAR file. # - Naming JAR file.
# - The build will insert this into a file that is read at run time as well. # - The build will insert this into a file that is read at run time as well.
version=1.6.0-PRE version=1.5.1-PRE
# Dependency versions # Dependency versions
shkVersion=1.2.2 shkVersion=1.2.2

View File

@ -40,7 +40,7 @@ public interface DirectoryEntry {
* return value should always be a list - a directory * return value should always be a list - a directory
* with 0 entries returns an empty list. * with 0 entries returns an empty list.
*/ */
public List<? extends FileEntry> getFiles() throws DiskException; public List<FileEntry> getFiles() throws DiskException;
/** /**
* Create a new FileEntry. * Create a new FileEntry.

View File

@ -268,7 +268,7 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
* Returns a null if specific filename is not located. * Returns a null if specific filename is not located.
*/ */
public FileEntry getFile(String filename) throws DiskException { public FileEntry getFile(String filename) throws DiskException {
List<? extends FileEntry> files = getFiles(); List<FileEntry> files = getFiles();
return getFile(files, filename.trim()); return getFile(files, filename.trim());
} }
@ -277,7 +277,7 @@ public abstract class FormattedDisk extends Disk implements DirectoryEntry {
* Note that in the instance of a system with directories (ie, ProDOS), * Note that in the instance of a system with directories (ie, ProDOS),
* this really returns the first file with the given filename. * this really returns the first file with the given filename.
*/ */
protected FileEntry getFile(List<? extends FileEntry> files, String filename) throws DiskException { protected FileEntry getFile(List<FileEntry> files, String filename) throws DiskException {
FileEntry theFileEntry = null; FileEntry theFileEntry = null;
if (files != null) { if (files != null) {
for (FileEntry entry : files) { for (FileEntry entry : files) {

View File

@ -89,7 +89,8 @@ public class PascalFormatDisk extends FormattedDisk {
bitmap.set(block); bitmap.set(block);
} }
// process through all files and mark those blocks as used // process through all files and mark those blocks as used
for (PascalFileEntry entry : getFiles()) { for (FileEntry fileEntry : getFiles()) {
PascalFileEntry entry = (PascalFileEntry) fileEntry;
for (int block=entry.getFirstBlock(); block<entry.getLastBlock(); block++) { for (int block=entry.getFirstBlock(); block<entry.getLastBlock(); block++) {
bitmap.clear(block); bitmap.clear(block);
} }
@ -136,8 +137,8 @@ public class PascalFormatDisk extends FormattedDisk {
* Retrieve a list of files. * Retrieve a list of files.
* @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles() * @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles()
*/ */
public List<PascalFileEntry> getFiles() { public List<FileEntry> getFiles() {
List<PascalFileEntry> list = new ArrayList<>(); List<FileEntry> list = new ArrayList<>();
byte[] directory = readDirectory(); byte[] directory = readDirectory();
// process directory blocks: // process directory blocks:
int entrySize = ENTRY_SIZE; int entrySize = ENTRY_SIZE;
@ -300,10 +301,11 @@ public class PascalFormatDisk extends FormattedDisk {
* Return the number of free blocks. * Return the number of free blocks.
*/ */
public int getFreeBlocks() { public int getFreeBlocks() {
List<PascalFileEntry> files = getFiles(); List<FileEntry> files = getFiles();
int blocksFree = getBlocksOnDisk() - 6; int blocksFree = getBlocksOnDisk() - 6;
if (files != null) { if (files != null) {
for (PascalFileEntry entry : files) { for (FileEntry fileEntry : files) {
PascalFileEntry entry = (PascalFileEntry) fileEntry;
blocksFree-= entry.getBlocksUsed(); blocksFree-= entry.getBlocksUsed();
} }
} }
@ -367,10 +369,11 @@ public class PascalFormatDisk extends FormattedDisk {
* Return the number of used blocks. * Return the number of used blocks.
*/ */
public int getUsedBlocks() { public int getUsedBlocks() {
List<PascalFileEntry> files = getFiles(); List<FileEntry> files = getFiles();
int blocksUsed = 6; int blocksUsed = 6;
if (files != null) { if (files != null) {
for (PascalFileEntry entry : files) { for (FileEntry fileEntry : files) {
PascalFileEntry entry = (PascalFileEntry) fileEntry;
blocksUsed+= entry.getBlocksUsed(); blocksUsed+= entry.getBlocksUsed();
} }
} }

View File

@ -24,6 +24,7 @@ import java.util.List;
import com.webcodepro.applecommander.storage.DirectoryEntry; import com.webcodepro.applecommander.storage.DirectoryEntry;
import com.webcodepro.applecommander.storage.DiskException; import com.webcodepro.applecommander.storage.DiskException;
import com.webcodepro.applecommander.storage.DiskFullException; import com.webcodepro.applecommander.storage.DiskFullException;
import com.webcodepro.applecommander.storage.FileEntry;
/** /**
* Implement directory functionality. * Implement directory functionality.
@ -62,7 +63,7 @@ public class ProdosDirectoryEntry extends ProdosFileEntry implements DirectoryEn
* with 0 entries returns an empty list. * with 0 entries returns an empty list.
* @throws DiskException * @throws DiskException
*/ */
public List<ProdosFileEntry> getFiles() throws DiskException { public List<FileEntry> getFiles() throws DiskException {
return getDisk().getFiles(getSubdirectoryHeader().getFileEntryBlock()); return getDisk().getFiles(getSubdirectoryHeader().getFileEntryBlock());
} }

View File

@ -261,7 +261,7 @@ public class ProdosFormatDisk extends FormattedDisk {
* @throws DiskException * @throws DiskException
* @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles() * @see com.webcodepro.applecommander.storage.FormattedDisk#getFiles()
*/ */
public List<ProdosFileEntry> getFiles() throws DiskException { public List<FileEntry> getFiles() throws DiskException {
return getFiles(VOLUME_DIRECTORY_BLOCK); return getFiles(VOLUME_DIRECTORY_BLOCK);
} }
@ -269,8 +269,8 @@ public class ProdosFormatDisk extends FormattedDisk {
* Build a list of files, starting in the given block number. * Build a list of files, starting in the given block number.
* This works for the master as well as the subdirectories. * This works for the master as well as the subdirectories.
*/ */
protected List<ProdosFileEntry> getFiles(int blockNumber) throws DiskException { protected List<FileEntry> getFiles(int blockNumber) throws DiskException {
List<ProdosFileEntry> files = new ArrayList<>(); List<FileEntry> files = new ArrayList<>();
final Set<Integer> visits = new HashSet<>(); final Set<Integer> visits = new HashSet<>();
while (blockNumber != 0) { while (blockNumber != 0) {
// Prevents a recursive catalog crawling. // Prevents a recursive catalog crawling.

View File

@ -102,10 +102,11 @@ public class RdosFormatDisk extends FormattedDisk {
bitmap.set(b); bitmap.set(b);
} }
// for each file, mark the blocks used // for each file, mark the blocks used
for (RdosFileEntry fileEntry : getFiles()) { for (FileEntry fileEntry : getFiles()) {
if (!fileEntry.isDeleted()) { if (!fileEntry.isDeleted()) {
for (int b=0; b<fileEntry.getSizeInBlocks(); b++) { RdosFileEntry entry = (RdosFileEntry) fileEntry;
bitmap.clear(fileEntry.getStartingBlock()+b); for (int b=0; b<entry.getSizeInBlocks(); b++) {
bitmap.clear(entry.getStartingBlock()+b);
} }
} }
} }
@ -179,8 +180,8 @@ public class RdosFormatDisk extends FormattedDisk {
/** /**
* Retrieve a list of files. * Retrieve a list of files.
*/ */
public List<RdosFileEntry> getFiles() { public List<FileEntry> getFiles() {
List<RdosFileEntry> files = new ArrayList<>(); List<FileEntry> files = new ArrayList<>();
for (int b=13; b<23; b++) { for (int b=13; b<23; b++) {
byte[] data = readRdosBlock(b); byte[] data = readRdosBlock(b);
for (int i=0; i<data.length; i+= ENTRY_LENGTH) { for (int i=0; i<data.length; i+= ENTRY_LENGTH) {
@ -240,8 +241,9 @@ public class RdosFormatDisk extends FormattedDisk {
*/ */
public int getUsedBlocks() { public int getUsedBlocks() {
int used = 0; int used = 0;
for (RdosFileEntry fileEntry : getFiles()) { for (FileEntry fileEntry : getFiles()) {
if (!fileEntry.isDeleted()) used+= fileEntry.getSizeInBlocks(); RdosFileEntry entry = (RdosFileEntry) fileEntry;
if (!fileEntry.isDeleted()) used+= entry.getSizeInBlocks();
} }
return used; return used;
} }

View File

@ -467,7 +467,7 @@ public class ac {
/** /**
* Recursive routine to write directory and file entries. * Recursive routine to write directory and file entries.
*/ */
static void writeFiles(List<? extends FileEntry> files, String directory) throws IOException, DiskException { static void writeFiles(List<FileEntry> files, String directory) throws IOException, DiskException {
for (FileEntry entry : files) { for (FileEntry entry : files) {
if ((entry != null) && (!entry.isDeleted()) && (!entry.isDirectory())) { if ((entry != null) && (!entry.isDeleted()) && (!entry.isDirectory())) {
FileFilter ff = entry.getSuggestedFilter(); FileFilter ff = entry.getSuggestedFilter();
@ -493,7 +493,7 @@ public class ac {
* file with the given filename. * file with the given filename.
*/ */
@Deprecated @Deprecated
static FileEntry getEntry(List<? extends FileEntry> files, String fileName) throws DiskException { static FileEntry getEntry(List<FileEntry> files, String fileName) throws DiskException {
if (files != null) { if (files != null) {
for (FileEntry entry : files) { for (FileEntry entry : files) {
String entryName = entry.getFilename(); String entryName = entry.getFilename();
@ -523,7 +523,7 @@ public class ac {
FormattedDisk formattedDisk = formattedDisks[i]; FormattedDisk formattedDisk = formattedDisks[i];
System.out.print(args[d] + " "); System.out.print(args[d] + " ");
System.out.println(formattedDisk.getDiskName()); System.out.println(formattedDisk.getDiskName());
List<? extends FileEntry> files = formattedDisk.getFiles(); List<FileEntry> files = formattedDisk.getFiles();
if (files != null) { if (files != null) {
showFiles(files, "", display); //$NON-NLS-1$ showFiles(files, "", display); //$NON-NLS-1$
} }
@ -547,7 +547,7 @@ public class ac {
* system with directories (e.g. ProDOS), this really returns the first file * system with directories (e.g. ProDOS), this really returns the first file
* with the given filename. * with the given filename.
*/ */
static void showFiles(List<? extends FileEntry> files, String indent, int display) throws DiskException { static void showFiles(List<FileEntry> files, String indent, int display) throws DiskException {
for (FileEntry entry : files) { for (FileEntry entry : files) {
if (!entry.isDeleted()) { if (!entry.isDeleted()) {
List<String> data = entry.getFileColumnData(display); List<String> data = entry.getFileColumnData(display);
@ -728,7 +728,7 @@ public class ac {
} }
public FileEntry getEntry(FormattedDisk formattedDisk) throws DiskException { public FileEntry getEntry(FormattedDisk formattedDisk) throws DiskException {
List<? extends FileEntry> files = formattedDisk.getFiles(); List<FileEntry> files = formattedDisk.getFiles();
FileEntry entry = null; FileEntry entry = null;
for (int i = 0; i < path.length - 1; i++) { for (int i = 0; i < path.length - 1; i++) {
String dirName = path[i]; String dirName = path[i];
@ -754,7 +754,7 @@ public class ac {
if (path.length == 1) { if (path.length == 1) {
return formattedDisk.createFile(); return formattedDisk.createFile();
} }
List<? extends FileEntry> files = formattedDisk.getFiles(); List<FileEntry> files = formattedDisk.getFiles();
DirectoryEntry dir = null, parentDir = null; DirectoryEntry dir = null, parentDir = null;
for (int i = 0; i < path.length - 1; i++) { for (int i = 0; i < path.length - 1; i++) {
String dirName = path[i]; String dirName = path[i];

View File

@ -164,7 +164,7 @@ public class DiskExplorerTab {
private int currentFormat = FormattedDisk.FILE_DISPLAY_STANDARD; private int currentFormat = FormattedDisk.FILE_DISPLAY_STANDARD;
private boolean formatChanged; private boolean formatChanged;
private List<? extends FileEntry> currentFileList; private List<FileEntry> currentFileList;
private Map<Integer,int[]> columnWidths = new HashMap<>(); private Map<Integer,int[]> columnWidths = new HashMap<>();
private boolean showDeletedFiles; private boolean showDeletedFiles;
@ -261,7 +261,7 @@ public class DiskExplorerTab {
if (disks[i].canHaveDirectories()) { if (disks[i].canHaveDirectories()) {
try { try {
Iterator<? extends FileEntry> files = disks[i].getFiles().iterator(); Iterator<FileEntry> files = disks[i].getFiles().iterator();
while (files.hasNext()) { while (files.hasNext()) {
FileEntry entry = (FileEntry) files.next(); FileEntry entry = (FileEntry) files.next();
if (entry.isDirectory()) { if (entry.isDirectory()) {
@ -880,7 +880,7 @@ public class DiskExplorerTab {
/** /**
* Display files in the fileTable. * Display files in the fileTable.
*/ */
protected void fillFileTable(List<? extends FileEntry> fileList) { protected void fillFileTable(List<FileEntry> fileList) {
int[] weights = sashForm.getWeights(); int[] weights = sashForm.getWeights();
if (formatChanged) { if (formatChanged) {
@ -1469,7 +1469,7 @@ public class DiskExplorerTab {
TreeItem selection = directoryTree.getSelection()[0]; TreeItem selection = directoryTree.getSelection()[0];
Object data = selection.getData(); Object data = selection.getData();
DirectoryEntry directory = (DirectoryEntry) data; DirectoryEntry directory = (DirectoryEntry) data;
List<? extends FileEntry> fileList = directory.getFiles(); List<FileEntry> fileList = directory.getFiles();
formatChanged = (currentFormat != newFormat); formatChanged = (currentFormat != newFormat);
if (formatChanged || !fileList.equals(currentFileList)) { if (formatChanged || !fileList.equals(currentFileList)) {
@ -2093,7 +2093,7 @@ public class DiskExplorerTab {
return viewFileItem; return viewFileItem;
} }
protected List<? extends FileEntry> getCurrentFileList() { protected List<FileEntry> getCurrentFileList() {
return currentFileList; return currentFileList;
} }

View File

@ -139,7 +139,7 @@ public class DiskHelperTest {
FormattedDisk formattedDisk = formattedDisks[i]; FormattedDisk formattedDisk = formattedDisks[i];
System.out.println(); System.out.println();
System.out.println(formattedDisk.getDiskName()); System.out.println(formattedDisk.getDiskName());
List<? extends FileEntry> files = formattedDisk.getFiles(); List<FileEntry> files = formattedDisk.getFiles();
if (files != null) { if (files != null) {
showFiles(files, ""); //$NON-NLS-1$ showFiles(files, ""); //$NON-NLS-1$
} }
@ -155,7 +155,7 @@ public class DiskHelperTest {
return formattedDisks; return formattedDisks;
} }
protected void showFiles(List<? extends FileEntry> files, String indent) throws DiskException { protected void showFiles(List<FileEntry> files, String indent) throws DiskException {
for (int i=0; i<files.size(); i++) { for (int i=0; i<files.size(); i++) {
FileEntry entry = files.get(i); FileEntry entry = files.get(i);
if (!entry.isDeleted()) { if (!entry.isDeleted()) {

View File

@ -384,7 +384,7 @@ public class DiskWriterTest {
FormattedDisk formattedDisk = formattedDisks[i]; FormattedDisk formattedDisk = formattedDisks[i];
System.out.println(); System.out.println();
System.out.println(formattedDisk.getDiskName()); System.out.println(formattedDisk.getDiskName());
List<? extends FileEntry> files = formattedDisk.getFiles(); List<FileEntry> files = formattedDisk.getFiles();
if (files != null) { if (files != null) {
showFiles(files, "", false); //$NON-NLS-1$ showFiles(files, "", false); //$NON-NLS-1$
} }
@ -405,7 +405,7 @@ public class DiskWriterTest {
/** /**
* Display a list of files. * Display a list of files.
*/ */
protected void showFiles(List<? extends FileEntry> files, String indent, boolean showDeleted) throws DiskException { protected void showFiles(List<FileEntry> files, String indent, boolean showDeleted) throws DiskException {
for (int i=0; i<files.size(); i++) { for (int i=0; i<files.size(); i++) {
FileEntry entry = (FileEntry) files.get(i); FileEntry entry = (FileEntry) files.get(i);
if (showDeleted || !entry.isDeleted()) { if (showDeleted || !entry.isDeleted()) {
@ -482,7 +482,7 @@ public class DiskWriterTest {
// ignored // ignored
} }
// Remove the files: // Remove the files:
List<? extends FileEntry> files = disk.getFiles(); List<FileEntry> files = disk.getFiles();
for (int i=0; i<files.size(); i++) { for (int i=0; i<files.size(); i++) {
FileEntry entry = (FileEntry) files.get(i); FileEntry entry = (FileEntry) files.get(i);
entry.delete(); entry.delete();
@ -506,7 +506,7 @@ public class DiskWriterTest {
System.out.println("Exercising create, delete, create sequence " //$NON-NLS-1$ System.out.println("Exercising create, delete, create sequence " //$NON-NLS-1$
+ "on disk " + disk.getDiskName() + "."); //$NON-NLS-1$ //$NON-NLS-2$ + "on disk " + disk.getDiskName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
writeFile(disk, 5432, filetype, false); writeFile(disk, 5432, filetype, false);
List<? extends FileEntry> files = disk.getFiles(); List<FileEntry> files = disk.getFiles();
for (int i=0; i<files.size(); i++) { for (int i=0; i<files.size(); i++) {
FileEntry entry = (FileEntry) files.get(i); FileEntry entry = (FileEntry) files.get(i);
entry.delete(); entry.delete();

View File

@ -34,7 +34,7 @@ public class AppleSingleTest {
Disk disk = new Disk(tmpImageName); Disk disk = new Disk(tmpImageName);
FormattedDisk formattedDisk = disk.getFormattedDisks()[0]; FormattedDisk formattedDisk = disk.getFormattedDisks()[0];
List<? extends FileEntry> files = formattedDisk.getFiles(); List<FileEntry> files = formattedDisk.getFiles();
assertNotNull(files); assertNotNull(files);
assertEquals(1, files.size()); assertEquals(1, files.size());
ProdosFileEntry file = (ProdosFileEntry)files.get(0); ProdosFileEntry file = (ProdosFileEntry)files.get(0);