Skip to content

Commit

Permalink
hdv bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolony committed Mar 14, 2017
1 parent 7381d8e commit 81523d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/com/bytezone/diskbrowser/disk/DiskFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ private static ProdosDisk checkHardDisk (File file)
catch (Exception e)
{
System.out.println (e);
System.out.println ("Prodos hard disk had error");
}

if (debug)
Expand Down
30 changes: 17 additions & 13 deletions src/com/bytezone/diskbrowser/prodos/FileEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,10 @@ private boolean isGEOSFile ()
return ((fileType & 0xF0) == 0x80);
}

private void removeEmptyBlocks ()
{
while (dataBlocks.size () > 0)
{
DiskAddress da = dataBlocks.get (dataBlocks.size () - 1);
if (da.getBlock () == 0)
dataBlocks.remove (dataBlocks.size () - 1);
else
break;
}
}

private void traverseMasterIndex (int keyPtr)
{
byte[] buffer = disk.readSector (keyPtr); // master index

// find the last used index block
// get the file size from the catalog and only check those blocks
int highestBlock = 0;
Expand All @@ -151,9 +140,10 @@ private void traverseMasterIndex (int keyPtr)
break;
}
}

for (int i = 0; i <= highestBlock; i++)
{
int block = HexFormatter.intValue (buffer[i], buffer[i + 256]); // index
int block = HexFormatter.intValue (buffer[i], buffer[i + 256]); // index
if (block != 0)
traverseIndex (block);
else
Expand All @@ -164,9 +154,23 @@ private void traverseMasterIndex (int keyPtr)
dataBlocks.add (da);
}
}

removeEmptyBlocks ();
}

private void removeEmptyBlocks ()
{
while (dataBlocks.size () > 0)
{
DiskAddress da = dataBlocks.get (dataBlocks.size () - 1);

if (da == null || da.getBlock () != 0)
break;

dataBlocks.remove (dataBlocks.size () - 1);
}
}

private void traverseIndex (int keyBlock)
{
parentDisk.setSectorType (keyBlock, parentDisk.indexSector);
Expand Down
7 changes: 3 additions & 4 deletions src/com/bytezone/diskbrowser/prodos/ProdosDisk.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,11 @@ private void processDirectoryBlock (int block, FileEntry parent,
byte[] sectorBuffer = disk.readSector (block);
sectorTypes[block] = currentSectorType;

for (int ptr = 4, max =
disk.getBlockSize () - ProdosConstants.ENTRY_SIZE; ptr < max; ptr +=
ProdosConstants.ENTRY_SIZE)
int max = disk.getBlockSize () - ProdosConstants.ENTRY_SIZE;
for (int ptr = 4; ptr < max; ptr += ProdosConstants.ENTRY_SIZE)
{
int storageType = (sectorBuffer[ptr] & 0xF0) >> 4;
if (storageType == 0) // deleted or unused
if (storageType == 0) // deleted or unused
continue;

byte[] entry = new byte[ProdosConstants.ENTRY_SIZE];
Expand Down

0 comments on commit 81523d0

Please sign in to comment.