This commit is contained in:
Denis Molony 2023-03-16 09:00:31 +10:00
parent 22dfaf65c6
commit 0af6714119
2 changed files with 37 additions and 17 deletions

View File

@ -21,7 +21,8 @@ public class NuFX
// -----------------------------------------------------------------------------------// // -----------------------------------------------------------------------------------//
{ {
private static final String UNDERLINE = private static final String UNDERLINE =
"------------------------------------------------------" + "-----------------------"; "------------------------------------------------------"
+ "-----------------------";
private MasterHeader masterHeader; private MasterHeader masterHeader;
private final byte[] buffer; private final byte[] buffer;
private final boolean debug = false; private final boolean debug = false;
@ -39,6 +40,7 @@ public class NuFX
{ {
buffer = Files.readAllBytes (path); buffer = Files.readAllBytes (path);
volumeName = new VolumeName (path.getFileName ().toString ()); volumeName = new VolumeName (path.getFileName ().toString ());
read (buffer); read (buffer);
} }
@ -94,6 +96,7 @@ public class NuFX
if (record.hasDisk ()) if (record.hasDisk ())
++totalDisks; ++totalDisks;
} }
System.out.println (toString ());
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -181,14 +184,14 @@ public class NuFX
} }
if (debug) if (debug)
System.out.printf ("%3d %-35s %02X %,7d %,7d %,7d %s %s%n", ++count, fileName, System.out.printf ("%3d %-35s %02X %,7d %,7d %,7d %s %s%n", ++count,
fileType, auxType, eof, buffer.length, created, modified); fileName, fileType, auxType, eof, buffer.length, created, modified);
FileEntry fileEntry; FileEntry fileEntry;
try try
{ {
fileEntry = fileEntry = disk.addFile (fileName, fileType, auxType, created, modified,
disk.addFile (fileName, fileType, auxType, created, modified, buffer, eof); buffer, eof);
} }
catch (FileAlreadyExistsException e) catch (FileAlreadyExistsException e)
{ {
@ -266,8 +269,8 @@ public class NuFX
volumeName.volumeName, masterHeader.getCreated2 (), masterHeader.getModified2 (), volumeName.volumeName, masterHeader.getCreated2 (), masterHeader.getModified2 (),
masterHeader.getTotalRecords ())); masterHeader.getTotalRecords ()));
text.append ( text.append (" Name Type Auxtyp Archived"
" Name Type Auxtyp Archived" + " Fmat Size Un-Length\n"); + " Fmat Size Un-Length\n");
text.append (String.format ("%s%n", UNDERLINE)); 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 final byte[] NuFX = { 0x4E, (byte) 0xF5, 0x46, (byte) 0xD8 };
private static String[] fileSystems = private static String[] fileSystems = { "", "ProDOS/SOS", "DOS 3.3", "DOS 3.2",
{ "", "ProDOS/SOS", "DOS 3.3", "DOS 3.2", "Apple II Pascal", "Macintosh HFS", "Apple II Pascal", "Macintosh HFS", "Macintosh MFS", "Lisa File System",
"Macintosh MFS", "Lisa File System", "Apple CP/M", "", "MS-DOS", "High Sierra", "Apple CP/M", "", "MS-DOS", "High Sierra", "ISO 9660", "AppleShare" };
"ISO 9660", "AppleShare" };
private static String[] storage = { "", "Seedling", "Sapling", "Tree", "", "Extended", private static String[] storage = { "", "Seedling", "Sapling", "Tree", "", "Extended",
"", "", "", "", "", "", "", "Subdirectory" }; "", "", "", "", "", "", "", "Subdirectory" };
private static String[] accessChars = { "D", "R", "B", "", "", "I", "W", "R" }; private static String[] accessChars = { "D", "R", "B", "", "", "I", "W", "R" };
private static String threadFormats[] = { "unc", "sq ", "lz1", "lz2", "", "" }; private static String threadFormats[] = { "unc", "sq ", "lz1", "lz2", "", "" };
@ -254,6 +253,13 @@ class Record
return 0; return 0;
} }
// ---------------------------------------------------------------------------------//
String getThreadFormatText ()
// ---------------------------------------------------------------------------------//
{
return threadFormats[getThreadFormat ()];
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
int getUncompressedSize () int getUncompressedSize ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -283,6 +289,17 @@ class Record
return size; return size;
} }
// ---------------------------------------------------------------------------------//
public float getCompressedPct ()
// ---------------------------------------------------------------------------------//
{
float pct = 100;
if (getUncompressedSize () > 0)
pct = getCompressedSize () * 100 / getUncompressedSize ();
return pct;
}
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
byte[] getData () byte[] getData ()
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//
@ -313,9 +330,9 @@ class Record
if (name.length () > 27) if (name.length () > 27)
name = ".." + name.substring (name.length () - 25); name = ".." + name.substring (name.length () - 25);
float pct = 100; // float pct = 100;
if (getUncompressedSize () > 0) // if (getUncompressedSize () > 0)
pct = getCompressedSize () * 100 / getUncompressedSize (); // pct = getCompressedSize () * 100 / getUncompressedSize ();
String lockedFlag = (access | 0xC3) == 1 ? "+" : " "; String lockedFlag = (access | 0xC3) == 1 ? "+" : " ";
String forkedFlag = hasResource () ? "+" : " "; String forkedFlag = hasResource () ? "+" : " ";
@ -323,11 +340,11 @@ class Record
if (hasDisk ()) if (hasDisk ())
return String.format ("%s%-27.27s %-4s %-6s %-15s %s %3.0f%% %7d", lockedFlag, return String.format ("%s%-27.27s %-4s %-6s %-15s %s %3.0f%% %7d", lockedFlag,
name, "Disk", (getUncompressedSize () / 1024) + "k", archived.format2 (), 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, return String.format ("%s%-27.27s %s%s $%04X %-15s %s %3.0f%% %7d", lockedFlag,
name, fileTypes[fileType], forkedFlag, auxType, archived.format2 (), name, fileTypes[fileType], forkedFlag, auxType, archived.format2 (),
threadFormats[getThreadFormat ()], pct, getUncompressedSize ()); getThreadFormatText (), getCompressedPct (), getUncompressedSize ());
} }
// ---------------------------------------------------------------------------------// // ---------------------------------------------------------------------------------//