From: <ga...@us...> - 2009-02-09 15:42:48
|
Revision: 5014 http://jnode.svn.sourceforge.net/jnode/?rev=5014&view=rev Author: galatnm Date: 2009-02-09 15:42:45 +0000 (Mon, 09 Feb 2009) Log Message: ----------- Simplify compare method. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2009-02-09 15:41:40 UTC (rev 5013) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2009-02-09 15:42:45 UTC (rev 5014) @@ -53,9 +53,11 @@ } /** + * Create catalog key based on parent CNID and the name of the file or folder. * - * @param parentID - * @param name + * @param parentID Parent catalog node identifier. + * @param name Name of the file or folder. + * */ public CatalogKey(final CatalogNodeId parentID, final HFSUnicodeString name) { this.parentID = parentID; @@ -75,22 +77,30 @@ return nodeName; } - public final int compareTo(final Key o) { - if (o instanceof CatalogKey) { - CatalogKey ck = (CatalogKey) o; - if (getParentId().getId() == ck.getParentId().getId()) { - return nodeName.getUnicodeString().compareTo( + /** + * Compare two catalog keys. These keys are compared by parent id and next + * by node name. + * + * @param key + * + */ + public final int compareTo(final Key key) { + int res = -1; + if (key instanceof CatalogKey) { + CatalogKey ck = (CatalogKey) key; + res = this.getParentId().compareTo(ck.getParentId()); + if (res == 0) { + res = this.getNodeName().getUnicodeString().compareTo( ck.getNodeName().getUnicodeString()); - } else if (getParentId().getId() < ck.getParentId().getId()) { - return -1; - } else { - return 1; } - } else { - return -1; } + return res; } + /* + * (non-Javadoc) + * @see org.jnode.fs.hfsplus.tree.AbstractKey#getBytes() + */ public byte[] getBytes() { byte[] data = new byte[this.getKeyLength()]; BigEndian.setInt16(data, 0, this.getKeyLength()); @@ -99,6 +109,10 @@ return data; } + /* + * (non-Javadoc) + * @see java.lang.Object#toString() + */ public final String toString() { StringBuffer s = new StringBuffer(); s.append("[length, Parent ID, Node name]:").append(getKeyLength()).append(",").append(getParentId().getId()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ga...@us...> - 2011-11-30 20:49:04
|
Revision: 5869 http://jnode.svn.sourceforge.net/jnode/?rev=5869&view=rev Author: galatnm Date: 2011-11-30 20:48:58 +0000 (Wed, 30 Nov 2011) Log Message: ----------- Fix HFS+ catalog key from luke. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2011-11-30 20:48:12 UTC (rev 5868) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2011-11-30 20:48:58 UTC (rev 5869) @@ -44,11 +44,12 @@ * @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); - keyLength = BigEndian.getInt16(ck, 0); + keyLength = BigEndian.getInt16(ck, 0) + 2; // Key length doesn't seem to include itself in the size currentOffset += 2; ck = new byte[4]; System.arraycopy(src, currentOffset, ck, 0, 4); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ga...@us...> - 2011-12-14 12:19:47
|
Revision: 5877 http://jnode.svn.sourceforge.net/jnode/?rev=5877&view=rev Author: galatnm Date: 2011-12-14 12:19:38 +0000 (Wed, 14 Dec 2011) Log Message: ----------- FS : Improve HFS catalog key javadocs. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2011-12-12 16:09:48 UTC (rev 5876) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2011-12-14 12:19:38 UTC (rev 5877) @@ -17,7 +17,7 @@ * along with this library; If not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ - + package org.jnode.fs.hfsplus.catalog; import org.jnode.fs.hfsplus.HfsUnicodeString; @@ -25,6 +25,17 @@ import org.jnode.fs.hfsplus.tree.Key; import org.jnode.util.BigEndian; +/** + * Implementation of catalog file key. The catalog file key is defined as following : + * <ul> + * <li>The length of the key</li> + * <li>The node identifier of the parent folder</li> + * <li>The name of the file or folder</li> + * </ul> + * + * The minimal length for a key is 6 bytes. 2 bytes for the length and 4 bytes for the catalog node id. + * + */ public class CatalogKey extends AbstractKey { public static final int MINIMUM_KEY_LENGTH = 6; @@ -44,7 +55,7 @@ * @param src * @param offset */ - + public CatalogKey(final byte[] src, final int offset) { int currentOffset = offset; byte[] ck = new byte[2]; @@ -96,8 +107,8 @@ res = this.getParentId().compareTo(ck.getParentId()); if (res == 0) { res = - this.getNodeName().getUnicodeString().compareTo( - ck.getNodeName().getUnicodeString()); + this.getNodeName().getUnicodeString() + .compareTo(ck.getNodeName().getUnicodeString()); } } return res; @@ -109,11 +120,11 @@ * @see org.jnode.fs.hfsplus.tree.AbstractKey#getBytes() */ public byte[] getBytes() { - int length = this.getKeyLength(); + 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); + System.arraycopy(nodeName.getBytes(), 0, data, 6, (nodeName.getLength() * 2) + 2); return data; } @@ -124,9 +135,9 @@ */ public final String toString() { StringBuffer s = new StringBuffer(); - s.append("[length, Parent ID, Node name]:").append(getKeyLength()).append(",").append( - getParentId().getId()).append(",").append( - (getNodeName() != null) ? getNodeName().getUnicodeString() : ""); + s.append("[length, Parent ID, Node name]:").append(getKeyLength()).append(",") + .append(getParentId().getId()).append(",") + .append((getNodeName() != null) ? getNodeName().getUnicodeString() : ""); return s.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ga...@us...> - 2011-12-15 09:58:27
|
Revision: 5878 http://jnode.svn.sourceforge.net/jnode/?rev=5878&view=rev Author: galatnm Date: 2011-12-15 09:58:16 +0000 (Thu, 15 Dec 2011) Log Message: ----------- FS : HFS+ catalog key temporary fix to avoid record data shift. Modified Paths: -------------- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java Modified: trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2011-12-14 12:19:38 UTC (rev 5877) +++ trunk/fs/src/fs/org/jnode/fs/hfsplus/catalog/CatalogKey.java 2011-12-15 09:58:16 UTC (rev 5878) @@ -60,7 +60,8 @@ int currentOffset = offset; byte[] ck = new byte[2]; System.arraycopy(src, currentOffset, ck, 0, 2); - keyLength = BigEndian.getInt16(ck, 0); + //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); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |