Restructured CPM a little bit to enable deletes. #41
This commit is contained in:
parent
a281a50640
commit
237e518d31
|
@ -119,11 +119,7 @@ public class CpmFileEntry implements FileEntry {
|
||||||
* Read the fileEntry bytes from the disk image.
|
* Read the fileEntry bytes from the disk image.
|
||||||
*/
|
*/
|
||||||
protected byte[] readFileEntry(int number) {
|
protected byte[] readFileEntry(int number) {
|
||||||
byte[] data = new byte[2 * CpmFormatDisk.CPM_BLOCKSIZE];
|
byte[] data = disk.readCpmFileEntries();
|
||||||
System.arraycopy(disk.readCpmBlock(0), 0, data,
|
|
||||||
0, CpmFormatDisk.CPM_BLOCKSIZE);
|
|
||||||
System.arraycopy(disk.readCpmBlock(1), 0, data,
|
|
||||||
CpmFormatDisk.CPM_BLOCKSIZE, CpmFormatDisk.CPM_BLOCKSIZE);
|
|
||||||
byte[] entry = new byte[ENTRY_LENGTH];
|
byte[] entry = new byte[ENTRY_LENGTH];
|
||||||
int offset = ((Integer)offsets.get(number)).intValue();
|
int offset = ((Integer)offsets.get(number)).intValue();
|
||||||
System.arraycopy(data, offset, entry, 0, ENTRY_LENGTH);
|
System.arraycopy(data, offset, entry, 0, ENTRY_LENGTH);
|
||||||
|
@ -133,14 +129,11 @@ public class CpmFileEntry implements FileEntry {
|
||||||
/**
|
/**
|
||||||
* Write the fileEntry bytes back to the disk image.
|
* Write the fileEntry bytes back to the disk image.
|
||||||
*/
|
*/
|
||||||
protected void writeFileEntry(int number, byte[] data) {
|
protected void writeFileEntry(int number, byte[] entry) {
|
||||||
byte[] block = new byte[CpmFormatDisk.CPM_BLOCKSIZE];
|
byte[] entries = disk.readCpmFileEntries();
|
||||||
System.arraycopy(data, 0, block,
|
int offset = ((Integer)offsets.get(number)).intValue();
|
||||||
0, CpmFormatDisk.CPM_BLOCKSIZE);
|
System.arraycopy(entry, 0, entries, offset, ENTRY_LENGTH);
|
||||||
disk.writeCpmBlock(0, block);
|
disk.writeCpmFileEntries(entries);
|
||||||
System.arraycopy(data, 0, block,
|
|
||||||
CpmFormatDisk.CPM_BLOCKSIZE, CpmFormatDisk.CPM_BLOCKSIZE);
|
|
||||||
disk.writeCpmBlock(1, block);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -443,6 +443,24 @@ public class CpmFormatDisk extends FormattedDisk {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] readCpmFileEntries() {
|
||||||
|
byte[] data = new byte[2 * CpmFormatDisk.CPM_BLOCKSIZE];
|
||||||
|
System.arraycopy(readCpmBlock(0), 0, data,
|
||||||
|
0, CpmFormatDisk.CPM_BLOCKSIZE);
|
||||||
|
System.arraycopy(readCpmBlock(1), 0, data,
|
||||||
|
CpmFormatDisk.CPM_BLOCKSIZE, CpmFormatDisk.CPM_BLOCKSIZE);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
public void writeCpmFileEntries(byte[] data) {
|
||||||
|
byte[] block = new byte[CPM_BLOCKSIZE];
|
||||||
|
System.arraycopy(data, 0, block,
|
||||||
|
0, CpmFormatDisk.CPM_BLOCKSIZE);
|
||||||
|
writeCpmBlock(0, block);
|
||||||
|
System.arraycopy(data, CpmFormatDisk.CPM_BLOCKSIZE, block,
|
||||||
|
0, CpmFormatDisk.CPM_BLOCKSIZE);
|
||||||
|
writeCpmBlock(1, block);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the physical track number.
|
* Compute the physical track number.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue