From c4ef20979262b6c32e5d16fe173993719b7f6b58 Mon Sep 17 00:00:00 2001 From: "John B. Matthews" Date: Sun, 18 May 2008 06:15:02 +0000 Subject: [PATCH] Bug fix: DosFormatDisk.createFile() must iterate sectors (not tracks); in ac.putFile() call setFileData() _then_ setAddress(). --- .../applecommander/storage/os/dos33/DosFileEntry.java | 4 +++- .../applecommander/storage/os/dos33/DosFormatDisk.java | 2 +- src/com/webcodepro/applecommander/ui/ac.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/webcodepro/applecommander/storage/os/dos33/DosFileEntry.java b/src/com/webcodepro/applecommander/storage/os/dos33/DosFileEntry.java index e178aef..b977008 100644 --- a/src/com/webcodepro/applecommander/storage/os/dos33/DosFileEntry.java +++ b/src/com/webcodepro/applecommander/storage/os/dos33/DosFileEntry.java @@ -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); diff --git a/src/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java index 15a600d..5a7db08 100644 --- a/src/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/dos33/DosFormatDisk.java @@ -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 diff --git a/src/com/webcodepro/applecommander/ui/ac.java b/src/com/webcodepro/applecommander/ui/ac.java index 81331e4..126a3a5 100644 --- a/src/com/webcodepro/applecommander/ui/ac.java +++ b/src/com/webcodepro/applecommander/ui/ac.java @@ -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(); }