// @Override me public DataOutput write(DataOutput out) throws Exception { int total = (this instanceof Zone64) ? Zone64.SIZE : Zone32.SIZE; for (int i = 0; i < num; i++) { out.writeInt(ints[i]); total += Utils.SIZEOF_INT; } for (int i = 0; i < num; i++) { bitmaps[i].write(out); total += bitmaps[i].getReadAheadSize() + bitmaps[i].getReadSize(); } if (extra != null) out.write(extra); else { int extraSize = (int) Utils.blocksToBytes(getDescriptorSize()) - total; while (extraSize-- > 0) out.writeByte(0xAA); } return out; }
private Zone addZone(Mfs mfs, long logicalStartBlock, SizeSet sizes, long chunkSize) throws Exception { if ((mfs == null) || (mfs.getMfs() == null)) throw new Exception("No MFS - MFS has not been initialized"); List<Zone> zones = mfs.getZones(); if ((zones == null) || zones.isEmpty()) throw new Exception("No Zones - MFS has not been initialized"); Zone lastZone = zones.get(zones.size() - 1); int baseFsPointer = lastZone.getInts()[0] - (int) lastZone.getNum() * Utils.SIZEOF_INT + (int) Utils.blocksToBytes(lastZone.getDescriptorSize() + 1) + 160; Zone64 z = new Zone64( logicalStartBlock, // descriptor start logicalStartBlock + sizes.partition, // data start sizes.data, // data size chunkSize, baseFsPointer); z.setType(ZoneType.MEDIA); ZoneHeader lastNext = lastZone.getNext(); /* just put the next pointer indicating the end into the new zone and fill the previous next with pointers to the new zone */ z.setNext(lastNext); lastZone.setNext(z.getHeader()); mfs.addZone(z); return z; }