Submitted by Martin Haye:

When one creates a subdirectory on a ProDOS volume, the master entry in the subdirectory's key block needs to point back to its parent directory block and entry number. However, the code for setting those things is missing.
This commit is contained in:
2013-07-05 03:25:12 +00:00
parent 43ccf507c4
commit 4989c0353b
2 changed files with 22 additions and 0 deletions

View File

@ -1338,6 +1338,7 @@ public class ProdosFormatDisk extends FormattedDisk {
int blockNumber = directory.getFileEntryBlock(); int blockNumber = directory.getFileEntryBlock();
while (blockNumber != 0) { while (blockNumber != 0) {
byte[] block = readBlock(blockNumber); byte[] block = readBlock(blockNumber);
int entryNum = 0;
int offset = 4; int offset = 4;
while (offset+ProdosCommonEntry.ENTRY_LENGTH < BLOCK_SIZE) { while (offset+ProdosCommonEntry.ENTRY_LENGTH < BLOCK_SIZE) {
int value = AppleUtil.getUnsignedByte(block[offset]); int value = AppleUtil.getUnsignedByte(block[offset]);
@ -1358,6 +1359,8 @@ public class ProdosFormatDisk extends FormattedDisk {
newHeader.setHousekeeping(); newHeader.setHousekeeping();
newHeader.setCreationDate(new Date()); newHeader.setCreationDate(new Date());
newHeader.setParentPointer(blockNumber); newHeader.setParentPointer(blockNumber);
newHeader.setParentEntry(entryNum);
newHeader.setParentEntryLength(ProdosCommonEntry.ENTRY_LENGTH);
// Now, add an entry for this subdirectory // Now, add an entry for this subdirectory
ProdosDirectoryEntry fileEntry = ProdosDirectoryEntry fileEntry =
new ProdosDirectoryEntry(this, blockNumber, offset, newHeader); new ProdosDirectoryEntry(this, blockNumber, offset, newHeader);
@ -1380,6 +1383,7 @@ public class ProdosFormatDisk extends FormattedDisk {
return fileEntry; return fileEntry;
} }
offset+= ProdosCommonEntry.ENTRY_LENGTH; offset+= ProdosCommonEntry.ENTRY_LENGTH;
entryNum++;
} }
int nextBlockNumber = AppleUtil.getWordValue(block, NEXT_BLOCK_POINTER); int nextBlockNumber = AppleUtil.getWordValue(block, NEXT_BLOCK_POINTER);
if (nextBlockNumber == 0 && directory instanceof ProdosSubdirectoryHeader) { if (nextBlockNumber == 0 && directory instanceof ProdosSubdirectoryHeader) {

View File

@ -69,6 +69,15 @@ public class ProdosSubdirectoryHeader extends ProdosCommonDirectoryHeader {
return AppleUtil.getUnsignedByte(readFileEntry()[0x25]); return AppleUtil.getUnsignedByte(readFileEntry()[0x25]);
} }
/**
* Sets the number of the file entry within the parent block.
*/
public void setParentEntry(int entryNum) {
byte[] data = readFileEntry();
data[0x25] = (byte) entryNum;
writeFileEntry(data);
}
/** /**
* Return the length of the parent entry. * Return the length of the parent entry.
*/ */
@ -76,6 +85,15 @@ public class ProdosSubdirectoryHeader extends ProdosCommonDirectoryHeader {
return AppleUtil.getWordValue(readFileEntry(), 0x26); return AppleUtil.getWordValue(readFileEntry(), 0x26);
} }
/**
* Sets the number of the file entry within the parent block.
*/
public void setParentEntryLength(int length) {
byte[] data = readFileEntry();
data[0x26] = (byte) length;
writeFileEntry(data);
}
/** /**
* Set the related ProDOS directory entry. * Set the related ProDOS directory entry.
*/ */