if(getStartBlock() != stream.getStartBlock()) {
setStartBlock(stream.getStartBlock());
}
+
+ // Update the number of property blocks in the header
+ _header_block.setPropertyCount(countBlocks());
}
private void populatePropertyTree(DirectoryProperty root) throws IOException {
*/
private int _bat_count;
+ /**
+ * Number of property blocks (int).
+ */
+ private int _property_count;
+
/**
* Start of the property set block (int index of the property set
* chain's first big block).
// Setup the fields to read and write the counts and starts
_bat_count = new IntegerField(_bat_count_offset, data).get();
+ _property_count = new IntegerField(_property_count_offset,_data).get();
_property_start = new IntegerField(_property_start_offset,_data).get();
_sbat_start = new IntegerField(_sbat_start_offset, _data).get();
_sbat_count = new IntegerField(_sbat_block_count_offset, _data).get();
+ read + type + " read; expected 512 bytes");
}
+ /**
+ * @return the number of property blocks
+ *
+ * @since POI 5.4.0
+ */
+ public int getPropertyCount() {
+ return _property_count;
+ }
+
+ /**
+ * Set the number of property blocks
+ *
+ * @param property_count number of property blocks
+ * @since POI 5.4.0
+ */
+ public void setPropertyCount(final int property_count) {
+ this._property_count = property_count;
+ }
+
/**
* get start of Property Table
*
public int getPropertyStart() {
return _property_start;
}
- /**
- * Set start of Property Table
- *
- * @param startBlock the index of the first block of the Property Table
- */
- public void setPropertyStart(final int startBlock) {
- _property_start = startBlock;
- }
+
+ /**
+ * Set start of Property Table
+ *
+ * @param startBlock the index of the first block of the Property Table
+ */
+ public void setPropertyStart(final int startBlock) {
+ _property_start = startBlock;
+ }
/**
* @return start of small block (MiniFAT) allocation table
public void writeData(final OutputStream stream) throws IOException {
// Update the counts and start positions
new IntegerField(_bat_count_offset, _bat_count, _data);
+ new IntegerField(_property_count_offset, _property_count, _data);
new IntegerField(_property_start_offset, _property_start, _data);
new IntegerField(_sbat_start_offset, _sbat_start, _data);
new IntegerField(_sbat_block_count_offset, _sbat_count, _data);
// useful offsets
int _signature_offset = 0;
int _bat_count_offset = 0x2C;
+ int _property_count_offset = 0x28;
int _property_start_offset = 0x30;
int _sbat_start_offset = 0x3C;
int _sbat_block_count_offset = 0x40;
// Check the header has the right points in it
assertEquals(1, header.getBATCount());
assertEquals(1, header.getBATArray()[0]);
+ assertEquals(2, header.getPropertyCount());
assertEquals(0, header.getPropertyStart());
assertEquals(1, header.getSBATCount());
assertEquals(21, header.getSBATStart());
// Will have fat then properties stream
assertEquals(1, hdr.getBATCount());
assertEquals(1, hdr.getBATArray()[0]);
+ assertEquals(1, hdr.getPropertyCount());
assertEquals(0, hdr.getPropertyStart());
assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getSBATStart());
assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getXBATIndex());
assertEquals(1, hdr.getBATCount());
assertEquals(1, hdr.getBATArray()[0]);
assertEquals(2, hdr.getSBATStart());
+ assertEquals(2, hdr.getPropertyCount());
assertEquals(0, hdr.getPropertyStart());
assertEquals(POIFSConstants.END_OF_CHAIN, hdr.getXBATIndex());
void testConstructors() throws IOException {
String[] hexData = {
"D0 CF 11 E0 A1 B1 1A E1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 00 03 00 FE FF 09 00",
- "06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FE FF FF FF 00 00 00 00 00 10 00 00 FE FF FF FF",
+ "06 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 FE FF FF FF 00 00 00 00 00 10 00 00 FE FF FF FF",
"01 00 00 00 FE FF FF FF 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
byte[] content = RawDataUtil.decode(hexData);
HeaderBlock block = new HeaderBlock(new ByteArrayInputStream(content));
+ assertEquals(1, block.getPropertyCount());
assertEquals(-2, block.getPropertyStart());
// verify we can't read a short block