Allow converting BXY files
Allow zero-length shrinkit files Allow situations where shrunk files have full paths as filenames
This commit is contained in:
parent
87eca0095c
commit
2fac776ed3
|
@ -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).
|
||||
*/
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue