Added ability to set values; work is done from readFileEntry and

writeFileEntry.
This commit is contained in:
Robert Greene 2002-12-12 01:46:14 +00:00
parent 45c415b9e6
commit edb1bed60f
1 changed files with 52 additions and 7 deletions

View File

@ -31,42 +31,87 @@ public class ProdosCommonDirectoryHeader extends ProdosCommonEntry {
* Constructor for ProdosCommonDirectoryHeader. * Constructor for ProdosCommonDirectoryHeader.
* @param fileEntry * @param fileEntry
*/ */
public ProdosCommonDirectoryHeader(byte[] fileEntry) { public ProdosCommonDirectoryHeader(ProdosFormatDisk disk, int block) {
super(fileEntry); super(disk, block, 4); // directory entries are always offset 4, right?
} }
/** /**
* Get the length of each entry. Expected to be 0x27. * Get the length of each entry. Expected to be 0x27.
*/ */
public int getEntryLength() { public int getEntryLength() {
return AppleUtil.getUnsignedByte(getFileEntry()[0x1f]); return AppleUtil.getUnsignedByte(readFileEntry()[0x1f]);
}
/**
* Set the length of each entry.
*/
public void setEntryLength() {
byte[] data = readFileEntry();
data[0x1f] = (byte) ENTRY_LENGTH;
writeFileEntry(data);
} }
/** /**
* Get the number of entries per block. Expected to be 0x0d. * Get the number of entries per block. Expected to be 0x0d.
*/ */
public int getEntriesPerBlock() { public int getEntriesPerBlock() {
return AppleUtil.getUnsignedByte(getFileEntry()[0x20]); return AppleUtil.getUnsignedByte(readFileEntry()[0x20]);
}
/**
* Set the number of entries per block.
*/
public void setEntriesPerBlock() {
byte[] data = readFileEntry();
data[0x20] = 0x0d;
writeFileEntry(data);
} }
/** /**
* Get the number of active entries in the volume directory. * Get the number of active entries in the volume directory.
*/ */
public int getFileCount() { public int getFileCount() {
return AppleUtil.getWordValue(getFileEntry(), 0x21); return AppleUtil.getWordValue(readFileEntry(), 0x21);
}
/**
* Set the number of active entries in the volume directory.
*/
public void setFileCount(int fileCount) {
byte[] data = readFileEntry();
AppleUtil.setWordValue(data, 0x21, fileCount);
writeFileEntry(data);
} }
/** /**
* Get the block number of the bit map. * Get the block number of the bit map.
*/ */
public int getBitMapPointer() { public int getBitMapPointer() {
return AppleUtil.getWordValue(getFileEntry(), 0x23); return AppleUtil.getWordValue(readFileEntry(), 0x23);
}
/**
* Set the block number of the bit map.
*/
public void setBitMapPointer(int blockNumber) {
byte[] data = readFileEntry();
AppleUtil.setWordValue(data, 0x23, blockNumber);
writeFileEntry(data);
} }
/** /**
* Get the total number of blocks on this volume. * Get the total number of blocks on this volume.
*/ */
public int getTotalBlocks() { public int getTotalBlocks() {
return AppleUtil.getWordValue(getFileEntry(), 0x25); return AppleUtil.getWordValue(readFileEntry(), 0x25);
}
/**
* Set the total number of blocks on this volume.
*/
public void setTotalBlocks(int totalBlocks) {
byte[] data = readFileEntry();
AppleUtil.setWordValue(data, 0x25, totalBlocks);
writeFileEntry(data);
} }
} }