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:
parent
43ccf507c4
commit
4989c0353b
|
@ -1338,6 +1338,7 @@ public class ProdosFormatDisk extends FormattedDisk {
|
|||
int blockNumber = directory.getFileEntryBlock();
|
||||
while (blockNumber != 0) {
|
||||
byte[] block = readBlock(blockNumber);
|
||||
int entryNum = 0;
|
||||
int offset = 4;
|
||||
while (offset+ProdosCommonEntry.ENTRY_LENGTH < BLOCK_SIZE) {
|
||||
int value = AppleUtil.getUnsignedByte(block[offset]);
|
||||
|
@ -1358,6 +1359,8 @@ public class ProdosFormatDisk extends FormattedDisk {
|
|||
newHeader.setHousekeeping();
|
||||
newHeader.setCreationDate(new Date());
|
||||
newHeader.setParentPointer(blockNumber);
|
||||
newHeader.setParentEntry(entryNum);
|
||||
newHeader.setParentEntryLength(ProdosCommonEntry.ENTRY_LENGTH);
|
||||
// Now, add an entry for this subdirectory
|
||||
ProdosDirectoryEntry fileEntry =
|
||||
new ProdosDirectoryEntry(this, blockNumber, offset, newHeader);
|
||||
|
@ -1380,6 +1383,7 @@ public class ProdosFormatDisk extends FormattedDisk {
|
|||
return fileEntry;
|
||||
}
|
||||
offset+= ProdosCommonEntry.ENTRY_LENGTH;
|
||||
entryNum++;
|
||||
}
|
||||
int nextBlockNumber = AppleUtil.getWordValue(block, NEXT_BLOCK_POINTER);
|
||||
if (nextBlockNumber == 0 && directory instanceof ProdosSubdirectoryHeader) {
|
||||
|
|
|
@ -69,6 +69,15 @@ public class ProdosSubdirectoryHeader extends ProdosCommonDirectoryHeader {
|
|||
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.
|
||||
*/
|
||||
|
@ -76,6 +85,15 @@ public class ProdosSubdirectoryHeader extends ProdosCommonDirectoryHeader {
|
|||
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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue