public class ERXMacBinarySwissArmyKnife extends Object
Modifier and Type | Field and Description |
---|---|
static int |
_AT
Offsets in header where the fields are located.
|
static int |
CRC_AT
Offsets in header where the fields are located.
|
static int |
FILE_CREATOR_AT
Offsets in header where the fields are located.
|
static int |
FILE_TYPE_AT
Offsets in header where the fields are located.
|
static int |
FINDER_FLAGS1_AT
Offsets in header where the fields are located.
|
static int |
FINDER_FLAGS2_AT
Offsets in header where the fields are located.
|
static int |
FINDER_FLAGS3_AT
Offsets in header where the fields are located.
|
static int |
FINDER_HORZ_AT
Offsets in header where the fields are located.
|
static int |
FINDER_VERT_AT
Offsets in header where the fields are located.
|
static int |
FINDER_WINDOW_AT
Offsets in header where the fields are located.
|
static int |
FLAG_LOCKED_AT
Offsets in header where the fields are located.
|
static int |
LEN_COMMENT_AT
Offsets in header where the fields are located.
|
static int |
LEN_DATA_FORK_AT
Offsets in header where the fields are located.
|
static int |
LEN_RES_FORK_AT
Offsets in header where the fields are located.
|
static int |
LEN_SECONDARY_AT
Offsets in header where the fields are located.
|
protected static int[] |
levelMasks
Bit-masks for different levels.
|
static long |
LIMIT_DATAFORK
Enforce this limit on data-fork length, due either to Mac OS API or field-width.
|
static int |
LIMIT_NAME
Enforce this limit on name-length, regardless of available space in header.
|
static int |
LIMIT_RESFORK
Enforce this limit on resource-fork length, due either to Mac OS API or field-width.
|
static int |
MACBINARY_HEADER_LEN
Length of a MacBinary header, always the first component of the file,
and the only required element.
|
static int |
MB1_VERSION
Possible values in VERSION_TARGET_AT and VERSION_MIN_AT byte-sized fields.
|
static int |
MB2_VERSION
Possible values in VERSION_TARGET_AT and VERSION_MIN_AT byte-sized fields.
|
static int |
MB3_SIGNATURE
Distinctive int-sized value in MB3_SIGNATURE_AT field, only present
for MB-3 format.
|
static int |
MB3_SIGNATURE_AT
Offsets in header where the fields are located.
|
static int |
MB3_VERSION
Possible values in VERSION_TARGET_AT and VERSION_MIN_AT byte-sized fields.
|
static int |
NAME_BYTES_AT
Offsets in header where the fields are located.
|
static int |
NAME_LEN_AT
Offsets in header where the fields are located.
|
static int |
NAME_SCRIPT_AT
Offsets in header where the fields are located.
|
protected static boolean |
strict |
static int |
VERSION_MIN_AT
Offsets in header where the fields are located.
|
static int |
VERSION_OBSOLETE_AT
Offsets in header where the fields are located.
|
static int |
VERSION_TARGET_AT
Offsets in header where the fields are located.
|
static int |
WHEN_CREATED_AT
Offsets in header where the fields are located.
|
static int |
WHEN_MODIFIED_AT
Offsets in header where the fields are located.
|
static int |
ZERO_1_AT
Offsets in header where the fields are located.
|
static int |
ZERO_2_AT
Offsets in header where the fields are located.
|
static int |
ZERO_3_AT
Offsets in header where the fields are located.
|
Constructor and Description |
---|
ERXMacBinarySwissArmyKnife() |
ERXMacBinarySwissArmyKnife(com.webobjects.foundation.NSData fileData) |
Modifier and Type | Method and Description |
---|---|
int |
calcCRC()
Calculate and return a CRC over the header.
|
int |
calcCRC2()
Calculate and return an alternative header CRC.
|
static int |
calculateCRC(int seed,
byte[] bytes,
int offset,
int count)
Calculate a MacBinary CRC using the given starting seed, and proceeding over the given
range of bytes.
|
int |
checkFormat(boolean strictFormat) |
byte[] |
getByteArray()
Get the internal byte-array.
|
byte |
getByteAt(int offset)
Return the signed byte at the given offset.
|
int |
getCRC()
Return the header CRC, as embedded in the header itself.
|
int |
getDataForkLength()
Get the data-fork length from the header.
|
int |
getIntAt(int offset)
Return the signed int at the given offset.
|
long |
getLongAt(int offset)
Return the signed long at the given offset.
|
int |
getResourceForkLength()
Get the resource-fork length from the header.
|
short |
getShortAt(int offset)
Return the signed short at the given offset.
|
int |
getUByteAt(int offset)
Return an int holding the unsigned byte at the given offset.
|
long |
getUIntAt(int offset)
Return a long holding the unsigned int at the given offset.
|
int |
getUShortAt(int offset)
Return an int holding the unsigned short at the given offset.
|
boolean |
isMacBinary(com.webobjects.foundation.NSData fileData) |
boolean |
isValidCRC()
Calculate and check the header CRC.
|
void |
putByteAt(byte value,
int offset)
Put the given byte at the supplied offset.
|
void |
putBytesAt(byte[] data,
int offset)
Put all the given bytes at the supplied offset.
|
void |
putBytesAt(byte[] data,
int offset,
int count)
Put the given bytes at the supplied offset.
|
void |
putIntAt(int value,
int offset)
Put the given int at the supplied offset.
|
void |
putLongAt(long value,
int offset)
Put the given long at the supplied offset.
|
void |
putShortAt(short value,
int offset)
Put the given short at the supplied offset.
|
void |
setByteArray(byte[] bytes)
Use the given array to hold bytes.
|
void |
setCRC()
Calculate and set the CRC over the header bytes previously set,
invoking calcCRC() to calculate the 16-bit value to store.
|
com.webobjects.foundation.NSData |
unwrapMacBinary(com.webobjects.foundation.NSData fileContents) |
public static final int ZERO_1_AT
public static final int NAME_LEN_AT
public static final int NAME_BYTES_AT
public static final int FILE_TYPE_AT
public static final int FILE_CREATOR_AT
public static final int FINDER_FLAGS1_AT
public static final int ZERO_2_AT
public static final int FINDER_VERT_AT
public static final int FINDER_HORZ_AT
public static final int FINDER_WINDOW_AT
public static final int FLAG_LOCKED_AT
public static final int ZERO_3_AT
public static final int LEN_DATA_FORK_AT
public static final int LEN_RES_FORK_AT
public static final int WHEN_CREATED_AT
public static final int WHEN_MODIFIED_AT
public static final int LEN_COMMENT_AT
public static final int FINDER_FLAGS2_AT
public static final int MB3_SIGNATURE_AT
public static final int NAME_SCRIPT_AT
public static final int FINDER_FLAGS3_AT
public static final int LEN_SECONDARY_AT
public static final int VERSION_TARGET_AT
public static final int VERSION_MIN_AT
public static final int CRC_AT
public static final int VERSION_OBSOLETE_AT
public static final int _AT
public static final int MB1_VERSION
public static final int MB2_VERSION
public static final int MB3_VERSION
public static final int MB3_SIGNATURE
protected static final int[] levelMasks
public static final int MACBINARY_HEADER_LEN
public static final long LIMIT_DATAFORK
public static final int LIMIT_RESFORK
public static final int LIMIT_NAME
protected static boolean strict
public ERXMacBinarySwissArmyKnife()
public ERXMacBinarySwissArmyKnife(com.webobjects.foundation.NSData fileData)
public boolean isMacBinary(com.webobjects.foundation.NSData fileData)
public com.webobjects.foundation.NSData unwrapMacBinary(com.webobjects.foundation.NSData fileContents)
public int checkFormat(boolean strictFormat)
public byte getByteAt(int offset)
public int getUByteAt(int offset)
public short getShortAt(int offset)
public int getUShortAt(int offset)
public int getIntAt(int offset)
public long getUIntAt(int offset)
public long getLongAt(int offset)
public void putByteAt(byte value, int offset)
public void putBytesAt(byte[] data, int offset)
public void putBytesAt(byte[] data, int offset, int count)
public void putShortAt(short value, int offset)
public void putIntAt(int value, int offset)
public void putLongAt(long value, int offset)
public final byte[] getByteArray()
public final void setByteArray(byte[] bytes)
public int getDataForkLength()
public int getResourceForkLength()
public static int calculateCRC(int seed, byte[] bytes, int offset, int count)
public void setCRC()
In most cases, you will find finishHeader() more useful since it finishes all the assembly for a particular header-format you select.
public boolean isValidCRC()
public int calcCRC()
public int calcCRC2()
public int getCRC()
Copyright © 2002 – 2020 Project Wonder.