From: <ga...@us...> - 2011-11-30 20:48:18
|
Revision: 5868 http://jnode.svn.sourceforge.net/jnode/?rev=5868&view=rev Author: galatnm Date: 2011-11-30 20:48:12 +0000 (Wed, 30 Nov 2011) Log Message: ----------- Clean up HFS+ Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2011-10-25 14:21:29 UTC (rev 5867) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/Catalog.java 2011-11-30 20:48:12 UTC (rev 5868) @@ -249,9 +249,10 @@ int nodeSize = getBTHeaderRecord().getNodeSize(); ByteBuffer nodeData = ByteBuffer.allocate(nodeSize); fs.getApi().read(catalogHeaderNodeOffset + (currentNodeNumber * nodeSize), nodeData); - NodeDescriptor nd = new NodeDescriptor(nodeData.array(), 0); + byte[] datas = nodeData.array(); + NodeDescriptor nd = new NodeDescriptor(datas, 0); if (nd.isIndexNode()) { - CatalogIndexNode node = new CatalogIndexNode(nodeData.array(), nodeSize); + CatalogIndexNode node = new CatalogIndexNode(datas, nodeSize); IndexRecord[] records = (IndexRecord[]) node.findAll(parentID); List<LeafRecord> lfList = new LinkedList<LeafRecord>(); for (IndexRecord rec : records) { @@ -291,7 +292,7 @@ CatalogKey cKey = new CatalogKey(parentID, nodeName); while (nd.isIndexNode()) { CatalogIndexNode node = new CatalogIndexNode(nodeData.array(), nodeSize); - IndexRecord record = (IndexRecord) node.find(cKey); + IndexRecord record = node.find(cKey); currentNodeNumber = record.getIndex(); currentOffset = catalogHeaderNodeOffset + record.getIndex() * nodeSize; nodeData = ByteBuffer.allocate(nodeSize); @@ -301,7 +302,7 @@ LeafRecord lr = null; if (nd.isLeafNode()) { CatalogLeafNode node = new CatalogLeafNode(nodeData.array(), nodeSize); - lr = (LeafRecord) node.find(parentID); + lr = node.find(parentID); } return lr; } Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java 2011-10-25 14:21:29 UTC (rev 5867) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogLeafNode.java 2011-11-30 20:48:12 UTC (rev 5868) @@ -3,77 +3,78 @@ import java.util.LinkedList; import java.util.List; +import org.apache.log4j.Logger; import org.jnode.fs.hfsplus.tree.AbstractNode; -import org.jnode.fs.hfsplus.tree.Key; import org.jnode.fs.hfsplus.tree.LeafRecord; import org.jnode.fs.hfsplus.tree.NodeDescriptor; -import org.jnode.fs.hfsplus.tree.NodeRecord; public class CatalogLeafNode extends AbstractNode<LeafRecord> { - /** - * Create a new node. - * - * @param descriptor - * @param nodeSize - */ - public CatalogLeafNode(NodeDescriptor descriptor, final int nodeSize) { - super(descriptor, nodeSize); - } - /** - * Create node from existing data. - * - * @param nodeData - * @param nodeSize - */ - public CatalogLeafNode(final byte[] nodeData, final int nodeSize) { - super(nodeData, nodeSize); + private final Logger log = Logger.getLogger(getClass()); - } + /** + * Create a new node. + * + * @param descriptor + * @param nodeSize + */ + public CatalogLeafNode(NodeDescriptor descriptor, final int nodeSize) { + super(descriptor, nodeSize); + } - @Override - protected void loadRecords(byte[] nodeData) { - CatalogKey key; - int offset; - for (int i = 0; i < this.descriptor.getNumRecords(); i++) { - offset = offsets.get(i); - key = new CatalogKey(nodeData, offset); - int recordSize = offsets.get(i + 1) - offset; - records.add(new LeafRecord(key, nodeData, offset, recordSize)); - } - } + /** + * Create node from existing data. + * + * @param nodeData + * @param nodeSize + */ + public CatalogLeafNode(final byte[] nodeData, final int nodeSize) { + super(nodeData, nodeSize); - /** - * @param parentId - * @return a NodeRecord or {@code null} - */ - public final LeafRecord find(final CatalogNodeId parentId) { - for (LeafRecord record : records) { - Key key = record.getKey(); - if (key instanceof CatalogKey) { - if (((CatalogKey) key).getParentId().getId() == parentId.getId()) { - return record; - } - } - } - return null; - } + } - /** - * @param parentId - * @return an array of NodeRecords - */ - public final LeafRecord[] findAll(final CatalogNodeId parentId) { - List<NodeRecord> list = new LinkedList<NodeRecord>(); - for (int index = 0; index < this.getNodeDescriptor().getNumRecords(); index++) { - NodeRecord record = this.getNodeRecord(index); - Key key = record.getKey(); - if (key instanceof CatalogKey && - ((CatalogKey) key).getParentId().getId() == parentId.getId()) { - list.add(record); - } - } - return list.toArray(new LeafRecord[list.size()]); - } + @Override + protected void loadRecords(byte[] nodeData) { + CatalogKey key; + int offset; + for (int i = 0; i < this.descriptor.getNumRecords(); i++) { + offset = offsets.get(i); + key = new CatalogKey(nodeData, offset); + int recordSize = offsets.get(i + 1) - offset; + records.add(new LeafRecord(key, nodeData, offset, recordSize)); + } + } + /** + * @param parentId + * @return a NodeRecord or {@code null} + */ + public final LeafRecord find(final CatalogNodeId parentId) { + for (LeafRecord record : records) { + log.debug("Record : " + record.toString() + " Parent ID : " + parentId.getId()); + CatalogKey key = (CatalogKey) record.getKey(); + if (key.getParentId().getId() == parentId.getId()) { + return record; + } + } + return null; + } + + /** + * @param parentId + * @return an array of NodeRecords + */ + public final LeafRecord[] findAll(final CatalogNodeId parentId) { + List<LeafRecord> list = new LinkedList<LeafRecord>(); + for (int index = 0; index < this.getNodeDescriptor().getNumRecords(); index++) { + LeafRecord record = this.getNodeRecord(index); + log.debug("Record : " + record.toString() + " Parent ID : " + parentId.getId()); + CatalogKey key = (CatalogKey) record.getKey(); + if (key.getParentId().getId() == parentId.getId()) { + list.add(record); + } + } + return list.toArray(new LeafRecord[list.size()]); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |