Compare commits

...

5 Commits

Author SHA1 Message Date
Denis Molony 3bf972a761 tidying 2023-09-16 06:51:31 +10:00
Denis Molony fd5bee6e5c tidying 2023-04-07 19:50:02 +10:00
Denis Molony 0af6714119 tidying 2023-03-16 09:00:31 +10:00
Denis Molony 22dfaf65c6 spacing 2023-03-11 16:35:48 +10:00
Denis Molony f4a6465b04 shorten absolute path 2023-02-24 12:33:21 +10:00
11 changed files with 135 additions and 90 deletions

View File

@ -243,7 +243,7 @@ public class SHRPictureFile1 extends HiResImage
colorTables[i] = new ColorTable (i, data, ptr);
else
colorTables[i] = new ColorTable (i, 0x00); // default empty table !! not
// finished
// finished
ptr += 32;
}
}

View File

@ -202,7 +202,7 @@ public class SubLine implements ApplesoftConstants
private void checkFunction (String var, byte terminator)
// ---------------------------------------------------------------------------------//
{
assert terminator == ASCII_LEFT_BRACKET;
// assert terminator == ASCII_LEFT_BRACKET;
if (!functions.contains (var))
functions.add (var);

View File

@ -206,8 +206,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
DefaultMutableTreeNode root = getCatalogTreeRoot ();
if (root.getUserObject () == null)
root.setUserObject (
new DefaultAppleFileSource (getName (), disk.toString (), this));
root.setUserObject (new DefaultAppleFileSource (getName (), disk.toString (), this));
}
// ---------------------------------------------------------------------------------//
@ -234,15 +233,15 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
public String getDisplayPath ()
// ---------------------------------------------------------------------------------//
{
// if (originalPath != null)
// return originalPath.toString ();
String home = System.getProperty ("user.home");
String path = originalPath != null ? originalPath.toString ()
: disk.getFile ().getAbsolutePath ();
if (path.startsWith (home))
return "~" + path.substring (home.length ());
String path =
originalPath != null ? originalPath.toString () : disk.getFile ().getAbsolutePath ();
int pos = path.indexOf (home);
if (pos == 0 || (path.startsWith ("/Volumes/") && pos > 0))
return "~" + path.substring (home.length () + pos);
return disk.getFile ().getAbsolutePath ();
}
@ -327,8 +326,7 @@ public abstract class AbstractFormattedDisk implements FormattedDisk
if (children != null)
while (children.hasMoreElements ())
{
DefaultMutableTreeNode childNode =
(DefaultMutableTreeNode) children.nextElement ();
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement ();
if (childNode.getUserObject ().toString ().indexOf (name) > 0)
return childNode;
}

View File

@ -733,12 +733,8 @@ public class AppleDisk implements Disk
{
StringBuilder text = new StringBuilder ();
String path = file.getAbsolutePath ();
String home = System.getProperty ("user.home");
if (path.startsWith (home))
path = "~" + path.substring (home.length ());
text.append (String.format ("Path ......... %s%n", path));
text.append (
String.format ("Path ......... %s%n", Utility.getShortPath (file.getAbsolutePath ())));
text.append (String.format ("File name .... %s%n", file.getName ()));
text.append (String.format ("File size .... %,d%n", file.length ()));
text.append (String.format ("Tracks ....... %d%n", tracks));

View File

@ -17,7 +17,8 @@ public class Binary2
// -----------------------------------------------------------------------------------//
{
private static final String UNDERLINE =
"------------------------------------------------------" + "-----------------------";
"------------------------------------------------------"
+ "-----------------------";
private Binary2Header binary2Header;
private byte[] buffer;
@ -54,8 +55,8 @@ public class Binary2
}
// ---------------------------------------------------------------------------------//
public byte[] getDiskBuffer ()
throws DiskFullException, VolumeCatalogFullException, FileAlreadyExistsException, IOException
public byte[] getDiskBuffer () throws DiskFullException, VolumeCatalogFullException,
FileAlreadyExistsException, IOException
// ---------------------------------------------------------------------------------//
{
ProdosDisk disk = new ProdosDisk (800, "DiskBrowser");
@ -72,8 +73,8 @@ public class Binary2
Squeeze squeeze = new Squeeze ();
byte[] tmp = squeeze.unSqueeze (dataBuffer);
disk.addFile (name, header.fileType, header.auxType, header.created, header.modified, tmp,
tmp.length);
disk.addFile (name, header.fileType, header.auxType, header.created,
header.modified, tmp, tmp.length);
}
else
disk.addFile (header.fileName, header.fileType, header.auxType, header.created,
@ -91,12 +92,12 @@ public class Binary2
{
StringBuilder text = new StringBuilder ();
text.append (
String.format (" %-15.15s Files:%5d%n%n",
fileName, headers.size ()));
text.append (String.format (
" %-15.15s Files:%5d%n%n",
fileName, headers.size ()));
text.append (
" Name Type Auxtyp Modified" + " Fmat Length\n");
text.append (" Name Type Auxtyp Modified"
+ " Fmat Length\n");
text.append (String.format ("%s%n", UNDERLINE));

View File

@ -21,7 +21,8 @@ public class NuFX
// -----------------------------------------------------------------------------------//
{
private static final String UNDERLINE =
"------------------------------------------------------" + "-----------------------";
"------------------------------------------------------"
+ "-----------------------";
private MasterHeader masterHeader;
private final byte[] buffer;
private final boolean debug = false;
@ -39,6 +40,7 @@ public class NuFX
{
buffer = Files.readAllBytes (path);
volumeName = new VolumeName (path.getFileName ().toString ());
read (buffer);
}
@ -94,6 +96,7 @@ public class NuFX
if (record.hasDisk ())
++totalDisks;
}
System.out.println (toString ());
}
// ---------------------------------------------------------------------------------//
@ -181,14 +184,14 @@ public class NuFX
}
if (debug)
System.out.printf ("%3d %-35s %02X %,7d %,7d %,7d %s %s%n", ++count, fileName,
fileType, auxType, eof, buffer.length, created, modified);
System.out.printf ("%3d %-35s %02X %,7d %,7d %,7d %s %s%n", ++count,
fileName, fileType, auxType, eof, buffer.length, created, modified);
FileEntry fileEntry;
try
{
fileEntry =
disk.addFile (fileName, fileType, auxType, created, modified, buffer, eof);
fileEntry = disk.addFile (fileName, fileType, auxType, created, modified,
buffer, eof);
}
catch (FileAlreadyExistsException e)
{
@ -266,8 +269,8 @@ public class NuFX
volumeName.volumeName, masterHeader.getCreated2 (), masterHeader.getModified2 (),
masterHeader.getTotalRecords ()));
text.append (
" Name Type Auxtyp Archived" + " Fmat Size Un-Length\n");
text.append (" Name Type Auxtyp Archived"
+ " Fmat Size Un-Length\n");
text.append (String.format ("%s%n", UNDERLINE));

View File

@ -15,13 +15,12 @@ class Record
// -----------------------------------------------------------------------------------//
{
private static final byte[] NuFX = { 0x4E, (byte) 0xF5, 0x46, (byte) 0xD8 };
private static String[] fileSystems =
{ "", "ProDOS/SOS", "DOS 3.3", "DOS 3.2", "Apple II Pascal", "Macintosh HFS",
"Macintosh MFS", "Lisa File System", "Apple CP/M", "", "MS-DOS", "High Sierra",
"ISO 9660", "AppleShare" };
private static String[] fileSystems = { "", "ProDOS/SOS", "DOS 3.3", "DOS 3.2",
"Apple II Pascal", "Macintosh HFS", "Macintosh MFS", "Lisa File System",
"Apple CP/M", "", "MS-DOS", "High Sierra", "ISO 9660", "AppleShare" };
private static String[] storage = { "", "Seedling", "Sapling", "Tree", "", "Extended",
"", "", "", "", "", "", "", "Subdirectory" };
"", "", "", "", "", "", "", "Subdirectory" };
private static String[] accessChars = { "D", "R", "B", "", "", "I", "W", "R" };
private static String threadFormats[] = { "unc", "sq ", "lz1", "lz2", "", "" };
@ -254,6 +253,13 @@ class Record
return 0;
}
// ---------------------------------------------------------------------------------//
String getThreadFormatText ()
// ---------------------------------------------------------------------------------//
{
return threadFormats[getThreadFormat ()];
}
// ---------------------------------------------------------------------------------//
int getUncompressedSize ()
// ---------------------------------------------------------------------------------//
@ -283,6 +289,17 @@ class Record
return size;
}
// ---------------------------------------------------------------------------------//
public float getCompressedPct ()
// ---------------------------------------------------------------------------------//
{
float pct = 100;
if (getUncompressedSize () > 0)
pct = getCompressedSize () * 100 / getUncompressedSize ();
return pct;
}
// ---------------------------------------------------------------------------------//
byte[] getData ()
// ---------------------------------------------------------------------------------//
@ -313,9 +330,9 @@ class Record
if (name.length () > 27)
name = ".." + name.substring (name.length () - 25);
float pct = 100;
if (getUncompressedSize () > 0)
pct = getCompressedSize () * 100 / getUncompressedSize ();
// float pct = 100;
// if (getUncompressedSize () > 0)
// pct = getCompressedSize () * 100 / getUncompressedSize ();
String lockedFlag = (access | 0xC3) == 1 ? "+" : " ";
String forkedFlag = hasResource () ? "+" : " ";
@ -323,11 +340,11 @@ class Record
if (hasDisk ())
return String.format ("%s%-27.27s %-4s %-6s %-15s %s %3.0f%% %7d", lockedFlag,
name, "Disk", (getUncompressedSize () / 1024) + "k", archived.format2 (),
threadFormats[getThreadFormat ()], pct, getUncompressedSize ());
getThreadFormatText (), getCompressedPct (), getUncompressedSize ());
return String.format ("%s%-27.27s %s%s $%04X %-15s %s %3.0f%% %7d", lockedFlag,
name, fileTypes[fileType], forkedFlag, auxType, archived.format2 (),
threadFormats[getThreadFormat ()], pct, getUncompressedSize ());
getThreadFormatText (), getCompressedPct (), getUncompressedSize ());
}
// ---------------------------------------------------------------------------------//

View File

