display nufx disks correctly

This commit is contained in:
Denis Molony 2021-05-08 19:56:57 +10:00
parent 269a1bbd83
commit c6443ff89e
5 changed files with 53 additions and 27 deletions

View File

@ -139,7 +139,7 @@ public class DiskFactory
}
if ("sdk".equals (suffix) || "shk".equals (suffix) // shrinkit disk/file archive
|| "bxy".equals (suffix))
|| "bxy".equals (suffix) || "bny".equals (suffix))
{
if (debug)
System.out.println (" ** sdk/shk/bxy **");

View File

@ -1,5 +1,7 @@
package com.bytezone.diskbrowser.utilities;
import static com.bytezone.diskbrowser.prodos.ProdosConstants.BLOCK_SIZE;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@ -22,7 +24,7 @@ public class NuFX
+ "-----------------------";
private MasterHeader masterHeader;
private final byte[] buffer;
private final boolean debug = false;
private final boolean debug = true;
private final List<Record> records = new ArrayList<> ();
private int totalFiles;
@ -78,25 +80,26 @@ public class NuFX
if (record.hasDisk ())
++totalDisks;
}
listFiles ();
}
// ---------------------------------------------------------------------------------//
private void calculateTotalBlocks ()
private void calculateTotalBlocks () // not exact
// ---------------------------------------------------------------------------------//
{
totalBlocks = 0;
for (Record record : records)
if (record.hasFile ())
if (record.hasFile () || record.hasResource ())
{
// note: total blocks does not include subdirectory blocks
int blocks = (record.getUncompressedSize () - 1) / 512 + 1;
int blocks = (record.getUncompressedSize () - 1) / BLOCK_SIZE + 1;
if (blocks == 1) // seedling
totalBlocks += blocks;
else if (blocks <= 256) // sapling
else if (blocks <= 0x100) // sapling
totalBlocks += blocks + 1;
else // tree
totalBlocks += blocks + (blocks / 256) + 2;
totalBlocks += blocks + (blocks / 0x100) + 2;
}
}
@ -231,7 +234,7 @@ public class NuFX
{
if (record.hasFile ())
{
System.out.printf ("%3d %-35s %,7d %d %,7d%n", count, record.getFileName (),
System.out.printf ("%3d %-35s %,7d %02X %,7d%n", count, record.getFileName (),
record.getFileSize (), record.getFileType (), record.getUncompressedSize ());
}
count++;
@ -245,7 +248,7 @@ public class NuFX
{
StringBuilder text = new StringBuilder ();
text.append (String.format (" %s Created:%s Mod:%s Recs:%5d%n%n",
text.append (String.format (" %-15.15s Created:%-17s Mod:%-17s Recs:%5d%n%n",
volumeName.getFileName (), masterHeader.getCreated2 (),
masterHeader.getModified2 (), masterHeader.getTotalRecords ()));
@ -259,9 +262,16 @@ public class NuFX
for (Record record : records)
{
text.append (String.format ("%s%n", record.getLine ()));
totalUncompressedSize += record.getUncompressedSize ();
totalCompressedSize += record.getCompressedSize ();
// if (record.hasDisk ())
// {
//
// }
// else
{
text.append (String.format ("%s%n", record.getLine ()));
totalUncompressedSize += record.getUncompressedSize ();
totalCompressedSize += record.getCompressedSize ();
}
}
text.append (String.format ("%s%n", UNDERLINE));

View File

@ -233,6 +233,7 @@ class Record
return fileSystems[fileSystemID];
}
// Called by NuFX.listFiles()
// ---------------------------------------------------------------------------------//
int getFileSize ()
// ---------------------------------------------------------------------------------//
@ -249,7 +250,7 @@ class Record
// ---------------------------------------------------------------------------------//
{
for (Thread thread : threads)
if (thread.hasFile ())
if (thread.hasFile () || thread.hasDisk ())
return thread.threadFormat;
return 0;
@ -259,10 +260,13 @@ class Record
int getUncompressedSize ()
// ---------------------------------------------------------------------------------//
{
if (hasDisk ())
return auxType * storType;
int size = 0;
for (Thread thread : threads)
if (thread.hasFile () || thread.hasResource ())
if (thread.hasFile () || thread.hasResource () || thread.hasDisk ())
size += thread.getUncompressedEOF ();
return size;
@ -275,7 +279,7 @@ class Record
int size = 0;
for (Thread thread : threads)
if (thread.hasFile () || thread.hasResource ())
if (thread.hasFile () || thread.hasResource () || thread.hasDisk ())
size += thread.getCompressedEOF ();
return size;
@ -307,15 +311,22 @@ class Record
String getLine ()
// ---------------------------------------------------------------------------------//
{
float pct = 0;
if (getUncompressedSize () > 0)
pct = getCompressedSize () * 100 / getUncompressedSize ();
String lockedFlag = (access | 0xC3) == 1 ? "+" : " ";
String forkedFlag = hasResource () ? "+" : " ";
String name = getFileName ();
if (name.length () > 27)
name = ".." + name.substring (name.length () - 25);
float pct = 100;
if (getUncompressedSize () > 0)
pct = getCompressedSize () * 100 / getUncompressedSize ();
String lockedFlag = (access | 0xC3) == 1 ? "+" : " ";
String forkedFlag = hasResource () ? "+" : " ";
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 ());
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 ());

View File

@ -14,6 +14,10 @@ class Thread
{ "data fork", "disk image", "resource fork" },
{ "filename", "undefined", "undefined" } };
private static final int DATA_FORK = 0;
private static final int DISK_IMAGE = 1;
private static final int RESOURCEFORK = 2;
final int threadClass;
final int threadFormat;
final int threadKind;
@ -96,13 +100,13 @@ class Thread
case 2:
switch (threadKind)
{
case 0: // data fork of file
case DATA_FORK:
hasFile = true;
break;
case 1: // disk image
case DISK_IMAGE:
hasDisk = true;
break;
case 2: // resource fork of file
case RESOURCEFORK:
hasResource = true;
break;
}
@ -195,13 +199,14 @@ class Thread
return fileName;
}
// Called by Record.getFileSize()
// ---------------------------------------------------------------------------------//
int getFileSize ()
// ---------------------------------------------------------------------------------//
{
if (lzw != null)
System.out.printf ("%04X v %04X v %04X%n", compressedEOF, uncompressedEOF,
lzw.getSize ());
// if (lzw != null)
// System.out.printf ("%04X v %04X v %04X%n", compressedEOF, uncompressedEOF,
// lzw.getSize ());
return lzw != null ? lzw.getSize () : uncompressedEOF;
// return uncompressedEOF;
}

View File

@ -34,7 +34,7 @@ public class Utility
public static final byte ASCII_CARET = 0x5E;
public static final List<String> suffixes = Arrays.asList ("po", "dsk", "do", "hdv",
"2mg", "v2d", "d13", "sdk", "shk", "bxy", "woz", "img", "dimg");
"2mg", "v2d", "d13", "sdk", "shk", "bxy", "bny", "woz", "img", "dimg");
// ---------------------------------------------------------------------------------//
public static boolean test (Graphics2D g)