Esempio n. 1
0
 /** @return the thread encoded as data */
 public byte[] getBytes() {
   byte[] data = new byte[512];
   BigEndian.setInt16(data, 0, recordType);
   BigEndian.setInt32(data, 4, (int) parentId.getId());
   System.arraycopy(parentId.getBytes(), 0, data, 4, 4);
   System.arraycopy(nodeName.getBytes(), 0, data, 8, nodeName.getBytes().length);
   return data;
 }
Esempio n. 2
0
 /**
  * Create catalog thread from existing data.
  *
  * @param src byte array contains catalog thread data.
  */
 public CatalogThread(final byte[] src) {
   byte[] data = new byte[512];
   System.arraycopy(src, 0, data, 0, CATALOG_THREAD_SIZE);
   recordType = BigEndian.getInt16(data, 0);
   parentId = new CatalogNodeId(data, 4);
   nodeName = new HfsUnicodeString(data, 8);
 }
Esempio n. 3
0
 /*
  * (non-Javadoc)
  *
  * @see org.jnode.fs.hfsplus.tree.AbstractKey#getBytes()
  */
 public byte[] getBytes() {
   int length = this.getKeyLength();
   byte[] data = new byte[length];
   BigEndian.setInt16(data, 0, length);
   System.arraycopy(parentId.getBytes(), 0, data, 2, 4);
   System.arraycopy(nodeName.getBytes(), 0, data, 6, (nodeName.getLength() * 2) + 2);
   return data;
 }
Esempio n. 4
0
 /**
  * Create catalog key from existing data.
  *
  * @param src
  * @param offset
  */
 public CatalogKey(final byte[] src, final int offset) {
   int currentOffset = offset;
   byte[] ck = new byte[2];
   System.arraycopy(src, currentOffset, ck, 0, 2);
   // TODO Understand why the +2 is necessary
   keyLength = BigEndian.getInt16(ck, 0) + 2;
   currentOffset += 2;
   ck = new byte[4];
   System.arraycopy(src, currentOffset, ck, 0, 4);
   parentId = new CatalogNodeId(ck, 0);
   currentOffset += 4;
   if (keyLength > MINIMUM_KEY_LENGTH) {
     nodeName = new HfsUnicodeString(src, currentOffset);
   }
 }