Fixed Pascal bug with invalid dates

This commit is contained in:
Denis Molony 2022-07-29 23:00:30 +10:00
parent 036e47b9b1
commit 37c489f252
3 changed files with 26 additions and 24 deletions

View File

@ -17,8 +17,7 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
{
static final DateTimeFormatter df = DateTimeFormatter.ofPattern ("d-LLL-yy");
static final DateTimeFormatter tf = DateTimeFormatter.ofPattern ("H:mm");
static final String UNDERLINE =
"----------------------------------------------------\n";
static final String UNDERLINE = "----------------------------------------------------\n";
private static final String NO_DATE = "<NO DATE>";
@ -28,8 +27,8 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
private final int usedBlocks;
// ---------------------------------------------------------------------------------//
public ProdosDirectory (FormattedDisk parent, String name, byte[] buffer,
int totalBlocks, int freeBlocks, int usedBlocks)
public ProdosDirectory (FormattedDisk parent, String name, byte[] buffer, int totalBlocks,
int freeBlocks, int usedBlocks)
// ---------------------------------------------------------------------------------//
{
super (name, buffer);
@ -86,7 +85,6 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
int nameLength = buffer[i] & 0x0F;
String filename = HexFormatter.getString (buffer, i + 1, nameLength);
String subType = "";
String locked;
switch (storageType)
{
@ -111,22 +109,20 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
LocalDateTime createdDate = Utility.getAppleDate (buffer, i + 24);
LocalDateTime modifiedDate = Utility.getAppleDate (buffer, i + 33);
String dateC =
createdDate == null ? NO_DATE : createdDate.format (df).toUpperCase ();
String dateM =
modifiedDate == null ? NO_DATE : modifiedDate.format (df).toUpperCase ();
String dateC = createdDate == null ? NO_DATE : createdDate.format (df).toUpperCase ();
String dateM = modifiedDate == null ? NO_DATE : modifiedDate.format (df).toUpperCase ();
String timeC = createdDate == null ? "" : createdDate.format (tf);
String timeM = modifiedDate == null ? "" : modifiedDate.format (tf);
int eof = Utility.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
int fileType = buffer[i + 16] & 0xFF;
locked = (buffer[i + 30] & 0xE0) == 0xE0 ? " " : "*";
String locked = (buffer[i + 30] & 0xE0) == 0xE0 ? " " : "*";
int aux = Utility.getShort (buffer, i + 31);
switch (fileType)
{
case FILE_TYPE_TEXT:
int aux = Utility.getShort (buffer, i + 31);
subType = String.format ("R=%5d", aux);
break;
@ -134,14 +130,13 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
case FILE_TYPE_PNT:
case FILE_TYPE_PIC:
case FILE_TYPE_FOT:
aux = Utility.getShort (buffer, i + 31);
subType = String.format ("A=$%4X", aux);
break;
case FILE_TYPE_AWP:
aux = Utility.intValue (buffer[i + 32], buffer[i + 31]); // backwards!
if (aux != 0)
filename = convert (filename, aux);
int flags = Utility.intValue (buffer[i + 32], buffer[i + 31]); // aux backwards!
if (flags != 0)
filename = convert (filename, flags);
break;
default:
@ -149,9 +144,9 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
}
String forkFlag = storageType == 5 ? "+" : " ";
text.append (String.format ("%s%-15s %3s%s %5d %9s %5s %9s %5s %8d %7s%n",
locked, filename, ProdosConstants.fileTypes[type], forkFlag, blocks, dateM,
timeM, dateC, timeC, eof, subType));
text.append (String.format ("%s%-15s %3s%s %5d %9s %5s %9s %5s %8d %7s %04X%n",
locked, filename, ProdosConstants.fileTypes[type], forkFlag, blocks, dateM, timeM,
dateC, timeC, eof, subType, aux));
break;
default:
@ -159,8 +154,7 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
}
}
text.append (
String.format ("%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
text.append (String.format ("%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
freeBlocks, usedBlocks, totalBlocks));
return text.toString ();

View File

@ -15,8 +15,8 @@ import com.bytezone.diskbrowser.utilities.Utility;
abstract class CatalogEntry implements AppleFileSource
// -----------------------------------------------------------------------------------//
{
static String[] storageTypes = { "Del", "Sdl", "Sap", "Tre", "Pas", "Ext", "", "", "",
"", "", "", "", "DIR", "SDH", "VDH" };
static String[] storageTypes =
{ "Del", "Sdl", "Sap", "Tre", "Pas", "Ext", "", "", "", "", "", "", "", "DIR", "SDH", "VDH" };
Disk disk;
ProdosDisk parentDisk;
@ -111,6 +111,7 @@ abstract class CatalogEntry implements AppleFileSource
StringBuilder text = new StringBuilder ();
text.append (String.format ("Name .......... %s%n", name));
text.append (String.format ("Access ........ %02X%n", access));
text.append (String.format ("Storage type... %02X%n", storageType));
text.append (String.format ("Created ....... %s%n",
created == null ? "" : created.format (ProdosDisk.df)));

View File

@ -444,8 +444,15 @@ public final class Utility
else
year += 1900;
try
{
return LocalDate.of (year, month, day);
}
catch (DateTimeException e)
{
return null;
}
}
// ---------------------------------------------------------------------------------//
public static int getWizLong (byte[] buffer, int offset)