In article , Rob Greene wrote: > "John B. Matthews" wrote in news:nospam- > 35F98B.00402505092003@clmboh1-nws3.columbus.rr.com: > > > Note that ProDOS delete() has significant problems. More as this > > develops. > > That sounds familiar. It is on the TODO list - although the description I > left myself isn't the best: delete does not seem to delete in all > circumstances. > > Hmmm... let me know! I'll be out this weekend, but I may be able to join > in the hunt later if the need arises. > -Rob Rob: Here's the delete() fixes: 8. In ProdosFormatDisk.createFile(), add fileEntry.setKeyPointer(0); if this is a recyled directory entry, a subsequent call to setFileData will try to free blocks that previously belonged to the deleted file. These blocks may have subsequently been allocated to another file. fileEntry.setKeyPointer(0); //may have been recycled Also, call setSeedlingFile(), rather than setSaplingFile(). 9. A file entry needs a header pointer: In ProdosFileEntry add /** * Set the block number of the block for the directory * that describes this file. */ public void setHeaderPointer(int headerPointer) { byte[] entry = readFileEntry(); AppleUtil.setWordValue(entry, 0x25, headerPointer); writeFileEntry(entry); } 10. Initailize header pointer in ProdosFormatDisk.createFile(), add int headerBlock = blockNumber; ... fileEntry.setHeaderPointer(headerBlock); 11. In ProdosFileEntry.delete(), the file count in the entry's directory header should be decremented. [ProDOS Tech. Ref. B.2.2 B.2.3] Also, both the storage type and the name length should be set to zero. [ProDOS Tech. Ref. B.2.4] /** * Delete the file. */ public void delete() { getDisk().freeBlocks(this); //decrement file count in header block int headerBlock = getHeaderPointer(); byte[] data = getDisk().readBlock(headerBlock); int fileCount = AppleUtil.getWordValue(data, 0x25); if (fileCount != 0) fileCount--; AppleUtil.setWordValue(data, 0x25, fileCount); getDisk().writeBlock(headerBlock, data); //clear storage type and name length data = readFileEntry(); data[0] = 0; writeFileEntry(data); } 12. And a new TextFileFilter: /** * Process the given FileEntry and return a byte array * with filtered data; use PrintWriter to get platform * agnostic line endings. */ public byte[] filter(FileEntry fileEntry) { byte[] fileData = fileEntry.getFileData(); int offset = 0; ByteArrayOutputStream byteArray = new ByteArrayOutputStream(fileData.length); PrintWriter printWriter = new PrintWriter(byteArray, true); while (offset < fileData.length) { char c = (char)(fileData[offset] & 0x7f); if (c != 0) { if (c == 0x0d) { //Apple line end printWriter.println(); } else { printWriter.print(c); } } offset++; } return byteArray.toByteArray(); } John ---- jmatthews at wright dot edu www dot wright dot edu/~john.matthews/