mirror of
https://github.com/dmolony/DiskBrowser.git
synced 2024-11-25 16:34:00 +00:00
Fixed Pascal bug with invalid dates
This commit is contained in:
parent
036e47b9b1
commit
37c489f252
@ -17,8 +17,7 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||||||
{
|
{
|
||||||
static final DateTimeFormatter df = DateTimeFormatter.ofPattern ("d-LLL-yy");
|
static final DateTimeFormatter df = DateTimeFormatter.ofPattern ("d-LLL-yy");
|
||||||
static final DateTimeFormatter tf = DateTimeFormatter.ofPattern ("H:mm");
|
static final DateTimeFormatter tf = DateTimeFormatter.ofPattern ("H:mm");
|
||||||
static final String UNDERLINE =
|
static final String UNDERLINE = "----------------------------------------------------\n";
|
||||||
"----------------------------------------------------\n";
|
|
||||||
|
|
||||||
private static final String NO_DATE = "<NO DATE>";
|
private static final String NO_DATE = "<NO DATE>";
|
||||||
|
|
||||||
@ -28,8 +27,8 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||||||
private final int usedBlocks;
|
private final int usedBlocks;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public ProdosDirectory (FormattedDisk parent, String name, byte[] buffer,
|
public ProdosDirectory (FormattedDisk parent, String name, byte[] buffer, int totalBlocks,
|
||||||
int totalBlocks, int freeBlocks, int usedBlocks)
|
int freeBlocks, int usedBlocks)
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
super (name, buffer);
|
super (name, buffer);
|
||||||
@ -86,7 +85,6 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||||||
int nameLength = buffer[i] & 0x0F;
|
int nameLength = buffer[i] & 0x0F;
|
||||||
String filename = HexFormatter.getString (buffer, i + 1, nameLength);
|
String filename = HexFormatter.getString (buffer, i + 1, nameLength);
|
||||||
String subType = "";
|
String subType = "";
|
||||||
String locked;
|
|
||||||
|
|
||||||
switch (storageType)
|
switch (storageType)
|
||||||
{
|
{
|
||||||
@ -111,22 +109,20 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||||||
LocalDateTime createdDate = Utility.getAppleDate (buffer, i + 24);
|
LocalDateTime createdDate = Utility.getAppleDate (buffer, i + 24);
|
||||||
LocalDateTime modifiedDate = Utility.getAppleDate (buffer, i + 33);
|
LocalDateTime modifiedDate = Utility.getAppleDate (buffer, i + 33);
|
||||||
|
|
||||||
String dateC =
|
String dateC = createdDate == null ? NO_DATE : createdDate.format (df).toUpperCase ();
|
||||||
createdDate == null ? NO_DATE : createdDate.format (df).toUpperCase ();
|
String dateM = modifiedDate == null ? NO_DATE : modifiedDate.format (df).toUpperCase ();
|
||||||
String dateM =
|
|
||||||
modifiedDate == null ? NO_DATE : modifiedDate.format (df).toUpperCase ();
|
|
||||||
|
|
||||||
String timeC = createdDate == null ? "" : createdDate.format (tf);
|
String timeC = createdDate == null ? "" : createdDate.format (tf);
|
||||||
String timeM = modifiedDate == null ? "" : modifiedDate.format (tf);
|
String timeM = modifiedDate == null ? "" : modifiedDate.format (tf);
|
||||||
|
|
||||||
int eof = Utility.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
|
int eof = Utility.intValue (buffer[i + 21], buffer[i + 22], buffer[i + 23]);
|
||||||
int fileType = buffer[i + 16] & 0xFF;
|
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)
|
switch (fileType)
|
||||||
{
|
{
|
||||||
case FILE_TYPE_TEXT:
|
case FILE_TYPE_TEXT:
|
||||||
int aux = Utility.getShort (buffer, i + 31);
|
|
||||||
subType = String.format ("R=%5d", aux);
|
subType = String.format ("R=%5d", aux);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -134,14 +130,13 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||||||
case FILE_TYPE_PNT:
|
case FILE_TYPE_PNT:
|
||||||
case FILE_TYPE_PIC:
|
case FILE_TYPE_PIC:
|
||||||
case FILE_TYPE_FOT:
|
case FILE_TYPE_FOT:
|
||||||
aux = Utility.getShort (buffer, i + 31);
|
|
||||||
subType = String.format ("A=$%4X", aux);
|
subType = String.format ("A=$%4X", aux);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILE_TYPE_AWP:
|
case FILE_TYPE_AWP:
|
||||||
aux = Utility.intValue (buffer[i + 32], buffer[i + 31]); // backwards!
|
int flags = Utility.intValue (buffer[i + 32], buffer[i + 31]); // aux backwards!
|
||||||
if (aux != 0)
|
if (flags != 0)
|
||||||
filename = convert (filename, aux);
|
filename = convert (filename, flags);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -149,9 +144,9 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||||||
}
|
}
|
||||||
|
|
||||||
String forkFlag = storageType == 5 ? "+" : " ";
|
String forkFlag = storageType == 5 ? "+" : " ";
|
||||||
text.append (String.format ("%s%-15s %3s%s %5d %9s %5s %9s %5s %8d %7s%n",
|
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,
|
locked, filename, ProdosConstants.fileTypes[type], forkFlag, blocks, dateM, timeM,
|
||||||
timeM, dateC, timeC, eof, subType));
|
dateC, timeC, eof, subType, aux));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -159,8 +154,7 @@ public class ProdosDirectory extends AbstractFile implements ProdosConstants
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text.append (
|
text.append (String.format ("%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
|
||||||
String.format ("%nBLOCKS FREE:%5d BLOCKS USED:%5d TOTAL BLOCKS:%5d%n",
|
|
||||||
freeBlocks, usedBlocks, totalBlocks));
|
freeBlocks, usedBlocks, totalBlocks));
|
||||||
|
|
||||||
return text.toString ();
|
return text.toString ();
|
||||||
|
@ -15,8 +15,8 @@ import com.bytezone.diskbrowser.utilities.Utility;
|
|||||||
abstract class CatalogEntry implements AppleFileSource
|
abstract class CatalogEntry implements AppleFileSource
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
{
|
{
|
||||||
static String[] storageTypes = { "Del", "Sdl", "Sap", "Tre", "Pas", "Ext", "", "", "",
|
static String[] storageTypes =
|
||||||
"", "", "", "", "DIR", "SDH", "VDH" };
|
{ "Del", "Sdl", "Sap", "Tre", "Pas", "Ext", "", "", "", "", "", "", "", "DIR", "SDH", "VDH" };
|
||||||
Disk disk;
|
Disk disk;
|
||||||
ProdosDisk parentDisk;
|
ProdosDisk parentDisk;
|
||||||
|
|
||||||
@ -111,6 +111,7 @@ abstract class CatalogEntry implements AppleFileSource
|
|||||||
StringBuilder text = new StringBuilder ();
|
StringBuilder text = new StringBuilder ();
|
||||||
|
|
||||||
text.append (String.format ("Name .......... %s%n", name));
|
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 ("Storage type... %02X%n", storageType));
|
||||||
text.append (String.format ("Created ....... %s%n",
|
text.append (String.format ("Created ....... %s%n",
|
||||||
created == null ? "" : created.format (ProdosDisk.df)));
|
created == null ? "" : created.format (ProdosDisk.df)));
|
||||||
|
@ -444,8 +444,15 @@ public final class Utility
|
|||||||
else
|
else
|
||||||
year += 1900;
|
year += 1900;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
return LocalDate.of (year, month, day);
|
return LocalDate.of (year, month, day);
|
||||||
}
|
}
|
||||||
|
catch (DateTimeException e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------//
|
// ---------------------------------------------------------------------------------//
|
||||||
public static int getWizLong (byte[] buffer, int offset)
|
public static int getWizLong (byte[] buffer, int offset)
|
||||||
|
Loading…
Reference in New Issue
Block a user