mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-08-08 10:25:04 +00:00
findbugs
This commit is contained in:
@@ -166,7 +166,9 @@ public class AppleDisk implements Disk
|
||||
{
|
||||
BufferedInputStream file = new BufferedInputStream (new FileInputStream (path));
|
||||
if (skip > 0)
|
||||
file.skip (skip);
|
||||
{
|
||||
long result = file.skip (skip);
|
||||
}
|
||||
file.read (diskBuffer);
|
||||
file.close ();
|
||||
}
|
||||
|
@@ -30,36 +30,33 @@ public class AppleDiskAddress implements DiskAddress
|
||||
return String.format ("[Block=%3d, Track=%2d, Sector=%2d]", block, track, sector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo (DiskAddress that)
|
||||
{
|
||||
return this.block - that.getBlock ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlock ()
|
||||
{
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSector ()
|
||||
{
|
||||
return sector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTrack ()
|
||||
{
|
||||
return track;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Disk getDisk ()
|
||||
{
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object other)
|
||||
{
|
||||
if (other == null || getClass () != other.getClass ())
|
||||
return false;
|
||||
return this.block == ((AppleDiskAddress) other).block;
|
||||
}
|
||||
}
|
@@ -278,16 +278,20 @@ class DataPanel extends JTabbedPane
|
||||
private void setImage (BufferedImage image)
|
||||
{
|
||||
this.image = image;
|
||||
int width, height;
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
Graphics2D g2 = image.createGraphics ();
|
||||
g2.setRenderingHint (RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
width = image.getWidth ();
|
||||
height = image.getHeight ();
|
||||
}
|
||||
else
|
||||
{
|
||||
width = height = 0;
|
||||
}
|
||||
|
||||
int width = image.getWidth ();
|
||||
int height = image.getHeight ();
|
||||
|
||||
if (width < 400)
|
||||
scale = (400 - 1) / width + 1;
|
||||
|
@@ -295,7 +295,7 @@ public class TreeBuilder
|
||||
|
||||
File[] files = file.listFiles ();
|
||||
if (files != null)
|
||||
for (File f : file.listFiles ())
|
||||
for (File f : files)
|
||||
{
|
||||
String name = f.getName ();
|
||||
if (name.startsWith ("."))
|
||||
|
@@ -9,9 +9,9 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
class PascalCatalogSector extends AbstractSector
|
||||
{
|
||||
private static DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||
private static String[] fileTypes = { "Volume", "Bad", "Code", "Text", "Info", "Data", "Graf",
|
||||
"Foto", "SecureDir" };
|
||||
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||
private static String[] fileTypes =
|
||||
{ "Volume", "Bad", "Code", "Text", "Info", "Data", "Graf", "Foto", "SecureDir" };
|
||||
|
||||
public PascalCatalogSector (Disk disk, byte[] buffer)
|
||||
{
|
||||
|
@@ -18,7 +18,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
public class PascalDisk extends AbstractFormattedDisk
|
||||
{
|
||||
static final int CATALOG_ENTRY_SIZE = 26;
|
||||
private static DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||
private final VolumeEntry volume;
|
||||
private final PascalCatalogSector diskCatalogSector;
|
||||
|
||||
|
@@ -12,7 +12,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
abstract class CatalogEntry implements AppleFileSource
|
||||
{
|
||||
FormattedDisk parentDisk;
|
||||
ProdosDisk parentDisk;
|
||||
DirectoryHeader parentDirectory;
|
||||
String name;
|
||||
int storageType;
|
||||
|
@@ -164,7 +164,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
|
||||
private void traverseIndex (int keyBlock)
|
||||
{
|
||||
parentDisk.setSectorType (keyBlock, ((ProdosDisk) parentDisk).indexSector);
|
||||
parentDisk.setSectorType (keyBlock, parentDisk.indexSector);
|
||||
indexBlocks.add (disk.getDiskAddress (keyBlock));
|
||||
byte[] buffer = disk.readSector (keyBlock);
|
||||
for (int i = 0; i < 256; i++)
|
||||
@@ -183,7 +183,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
// break;
|
||||
if (block != 0)
|
||||
{
|
||||
parentDisk.setSectorType (block, ((ProdosDisk) parentDisk).dataSector);
|
||||
parentDisk.setSectorType (block, parentDisk.dataSector);
|
||||
dataBlocks.add (disk.getDiskAddress (block));
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
|
||||
private void traverseGEOSIndex (int keyPtr)
|
||||
{
|
||||
parentDisk.setSectorType (keyPtr, ((ProdosDisk) parentDisk).indexSector);
|
||||
parentDisk.setSectorType (keyPtr, parentDisk.indexSector);
|
||||
indexBlocks.add (disk.getDiskAddress (keyPtr));
|
||||
byte[] buffer = disk.readSector (keyPtr);
|
||||
// int length = HexFormatter.intValue (buffer[0xFF], buffer[0x1FF]);
|
||||
@@ -217,7 +217,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
break;
|
||||
if (block == 0xFFFF)
|
||||
continue;
|
||||
parentDisk.setSectorType (block, ((ProdosDisk) parentDisk).dataSector);
|
||||
parentDisk.setSectorType (block, parentDisk.dataSector);
|
||||
dataBlocks.add (disk.getDiskAddress (block));
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
file = new IntegerBasicProgram (name, exactBuffer);
|
||||
break;
|
||||
case FILE_TYPE_DIRECTORY:
|
||||
VolumeDirectoryHeader vdh = ((ProdosDisk) parentDisk).vdh;
|
||||
VolumeDirectoryHeader vdh = parentDisk.vdh;
|
||||
file = new ProdosDirectory (parentDisk, name, buffer, vdh.totalBlocks,
|
||||
vdh.freeBlocks, vdh.usedBlocks);
|
||||
break;
|
||||
@@ -561,8 +561,8 @@ class FileEntry extends CatalogEntry implements ProdosConstants
|
||||
return String.format ("%s %03d %s", ProdosConstants.fileTypes[fileType],
|
||||
blocksUsed, locked)
|
||||
+ name;
|
||||
String timeC = created == null ? "" : ProdosDisk.df.format (created.getTime ());
|
||||
String timeF = modified == null ? "" : ProdosDisk.df.format (modified.getTime ());
|
||||
String timeC = created == null ? "" : parentDisk.df.format (created.getTime ());
|
||||
String timeF = modified == null ? "" : parentDisk.df.format (modified.getTime ());
|
||||
return String.format ("%s %s%-30s %3d %,10d %15s %15s",
|
||||
ProdosConstants.fileTypes[fileType], locked,
|
||||
parentDirectory.name + "/" + name, blocksUsed, endOfFile, timeC,
|
||||
|
@@ -81,7 +81,8 @@ class ProdosCatalogSector extends AbstractSector
|
||||
addTextAndDecimal (text, buffer, offset + 19, 2, "Blocks used");
|
||||
addTextAndDecimal (text, buffer, offset + 21, 3, "EOF");
|
||||
GregorianCalendar created = HexFormatter.getAppleDate (buffer, offset + 24);
|
||||
String dateC = created == null ? "" : ProdosDisk.df.format (created.getTime ());
|
||||
String dateC =
|
||||
created == null ? "" : ((ProdosDisk) disk).df.format (created.getTime ());
|
||||
addText (text, buffer, offset + 24, 4, "Creation date : " + dateC);
|
||||
addTextAndDecimal (text, buffer, offset + 28, 1, "Version");
|
||||
addText (text, buffer, offset + 29, 1, "Minimum version");
|
||||
@@ -89,7 +90,8 @@ class ProdosCatalogSector extends AbstractSector
|
||||
addTextAndDecimal (text, buffer, offset + 31, 2,
|
||||
"Auxilliary type - " + getAuxilliaryText (fileType));
|
||||
GregorianCalendar modified = HexFormatter.getAppleDate (buffer, offset + 33);
|
||||
String dateM = modified == null ? "" : ProdosDisk.df.format (modified.getTime ());
|
||||
String dateM =
|
||||
modified == null ? "" : ((ProdosDisk) disk).df.format (modified.getTime ());
|
||||
addText (text, buffer, offset + 33, 4, "Modification date : " + dateM);
|
||||
addTextAndDecimal (text, buffer, offset + 37, 2, "Header pointer");
|
||||
return text.toString ();
|
||||
@@ -122,7 +124,8 @@ class ProdosCatalogSector extends AbstractSector
|
||||
StringBuilder text = new StringBuilder ();
|
||||
addText (text, buffer, offset + 20, 4, "Not used");
|
||||
GregorianCalendar created = HexFormatter.getAppleDate (buffer, offset + 24);
|
||||
String dateC = created == null ? "" : ProdosDisk.df.format (created.getTime ());
|
||||
String dateC =
|
||||
created == null ? "" : ((ProdosDisk) disk).df.format (created.getTime ());
|
||||
addText (text, buffer, offset + 24, 4, "Creation date : " + dateC);
|
||||
addText (text, buffer, offset + 28, 1, "Prodos version");
|
||||
addText (text, buffer, offset + 29, 1, "Minimum version");
|
||||
|
@@ -12,7 +12,7 @@ class ProdosDirectory extends AbstractFile
|
||||
private static final String newLine = String.format ("%n");
|
||||
private static final String newLine2 = newLine + newLine;
|
||||
|
||||
private final FormattedDisk parentFD;
|
||||
private final ProdosDisk parentFD;
|
||||
private final int totalBlocks;
|
||||
private final int freeBlocks;
|
||||
private final int usedBlocks;
|
||||
@@ -22,7 +22,7 @@ class ProdosDirectory extends AbstractFile
|
||||
{
|
||||
super (name, buffer);
|
||||
|
||||
this.parentFD = parent;
|
||||
this.parentFD = (ProdosDisk) parent;
|
||||
this.totalBlocks = totalBlocks;
|
||||
this.freeBlocks = freeBlocks;
|
||||
this.usedBlocks = usedBlocks;
|
||||
@@ -65,14 +65,13 @@ class ProdosDirectory extends AbstractFile
|
||||
|
||||
GregorianCalendar created = HexFormatter.getAppleDate (buffer, i + 24);
|
||||
String dateC = created == null ? NO_DATE
|
||||
: ProdosDisk.sdf.format (created.getTime ()).toUpperCase ();
|
||||
String timeC =
|
||||
created == null ? "" : ProdosDisk.stf.format (created.getTime ());
|
||||
: parentFD.sdf.format (created.getTime ()).toUpperCase ();
|
||||
String timeC = created == null ? "" : parentFD.stf.format (created.getTime ());
|
||||
GregorianCalendar modified = HexFormatter.getAppleDate (buffer, i + 33);
|
||||
String dateM = modified == null ? NO_DATE
|
||||
: ProdosDisk.sdf.format (modified.getTime ()).toUpperCase ();
|
||||
: parentFD.sdf.format (modified.getTime ()).toUpperCase ();
|
||||
String timeM =
|
||||
modified == null ? "" : ProdosDisk.stf.format (modified.getTime ());
|
||||
modified == null ? "" : parentFD.stf.format (modified.getTime ());
|
||||
int eof =
|
||||
HexFormatter.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
|
||||
int fileType = HexFormatter.intValue (buffer[i + 16]);
|
||||
|
@@ -16,9 +16,9 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
public class ProdosDisk extends AbstractFormattedDisk
|
||||
{
|
||||
protected static final DateFormat df = DateFormat.getInstance ();
|
||||
protected static final SimpleDateFormat sdf = new SimpleDateFormat ("d-MMM-yy");
|
||||
protected static final SimpleDateFormat stf = new SimpleDateFormat ("H:mm");
|
||||
protected final DateFormat df = DateFormat.getInstance ();
|
||||
protected final SimpleDateFormat sdf = new SimpleDateFormat ("d-MMM-yy");
|
||||
protected final SimpleDateFormat stf = new SimpleDateFormat ("H:mm");
|
||||
|
||||
final SectorType dosSector = new SectorType ("Bootstrap Loader", Color.lightGray);
|
||||
final SectorType catalogSector = new SectorType ("Catalog", new Color (0, 200, 0));
|
||||
|
@@ -27,7 +27,7 @@ class SubDirectoryHeader extends DirectoryHeader
|
||||
{
|
||||
String locked = (access == 0x01) ? "*" : " ";
|
||||
return String.format (" %s%-40s %15s", locked, "/" + name,
|
||||
ProdosDisk.df.format (created.getTime ()));
|
||||
parentDisk.df.format (created.getTime ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -121,7 +121,7 @@ class VolumeDirectoryHeader extends DirectoryHeader
|
||||
if (false)
|
||||
{
|
||||
String locked = (access == 0x01) ? "*" : " ";
|
||||
String timeC = created == null ? "" : ProdosDisk.df.format (created.getTime ());
|
||||
String timeC = created == null ? "" : parentDisk.df.format (created.getTime ());
|
||||
return String.format (" %s%-42s %15s", locked, "/" + name, timeC);
|
||||
}
|
||||
return name;
|
||||
|
Reference in New Issue
Block a user