WimFileSystempublic class WimFileSystem extends FileSystemAbstract This class provides interface to WIM file system. |
Fields Summary |
---|
private int | CARD_BUFFERConstant defines size of the card buffer | private int | P1_P2Constant defines parameters P1, P2 in the apdu command |
Constructors Summary |
---|
public WimFileSystem(Connection apdu)Constructs new WimFileSystem object.
super(apdu);
apdu.setCLAbyte((byte)0x80);
|
Methods Summary |
---|
public byte[] | readData(int offset, int length, int fileOffset)Reads part of selected file.
byte[] data = new byte[length + offset];
while (length != 0) {
int len = length > CARD_BUFFER ? CARD_BUFFER : length;
byte[] result = apdu.resetCommand().
sendCommand(INS_READ, fileOffset, len, true);
System.arraycopy(result, 0, data, offset, len);
offset += len;
fileOffset += len;
length -= len;
}
return data;
| public void | select(short id)Selects file by ID.
byte[] data = apdu.resetCommand().
putShort(id).
sendCommand(INS_SELECT, P1_P2);
isEFSelected = false;
currentFileSize = 0;
if (data.length == 2) {
return; // FCI is empty
}
TLV t; // parse FCI
try {
t = new TLV(data, 0);
} catch (TLVException e) {
throw new IOException();
}
t = t.child;
while (t != null) {
if (t.type == 0x80) {
isEFSelected = true;
currentFileSize = Utils.getU2(data, t.valueOffset);
return;
}
t = t.next;
}
return;
| public void | writeData(byte[] data, int offset, int length, int fileOffset)Writes data into selected file.
while (length != 0) {
int len = length > CARD_BUFFER ? CARD_BUFFER : length;
apdu.resetCommand().
putBytes(data, offset, len).
sendCommand(INS_UPDATE, fileOffset, len, true);
offset += len;
fileOffset += len;
length -= len;
}
|
|