mirror of
https://github.com/AppleCommander/ShrinkItArchive.git
synced 2024-12-22 02:31:00 +00:00
Fix up SDK operations - when they're packed inside a BXY wrapper.
This commit is contained in:
parent
f5599334c5
commit
7743e29f8a
@ -25,12 +25,26 @@ public class MasterHeaderBlock {
|
||||
private Date archiveModWhen;
|
||||
private int masterVersion;
|
||||
private long masterEof;
|
||||
|
||||
private byte[] nuFileId = {0,0,0,0,0,0};
|
||||
|
||||
/**
|
||||
* Create the Master Header Block, based on the LittleEndianByteInputStream.
|
||||
*/
|
||||
public MasterHeaderBlock(LittleEndianByteInputStream bs) throws IOException {
|
||||
bs.checkNuFileId();
|
||||
int headerOffset = 0;
|
||||
nuFileId = bs.readBytes(6);
|
||||
|
||||
if (checkId(nuFileId,BXY_ID)) {
|
||||
bs.readBytes(127 - NUFILE_ID.length);
|
||||
headerOffset = 128;
|
||||
int count = bs.read();
|
||||
if (count != 0)
|
||||
throw new IOException("This is actually a Binary II archive with multiple files in it.");
|
||||
nuFileId = bs.readBytes(6);
|
||||
}
|
||||
if (!checkId(nuFileId,NUFILE_ID)) {
|
||||
throw new IOException("Unable to decode this archive.");
|
||||
}
|
||||
masterCrc = bs.readWord();
|
||||
bs.resetCrc(); // CRC is computed from this point to the end of the header
|
||||
totalRecords = bs.readLong();
|
||||
@ -44,7 +58,7 @@ public class MasterHeaderBlock {
|
||||
masterEof = -1;
|
||||
}
|
||||
// Read whatever remains of the fixed size header
|
||||
while (bs.getTotalBytesRead() < MASTER_HEADER_LENGTH) {
|
||||
while (bs.getTotalBytesRead() < MASTER_HEADER_LENGTH + headerOffset) {
|
||||
bs.readByte();
|
||||
}
|
||||
validCrc = (masterCrc == bs.getCrcValue());
|
||||
@ -91,4 +105,22 @@ public class MasterHeaderBlock {
|
||||
public boolean isValidCrc() {
|
||||
return validCrc;
|
||||
}
|
||||
/**
|
||||
* Test that the requested constant is present.
|
||||
*/
|
||||
private boolean checkId(byte[] data, byte[] constant) {
|
||||
for (int i = 0; i < constant.length; i++){
|
||||
if (data[i] != constant[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Master Header Block identifier "magic" bytes. */
|
||||
public static final byte[] NUFILE_ID = { 0x4e, (byte)0xf5, 0x46, (byte)0xe9, 0x6c, (byte)0xe5 };
|
||||
/** Header Block identifier "magic" bytes. */
|
||||
public static final byte[] NUFX_ID = { 0x4e, (byte)0xf5, 0x46, (byte)0xd8 };
|
||||
/** Binay II identifier "magic" bytes. */
|
||||
public static final byte[] BXY_ID = { 0x0a, 0x47, 0x4c };
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class ThreadRecord {
|
||||
if (hb.getStorageType() <= 13 ) {
|
||||
/* supposed to be block size, but SHK v3.0.1 stored it wrong */
|
||||
threadEof = hb.getExtraType() * 512;
|
||||
System.out.println("Found erroneous storage type... fixing.");
|
||||
// System.out.println("Found erroneous storage type... fixing.");
|
||||
} else if (hb.getStorageType() == 256 &&
|
||||
hb.getExtraType() == 280 &&
|
||||
hb.getFileSysId() == 2 ) { // FileSysDOS33
|
||||
|
Loading…
Reference in New Issue
Block a user