@ -29,7 +29,8 @@ public class PascalDisk extends AbstractFormattedDisk
// -----------------------------------------------------------------------------------//
{
static final int CATALOG_ENTRY_SIZE = 26;
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
private final DateTimeFormatter dtf =
DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
private final VolumeEntry volumeEntry;
private final PascalCatalogSector diskCatalogSector;
@ -48,8 +49,8 @@ public class PascalDisk extends AbstractFormattedDisk
SectorType fotoSector = new SectorType ("Foto", Color.gray);
SectorType badSector = new SectorType ("Bad", Color.darkGray);
SectorType[] sectors = { catalogSector, badSector, codeSector, textSector, infoSector, dataSector,
grafSector, fotoSector };
SectorType[] sectors = { catalogSector, badSector, codeSector, textSector, infoSector,
dataSector, grafSector, fotoSector };
// ---------------------------------------------------------------------------------//
public PascalDisk (Disk disk)
@ -100,7 +101,8 @@ public class PascalDisk extends AbstractFormattedDisk
freeBlocks.set (i, false);
}
diskCatalogSector = new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors);
diskCatalogSector =
new PascalCatalogSector (disk, disk.readBlocks (sectors), sectors);
// read the catalog
List<DiskAddress> addresses = new ArrayList<> ();
@ -297,16 +299,18 @@ public class PascalDisk extends AbstractFormattedDisk
{
String newLine = String.format ("%n");
String newLine2 = newLine + newLine;
String line =
"---- --------------- ---- -------- ------- ---- ---- ----" + newLine;
String line = "---- --------------- ---- -------- ------- ---- ---- ----"
+ newLine;
String date = volumeEntry.localDate == null ? "--" : volumeEntry.localDate.format (dtf);
String date =
volumeEntry.localDate == null ? "--" : volumeEntry.localDate.format (dtf);
StringBuilder text = new StringBuilder ();
text.append ("File : " + getDisplayPath () + newLine2);
text.append ("Volume : " + volumeEntry.name + newLine);
text.append ("Date : " + date + newLine2);
text.append ("Blks Name Type Date Length Frst Last Blks\n");
text.append (
"Blks Name Type Date Length Frst Last Blks\n");
text.append (line);
int usedBlocks = 6;
@ -319,15 +323,16 @@ public class PascalDisk extends AbstractFormattedDisk
date = ce.localDate == null ? "--" : ce.localDate.format (dtf);
int bytes = (size - 1) * 512 + ce.bytesUsedInLastBlock;
String fileType =
ce.fileType < 0 || ce.fileType >= fileTypes.length ? "????" : fileTypes[ce.fileType];
text.append (String.format ("%4d %-15s %-6s %8s %,8d $%03X $%03X $%03X%n", size,
ce.name, fileType, date, bytes, ce.firstBlock, ce.lastBlock, size));
String fileType = ce.fileType < 0 || ce.fileType >= fileTypes.length ? "????"
: fileTypes[ce.fileType];
text.append (String.format ("%4d %-15s %-6s %8s %,8d $%03X $%03X $%03X%n",
size, ce.name, fileType, date, bytes, ce.firstBlock, ce.lastBlock, size));
}
text.append (line);
text.append (String.format ("Blocks free : %3d Blocks used : %3d Total blocks : %3d%n",
(volumeEntry.totalBlocks - usedBlocks), usedBlocks, volumeEntry.totalBlocks));
text.append (
String.format ("Blocks free : %3d Blocks used : %3d Total blocks : %3d%n",
(volumeEntry.totalBlocks - usedBlocks), usedBlocks, volumeEntry.totalBlocks));
return new DefaultAppleFileSource (volumeEntry.name, text.toString (), this);
}

View File

