diff --git a/src/com/webcodepro/applecommander/storage/Disk.java b/src/com/webcodepro/applecommander/storage/Disk.java index 42f31c0..7de2a2c 100644 --- a/src/com/webcodepro/applecommander/storage/Disk.java +++ b/src/com/webcodepro/applecommander/storage/Disk.java @@ -181,7 +181,7 @@ public class Disk { byte[] diskImage = null; byte[] diskImageDC42 = null; - if (isSDK() || isSHK()) { + if (isSDK() || isSHK() || isBXY()) { // If we have an SDK, unpack it and send along the byte array // If we have a SHK, build a new disk and unpack the contents on to it diskImage = com.webcodepro.shrinkit.Utilities.unpackSHKFile(filename); @@ -424,6 +424,14 @@ public class Disk { return filename.toLowerCase().endsWith(".shk"); //$NON-NLS-1$ } + /** + * Indicate if this disk is a ShrinkIt-compressed binary II archive. + */ + public boolean isBXY() + { + return filename.toLowerCase().endsWith(".bxy"); //$NON-NLS-1$ + } + /** * Indicate if this disk is ProDOS ordered (beginning with block 0). */ diff --git a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java index 870ee8f..d6d02c9 100644 --- a/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java +++ b/src/com/webcodepro/applecommander/storage/os/prodos/ProdosFormatDisk.java @@ -632,6 +632,7 @@ public class ProdosFormatDisk extends FormattedDisk { } else { // compute free space and see if the data will fit! int numberOfDataBlocks = (fileData.length + BLOCK_SIZE - 1) / BLOCK_SIZE; + if (fileData.length == 0) numberOfDataBlocks = 1; int numberOfBlocks = numberOfDataBlocks; if (numberOfBlocks > 1) { numberOfBlocks+= ((numberOfDataBlocks-1) / 256) + 1; // that's 128K @@ -657,7 +658,8 @@ public class ProdosFormatDisk extends FormattedDisk { byte[] masterIndexBlockData = new byte[BLOCK_SIZE]; int offset = 0; int blockCount = 0; - while (offset < fileData.length) { + // Need to let a file length go through once + while ((offset < fileData.length) || ((fileData.length == 0) && (offset == 0))){ if (blockCount > 0) blockNumber = findFreeBlock(bitmap); setBlockUsed(bitmap, blockNumber); blockCount++; diff --git a/src/com/webcodepro/shrinkit/HeaderBlock.java b/src/com/webcodepro/shrinkit/HeaderBlock.java index ad00eee..a76106a 100644 --- a/src/com/webcodepro/shrinkit/HeaderBlock.java +++ b/src/com/webcodepro/shrinkit/HeaderBlock.java @@ -108,10 +108,24 @@ public class HeaderBlock { ThreadRecord r = findThreadRecord(ThreadKind.FILENAME); if (r != null) filename = r.getText(); if (filename == null) filename = rawFilename; + if (filename.contains(":")) { + filename = filename.replace(":","/"); + } } return filename; } + /** + * Final element in the path, in those cases where a filename actually holds a path name + */ + public String getFinalFilename() { + String filename = getFilename(); + String[] path; + path = filename.split("/"); + filename = path[path.length - 1]; + return filename; + } + /** * Get the data fork. */ diff --git a/src/com/webcodepro/shrinkit/Utilities.java b/src/com/webcodepro/shrinkit/Utilities.java index 059f488..d30db9a 100644 --- a/src/com/webcodepro/shrinkit/Utilities.java +++ b/src/com/webcodepro/shrinkit/Utilities.java @@ -136,7 +136,7 @@ public class Utilities // We have a traditional file, no resource fork. newFile.setFileData(readThread(dataFork)); } - newFile.setFilename(b.getFilename()); + newFile.setFilename(b.getFinalFilename()); newFile.setFiletype(b.getFileType()); newFile.setAuxiliaryType((int) b.getExtraType()); // TODO: dates differ by a month or so from what CiderPress reports. diff --git a/src/com/webcodepro/shrinkit/io/LittleEndianByteInputStream.java b/src/com/webcodepro/shrinkit/io/LittleEndianByteInputStream.java index 05dc684..bf5c145 100644 --- a/src/com/webcodepro/shrinkit/io/LittleEndianByteInputStream.java +++ b/src/com/webcodepro/shrinkit/io/LittleEndianByteInputStream.java @@ -62,6 +62,9 @@ public class LittleEndianByteInputStream extends InputStream implements ByteCons byte[] data = new byte[bytes]; int read = inputStream.read(data); bytesRead+= read; + // In the case where we have a zero-byte file, 'read' stays at -1, which is not correct. Fix it. + if ((bytes == 0) && (read == -1)) + read = 0; if (read < bytes) { throw new IOException("Requested " + bytes + " bytes, but " + read + " read"); }