tidying
This commit is contained in:
parent
489f7b1791
commit
39bdb3d00a
|
@ -4,7 +4,6 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.common.ComputeCRC32;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
|
@ -35,7 +34,7 @@ public class DiskDetails
|
|||
this.size = file.length ();
|
||||
|
||||
if (doChecksum)
|
||||
checksum = ComputeCRC32.getChecksumValue (file);
|
||||
checksum = Utility.getChecksumValue (file);
|
||||
else
|
||||
checksum = 0;
|
||||
}
|
||||
|
@ -136,7 +135,7 @@ public class DiskDetails
|
|||
public long calculateChecksum ()
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
checksum = ComputeCRC32.getChecksumValue (file);
|
||||
checksum = Utility.getChecksumValue (file);
|
||||
return checksum;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,16 @@ package com.bytezone.diskbrowser.utilities;
|
|||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.DateTimeException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
public class Utility
|
||||
|
@ -239,6 +245,30 @@ public class Utility
|
|||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static long getChecksumValue (File file)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
Checksum checksum = new CRC32 ();
|
||||
try
|
||||
{
|
||||
BufferedInputStream is =
|
||||
new BufferedInputStream (new FileInputStream (file.getAbsolutePath ()));
|
||||
byte[] bytes = new byte[1024];
|
||||
int len = 0;
|
||||
|
||||
while ((len = is.read (bytes)) >= 0)
|
||||
checksum.update (bytes, 0, len);
|
||||
|
||||
is.close ();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace ();
|
||||
}
|
||||
return checksum.getValue ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static int crc32 (byte[] buffer, int offset, int length)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
|
|
@ -8,9 +8,9 @@ import java.awt.image.BufferedImage;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.common.Utility;
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class MazeGridV5 extends AbstractFile
|
||||
|
@ -137,7 +137,7 @@ class MazeGridV5 extends AbstractFile
|
|||
offset = 0x320;
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
text.append (Utility.toHex (buffer, offset + i * 10, 10));
|
||||
text.append (HexFormatter.format (buffer, offset + i * 10, 10));
|
||||
text.append ("\n");
|
||||
}
|
||||
text.append ("\n");
|
||||
|
@ -145,7 +145,7 @@ class MazeGridV5 extends AbstractFile
|
|||
offset = 0x400;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
text.append (Utility.toHex (buffer, offset + i * 64, 64));
|
||||
text.append (HexFormatter.format (buffer, offset + i * 64, 64));
|
||||
text.append ("\n\n");
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ class MazeGridV5 extends AbstractFile
|
|||
offset = 0x5F0;
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
text.append (Utility.toHex (buffer, offset + i * 64, 64));
|
||||
text.append (HexFormatter.format (buffer, offset + i * 64, 64));
|
||||
text.append ("\n\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.common.Utility;
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class MessageBlock extends AbstractFile implements Iterable<MessageDataBlock>
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.bytezone.diskbrowser.wizardry;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.common.Utility;
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class MessageDataBlock extends AbstractFile
|
||||
|
@ -176,7 +176,7 @@ class MessageDataBlock extends AbstractFile
|
|||
{
|
||||
StringBuilder text = new StringBuilder ();
|
||||
|
||||
String data = Utility.getHex (buffer, offset, length);
|
||||
String data = HexFormatter.format (buffer, offset, length);
|
||||
text.append (String.format ("%5d: %03X %02X : %s", msgNo, offset, length, data));
|
||||
|
||||
return text.toString ();
|
||||
|
|
|
@ -4,9 +4,9 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.common.Utility;
|
||||
import com.bytezone.diskbrowser.applefile.AbstractFile;
|
||||
import com.bytezone.diskbrowser.utilities.HexFormatter;
|
||||
import com.bytezone.diskbrowser.utilities.Utility;
|
||||
|
||||
// -----------------------------------------------------------------------------------//
|
||||
class Wiz5Monsters extends AbstractFile implements Iterable<Wiz5Monsters.Monster>
|
||||
|
|
Loading…
Reference in New Issue