@ -15,8 +15,8 @@ import com.bytezone.diskbrowser.utilities.Utility;
abstract class CatalogEntry implements AppleFileSource
// -----------------------------------------------------------------------------------//
{
static String[] storageTypes =
{ "Del", "Sdl", "Sap", "Tre", "Pas", "Ext", "", "", "", "", "", "", "", "DIR", "SDH", "VDH" };
static String[] storageTypes = { "Del", "Sdl", "Sap", "Tre", "Pas", "Ext", "", "", "",
"", "", "", "", "DIR", "SDH", "VDH" };
Disk disk;
ProdosDisk parentDisk;

View File

@ -72,8 +72,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
private FileEntry link;
// ---------------------------------------------------------------------------------//
FileEntry (ProdosDisk fDisk, byte[] entryBuffer, DirectoryHeader parent, int parentBlock,
int entryNo)
FileEntry (ProdosDisk fDisk, byte[] entryBuffer, DirectoryHeader parent,
int parentBlock, int entryNo)
// ---------------------------------------------------------------------------------//
{
super (fDisk, entryBuffer, parentBlock, entryNo);
@ -101,7 +101,6 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case GSOS_EXTENDED_FILE:
readForks ();
// System.out.printf ("%s has forks%n", getUniqueName ());
break;
case SUBDIRECTORY:
@ -351,7 +350,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
file = new DoubleHiResImage (name, outBuffer);
break;
case 0x8000:
file = new SHRPictureFile2 (name, outBuffer, FILE_TYPE_PIC, 0x2000, 0x8000);
file =
new SHRPictureFile2 (name, outBuffer, FILE_TYPE_PIC, 0x2000, 0x8000);
break;
default:
file = new AssemblerProgram (name, exactBuffer, auxType);
@ -371,8 +371,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
}
// else if (name.endsWith (".PIC")) // 0091 X-BASIC../../XBASIC.PIC
// file = new SHRPictureFile2 (name, exactBuffer, fileType, auxType, endOfFile);
else if ((name.equals ("DOS.3.3") || name.equals ("DDOS.3.3")) && endOfFile == 0x2800
&& DosMasterFile.isDos33 (parentDisk, exactBuffer))
else if ((name.equals ("DOS.3.3") || name.equals ("DDOS.3.3"))
&& endOfFile == 0x2800 && DosMasterFile.isDos33 (parentDisk, exactBuffer))
{
file = new DosMasterFile (name, exactBuffer);
}
@ -415,8 +415,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
case FILE_TYPE_DIRECTORY:
VolumeDirectoryHeader vdh = parentDisk.getVolumeDirectoryHeader ();
file = new ProdosDirectory (parentDisk, name, buffer, vdh.totalBlocks, vdh.freeBlocks,
vdh.usedBlocks);
file = new ProdosDirectory (parentDisk, name, buffer, vdh.totalBlocks,
vdh.freeBlocks, vdh.usedBlocks);
break;
case FILE_TYPE_APPLESOFT_BASIC_VARS:
@ -627,7 +627,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
if (addresses.size () > 0)
{
byte[] tempBuffer = disk.readBlocks (addresses);
buffers.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
buffers.add (
new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
addresses.clear ();
}
logicalBlock += 256;
@ -727,8 +728,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
}
// ---------------------------------------------------------------------------------//
private int readIndexBlock (int indexBlock, List<DiskAddress> addresses, List<TextBuffer> buffers,
int logicalBlock)
private int readIndexBlock (int indexBlock, List<DiskAddress> addresses,
List<TextBuffer> buffers, int logicalBlock)
// ---------------------------------------------------------------------------------//
{
byte[] indexBuffer = disk.readBlock (indexBlock);
@ -740,7 +741,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
else if (addresses.size () > 0)
{
byte[] tempBuffer = disk.readBlocks (addresses);
buffers.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
buffers
.add (new TextBuffer (tempBuffer, auxType, logicalBlock - addresses.size ()));
addresses.clear ();
}
logicalBlock++;
@ -811,13 +813,14 @@ class FileEntry extends CatalogEntry implements ProdosConstants
String locked = (access == 0x00) ? "*" : " ";
if (true)
return String.format ("%s %03d %s", ProdosConstants.fileTypes[fileType], blocksUsed, locked)
+ name;
return String.format ("%s %03d %s", ProdosConstants.fileTypes[fileType],
blocksUsed, locked) + name;
String timeC = created == null ? "" : created.format (ProdosDisk.df);
String timeF = modified == null ? "" : modified.format (ProdosDisk.df);
return String.format ("%s %s%-30s %3d %,10d %15s %15s", ProdosConstants.fileTypes[fileType],
locked, parentDirectory.name + "/" + name, blocksUsed, endOfFile, timeC, timeF);
return String.format ("%s %s%-30s %3d %,10d %15s %15s",
ProdosConstants.fileTypes[fileType], locked, parentDirectory.name + "/" + name,
blocksUsed, endOfFile, timeC, timeF);
}
}

View File

