Bug fix: DosFormatDisk.createFile() must iterate sectors (not tracks); in ac.putFile() call setFileData() _then_ setAddress().

This commit is contained in:
John B. Matthews 2008-05-18 06:15:02 +00:00
parent 713bfac5f2
commit c4ef209792
3 changed files with 5 additions and 3 deletions

View File

@ -357,6 +357,8 @@ public class DosFileEntry implements FileEntry {
* Note: The address can be set before the data is saved or
* after the data is saved. This is an attempt to make the
* API more easily usable.
*
* Empirically, the data must be set before the address is set.
*/
public void setFileData(byte[] data) throws DiskFullException {
if (isBinaryFile()) {
@ -365,7 +367,7 @@ public class DosFileEntry implements FileEntry {
AppleUtil.setWordValue(filedata, 0, address.intValue());
address = null;
} else {
AppleUtil.setWordValue(filedata, 0, 0); // Needs to be set via setAddress
AppleUtil.setWordValue(filedata, 0, 0); // Needs to be set via setAddress
}
AppleUtil.setWordValue(filedata, 2, data.length);
System.arraycopy(data, 0, filedata, 4, data.length);

View File

@ -161,7 +161,7 @@ public class DosFormatDisk extends FormattedDisk {
byte[] vtoc = readVtoc();
int track = AppleUtil.getUnsignedByte(vtoc[1]);
int sector = AppleUtil.getUnsignedByte(vtoc[2]);
while (track != 0) { // iterate through all catalog sectors
while (sector != 0) { // bug fix: iterate through all catalog _sectors_
byte[] catalogSector = readSector(track, sector);
int offset = 0x0b;
while (offset < 0xff) { // iterate through all entries

View File

@ -106,10 +106,10 @@ public class ac {
FileEntry entry = formattedDisk.createFile();
entry.setFilename(fileName);
entry.setFiletype(fileType);
entry.setFileData(buf.toByteArray());
if (entry.needsAddress()) {
entry.setAddress(stringToInt(address));
}
entry.setFileData(buf.toByteArray());
formattedDisk.save();
}