mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2025-01-04 20:30:10 +00:00
removed GregorianCalendar
This commit is contained in:
parent
1b9e9d47ac
commit
1b86b31233
@ -1,5 +1,6 @@
|
||||
package com.bytezone.diskbrowser.pascal;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
@ -23,6 +24,7 @@ abstract class CatalogEntry implements AppleFileSource
|
||||
protected int lastBlock; // block AFTER last used block
|
||||
protected int fileType;
|
||||
protected GregorianCalendar date;
|
||||
protected LocalDate localDate;
|
||||
protected int bytesUsedInLastBlock;
|
||||
protected final List<DiskAddress> blocks = new ArrayList<> ();
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class FileEntry extends CatalogEntry
|
||||
super (parent, buffer);
|
||||
|
||||
bytesUsedInLastBlock = Utility.getShort (buffer, 22);
|
||||
date = Utility.getPascalDate (buffer, 24);
|
||||
localDate = Utility.getPascalLocalDate (buffer, 24);
|
||||
|
||||
int max = Math.min (lastBlock, parent.getDisk ().getTotalBlocks ());
|
||||
for (int i = firstBlock; i < max; i++)
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.bytezone.diskbrowser.pascal;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.List;
|
||||
|
||||
import com.bytezone.diskbrowser.disk.AbstractSector;
|
||||
@ -14,7 +15,8 @@ import com.bytezone.diskbrowser.utilities.Utility;
|
||||
class PascalCatalogSector extends AbstractSector
|
||||
// -----------------------------------------------------------------------------------//
|
||||
{
|
||||
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||
// private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
|
||||
private static String[] fileTypes =
|
||||
{ "Volume", "Bad", "Code", "Text", "Info", "Data", "Graf", "Foto", "SecureDir" };
|
||||
|
||||
@ -44,8 +46,9 @@ class PascalCatalogSector extends AbstractSector
|
||||
addTextAndDecimal (text, buffer, 16, 2, "Files on disk");
|
||||
addTextAndDecimal (text, buffer, 18, 2, "First block of volume");
|
||||
|
||||
GregorianCalendar calendar = Utility.getPascalDate (buffer, 20);
|
||||
String date = calendar == null ? "--" : df.format (calendar.getTime ());
|
||||
LocalDate localDate = Utility.getPascalLocalDate (buffer, 20);
|
||||
String date = localDate == null ? "--" : localDate.format (dtf);
|
||||
|
||||
addText (text, buffer, 20, 2, "Most recent date setting : " + date);
|
||||
addTextAndDecimal (text, buffer, 22, 4, "Reserved");
|
||||
|
||||
@ -71,8 +74,8 @@ class PascalCatalogSector extends AbstractSector
|
||||
addText (text, buffer, ptr + 18, 4, "File name : " + name);
|
||||
addTextAndDecimal (text, buffer, ptr + 22, 2, "Bytes in file's last block");
|
||||
|
||||
calendar = Utility.getPascalDate (buffer, ptr + 24);
|
||||
date = calendar == null ? "--" : df.format (calendar.getTime ());
|
||||
localDate = Utility.getPascalLocalDate (buffer, ptr + 24);
|
||||
date = localDate == null ? "--" : localDate.format (dtf);
|
||||
addText (text, buffer, ptr + 24, 2, "Date : " + date);
|
||||
|
||||
ptr += PascalDisk.CATALOG_ENTRY_SIZE;
|
||||
|
@ -2,8 +2,10 @@ package com.bytezone.diskbrowser.pascal;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.text.DateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
@ -29,6 +31,7 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
{
|
||||
static final int CATALOG_ENTRY_SIZE = 26;
|
||||
private final DateFormat df = DateFormat.getDateInstance (DateFormat.SHORT);
|
||||
private final DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT);
|
||||
private final VolumeEntry volumeEntry;
|
||||
private final PascalCatalogSector diskCatalogSector;
|
||||
|
||||
@ -232,8 +235,10 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
}
|
||||
|
||||
int lastByte = Utility.getShort (buffer, ptr + 22);
|
||||
GregorianCalendar date = Utility.getPascalDate (buffer, 24);
|
||||
String dateString = date == null ? "" : date.toString ();
|
||||
// GregorianCalendar date = Utility.getPascalDate (buffer, 24);
|
||||
LocalDate localDate = Utility.getPascalLocalDate (buffer, 24);
|
||||
String dateString = localDate == null ? ""
|
||||
: localDate.format (DateTimeFormatter.ofLocalizedDate (FormatStyle.SHORT));
|
||||
if (debug)
|
||||
System.out.printf ("%4d %4d %d %-15s %d %s%n", firstBlock, lastBlock, kind,
|
||||
new String (buffer, ptr + 7, nameLength), lastByte, dateString);
|
||||
@ -297,7 +302,9 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
String newLine2 = newLine + newLine;
|
||||
String line =
|
||||
"---- --------------- ---- -------- ------- ---- ---- ----" + newLine;
|
||||
String date = volumeEntry.date == null ? "--" : df.format (volumeEntry.date.getTime ());
|
||||
|
||||
String date = volumeEntry.localDate == null ? "--" : volumeEntry.localDate.format (dtf);
|
||||
|
||||
StringBuilder text = new StringBuilder ();
|
||||
text.append ("File : " + getDisplayPath () + newLine2);
|
||||
text.append ("Volume : " + volumeEntry.name + newLine);
|
||||
@ -311,16 +318,20 @@ public class PascalDisk extends AbstractFormattedDisk
|
||||
FileEntry ce = (FileEntry) fe;
|
||||
int size = ce.lastBlock - ce.firstBlock;
|
||||
usedBlocks += size;
|
||||
date = ce.date == null ? "--" : df.format (ce.date.getTime ());
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
text.append (line);
|
||||
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);
|
||||
}
|
||||
}
|
@ -17,9 +17,9 @@ class VolumeEntry extends CatalogEntry
|
||||
{
|
||||
super (parent, buffer);
|
||||
|
||||
totalBlocks = Utility.getShort (buffer, 14); // 280
|
||||
totalBlocks = Utility.getShort (buffer, 14); // 280
|
||||
totalFiles = Utility.getShort (buffer, 16);
|
||||
date = Utility.getPascalDate (buffer, 20); // 2 bytes
|
||||
localDate = Utility.getPascalLocalDate (buffer, 20); // 2 bytes
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
@ -9,9 +9,9 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.time.DateTimeException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.Checksum;
|
||||
@ -230,7 +230,6 @@ public final class Utility
|
||||
public static LocalDateTime getAppleDate (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
// int yymmdd = readShort (buffer, offset);
|
||||
int yymmdd = getShort (buffer, offset);
|
||||
if (yymmdd != 0)
|
||||
{
|
||||
@ -429,7 +428,7 @@ public final class Utility
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
public static GregorianCalendar getPascalDate (byte[] buffer, int offset)
|
||||
public static LocalDate getPascalLocalDate (byte[] buffer, int offset)
|
||||
// ---------------------------------------------------------------------------------//
|
||||
{
|
||||
int date = Utility.getShort (buffer, offset);
|
||||
@ -446,7 +445,7 @@ public final class Utility
|
||||
else
|
||||
year += 1900;
|
||||
|
||||
return new GregorianCalendar (year, month - 1, day);
|
||||
return LocalDate.of (year, month, day);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------//
|
||||
|
Loading…
Reference in New Issue
Block a user