@ -40,8 +40,8 @@ public final class Utility
private static MathContext mathContext4 = new MathContext (6);
private static MathContext mathContext8 = new MathContext (15);
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv", "2mg",
"d13", "sdk", "shk", "bxy", "bny", "bqy", "woz", "img", "dimg");
private static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv",
"2mg", "d13", "sdk", "shk", "bxy", "bny", "bqy", "woz", "img", "dimg");
// ---------------------------------------------------------------------------------//
private Utility ()
@ -255,7 +255,8 @@ public final class Utility
}
catch (DateTimeException e)
{
System.out.printf ("Bad date/time: %d %d %d %d %d %n", year, month, day, hour, minute);
System.out.printf ("Bad date/time: %d %d %d %d %d %n", year, month, day, hour,
minute);
}
}
@ -315,7 +316,8 @@ public final class Utility
public static int readTriple (byte[] buffer, int ptr)
// ---------------------------------------------------------------------------------//
{
return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8 | (buffer[ptr + 2] & 0xFF) << 16;
return (buffer[ptr] & 0xFF) | (buffer[ptr + 1] & 0xFF) << 8
| (buffer[ptr + 2] & 0xFF) << 16;
}
// ---------------------------------------------------------------------------------//
@ -384,8 +386,8 @@ public final class Utility
if (exponent == 0)
return 0.0;
int mantissa =
(buffer[ptr + 2] & 0x7F) << 16 | (buffer[ptr + 1] & 0xFF) << 8 | (buffer[ptr] & 0xFF);
int mantissa = (buffer[ptr + 2] & 0x7F) << 16 | (buffer[ptr + 1] & 0xFF) << 8
| (buffer[ptr] & 0xFF);
boolean negative = (buffer[ptr + 2] & 0x80) != 0;
double value = 0.5;
@ -408,9 +410,10 @@ public final class Utility
if (exponent == 0)
return 0.0;
long mantissa = (long) (buffer[ptr + 6] & 0x7F) << 48 | (long) (buffer[ptr + 5] & 0xFF) << 40
| (long) (buffer[ptr + 4] & 0xFF) << 32 | (long) (buffer[ptr + 3] & 0xFF) << 24
| (buffer[ptr + 2] & 0xFF) << 16 | (buffer[ptr + 1] & 0xFF) << 8 | (buffer[ptr] & 0xFF);
long mantissa = (long) (buffer[ptr + 6] & 0x7F) << 48
| (long) (buffer[ptr + 5] & 0xFF) << 40 | (long) (buffer[ptr + 4] & 0xFF) << 32
| (long) (buffer[ptr + 3] & 0xFF) << 24 | (buffer[ptr + 2] & 0xFF) << 16
| (buffer[ptr + 1] & 0xFF) << 8 | (buffer[ptr] & 0xFF);
boolean negative = (buffer[ptr + 6] & 0x80) != 0;
double value = 0.5;
@ -519,10 +522,11 @@ public final class Utility
{
int[] val = new int[6];
for (int i = 0; i < 6; i++)
// val[i] = Integer.parseInt (String.format ("%02X", buffer[ptr + i] & 0xFF));
// val[i] = Integer.parseInt (String.format ("%02X", buffer[ptr + i] & 0xFF));
val[i] = buffer[ptr + i] & 0xFF;
LocalDateTime date = LocalDateTime.of (val[3] + 2000, val[5], val[4], val[2], val[1], val[0]);
LocalDateTime date =
LocalDateTime.of (val[3] + 2000, val[5], val[4], val[2], val[1], val[0]);
return date;
}
catch (DateTimeException e)
@ -565,6 +569,23 @@ public final class Utility
return suffixes.contains (getSuffix (filename));
}
// ---------------------------------------------------------------------------------//
public static String getShortPath (String path)
// ---------------------------------------------------------------------------------//
{
String home = System.getProperty ("user.home");
if (path.startsWith (home))
path = "~" + path.substring (home.length ());
else if (path.startsWith ("/Volumes/"))
{
int pos = path.indexOf (home);
if (pos > 0)
path = "~" + path.substring (home.length () + pos);
}
return path;
}
// ---------------------------------------------------------------------------------//
public static void reverse (byte[] buffer)
// ---------------------------------------------------------------------------------//
@ -613,7 +634,8 @@ public final class Utility
public static boolean isPossibleVariable (byte value)
// ---------------------------------------------------------------------------------//
{
return isDigit (value) || isLetter (value) || value == ASCII_DOLLAR || value == ASCII_PERCENT;
return isDigit (value) || isLetter (value) || value == ASCII_DOLLAR
|| value == ASCII_PERCENT;
}
// ---------------------------------------------------------------------------------//