sort empty prodos folders correctly

This commit is contained in:
Denis Molony 2020-02-18 17:26:32 +10:00
parent 0c66757679
commit 639330b24d
5 changed files with 27 additions and 5 deletions

View File

@ -138,6 +138,10 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
gridLayout = new Dimension (16, 35); gridLayout = new Dimension (16, 35);
break; break;
case 704:
gridLayout = new Dimension (16, 44);
break;
case 768: case 768:
gridLayout = new Dimension (16, 48); gridLayout = new Dimension (16, 48);
break; break;

View File

@ -52,15 +52,16 @@ class AppleDiskTab extends AbstractTab
// This constructor is only called when lastFileUsed is not null, but the disk // This constructor is only called when lastFileUsed is not null, but the disk
// couldn't find the file entry. Either the file has been deleted, or it is a disk // couldn't find the file entry. Either the file has been deleted, or it is a disk
// with redefined files (Wizardry, Infocom etc). // with redefined files (Wizardry, Infocom etc).
// Or possibly a root volume folder.
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector, public AppleDiskTab (FormattedDisk disk, DiskAndFileSelector selector,
RedoHandler redoHandler, Font font, String lastFileUsed) RedoHandler redoHandler, Font font, String lastFileUsed)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
super (redoHandler, selector, font); super (redoHandler, selector, font);
System.out.println ("****************** File not found"); System.out.println ("File not found: " + lastFileUsed);
create (disk); create (disk);
// System.out.println ("ooh - couldn't find the previous file");
DefaultMutableTreeNode node = findNode (lastFileUsed); DefaultMutableTreeNode node = findNode (lastFileUsed);
if (node != null) if (node != null)
{ {

View File

@ -108,7 +108,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case PASCAL_ON_PROFILE: case PASCAL_ON_PROFILE:
indexBlocks.add (disk.getDiskAddress (keyPtr)); indexBlocks.add (disk.getDiskAddress (keyPtr));
System.out.println ("PASCAL on PROFILE: " + name); System.out.println ("PASCAL on PROFILE: " + name); // PDUCSD12.PO
// are these blocks guaranteed to be contiguous? // are these blocks guaranteed to be contiguous?
break; break;

View File

@ -124,10 +124,12 @@ class ProdosCatalogSector extends AbstractSector
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
addText (text, buffer, offset + 16, 4, "Not used"); addText (text, buffer, offset + 16, 4, "Not used");
text.append (getCommonHeader (offset)); text.append (getCommonHeader (offset));
addTextAndDecimal (text, buffer, offset + 35, 2, "Bit map pointer"); addTextAndDecimal (text, buffer, offset + 35, 2, "Bit map pointer");
addTextAndDecimal (text, buffer, offset + 37, 2, "Total blocks"); addTextAndDecimal (text, buffer, offset + 37, 2, "Total blocks");
return text.toString (); return text.toString ();
} }
@ -136,12 +138,14 @@ class ProdosCatalogSector extends AbstractSector
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
addText (text, buffer, offset + 16, 1, "Hex $75"); addText (text, buffer, offset + 16, 1, "Hex $75");
addText (text, buffer, offset + 17, 3, "Not used"); addText (text, buffer, offset + 17, 3, "Not used");
text.append (getCommonHeader (offset)); text.append (getCommonHeader (offset));
addTextAndDecimal (text, buffer, offset + 35, 2, "Parent block"); addTextAndDecimal (text, buffer, offset + 35, 2, "Parent block");
addTextAndDecimal (text, buffer, offset + 37, 1, "Parent entry number"); addTextAndDecimal (text, buffer, offset + 37, 1, "Parent entry number");
addTextAndDecimal (text, buffer, offset + 38, 1, "Parent entry length"); addTextAndDecimal (text, buffer, offset + 38, 1, "Parent entry length");
return text.toString (); return text.toString ();
} }
@ -150,13 +154,16 @@ class ProdosCatalogSector extends AbstractSector
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
addText (text, buffer, offset + 20, 4, "Not used"); addText (text, buffer, offset + 20, 4, "Not used");
GregorianCalendar created = HexFormatter.getAppleDate (buffer, offset + 24); GregorianCalendar created = HexFormatter.getAppleDate (buffer, offset + 24);
String dateC = created == null ? "" : parent.df.format (created.getTime ()); String dateC = created == null ? "" : parent.df.format (created.getTime ());
addText (text, buffer, offset + 24, 4, "Creation date : " + dateC); addText (text, buffer, offset + 24, 4, "Creation date : " + dateC);
addText (text, buffer, offset + 28, 1, "Prodos version"); addText (text, buffer, offset + 28, 1, "Prodos version");
addText (text, buffer, offset + 29, 1, "Minimum version"); addText (text, buffer, offset + 29, 1, "Minimum version");
addText (text, buffer, offset + 30, 1, "Access"); addText (text, buffer, offset + 30, 1, "Access");
addTextAndDecimal (text, buffer, offset + 31, 1, "Entry length"); addTextAndDecimal (text, buffer, offset + 31, 1, "Entry length");
addTextAndDecimal (text, buffer, offset + 32, 1, "Entries per block"); addTextAndDecimal (text, buffer, offset + 32, 1, "Entries per block");
addTextAndDecimal (text, buffer, offset + 33, 2, "File count"); addTextAndDecimal (text, buffer, offset + 33, 2, "File count");
@ -220,13 +227,18 @@ class ProdosCatalogSector extends AbstractSector
} }
// Deleted files leave the name intact, but set the name length to zero // Deleted files leave the name intact, but set the name length to zero
// Also - the pointers in the master blocks of a sapling or tree file are
// swapped when the file is deleted.
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
private String getDeletedName (int offset) private String getDeletedName (int offset)
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
{ {
StringBuilder text = new StringBuilder (); StringBuilder text = new StringBuilder ();
for (int i = offset, max = offset + 15; i < max && buffer[i] != 0; i++) for (int i = offset, max = offset + 15; i < max && buffer[i] != 0; i++)
text.append ((char) (buffer[i] & 0xFF)); text.append ((char) (buffer[i] & 0xFF));
return text.toString (); return text.toString ();
} }
} }

View File

@ -362,10 +362,15 @@ public class ProdosDisk extends AbstractFormattedDisk
@Override @Override
public int compare (DefaultMutableTreeNode o1, DefaultMutableTreeNode o2) public int compare (DefaultMutableTreeNode o1, DefaultMutableTreeNode o2)
{ {
if (o1.isLeaf () && !o2.isLeaf ()) boolean folder1 = o1.getAllowsChildren ();
boolean folder2 = o2.getAllowsChildren ();
// if (o1.isLeaf () && !o2.isLeaf ())
if (folder1 && !folder2)
return -1; return -1;
if (!o1.isLeaf () && o2.isLeaf ()) // if (!o1.isLeaf () && o2.isLeaf ())
if (!folder1 && folder2)
return 1; return 1;
String name1 = ((FileEntry) o1.getUserObject ()).name; String name1 = ((FileEntry) o1.getUserObject ()).name;