[EGIT PATCH v2 11/12] Expose the underlying resource entries in ContainerTreeIterator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is needed if interacting with any of the Eclipse platform
methods that take IResources as arguments.

Signed-off-by: Tor Arne Vestbø <torarnv@xxxxxxxxx>
---
 .../spearce/egit/core/ContainerTreeIterator.java   |   23 +++++++++++++++++++-
 .../src/org/spearce/jgit/treewalk/TreeWalk.java    |    9 +++++++
 2 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/ContainerTreeIterator.java b/org.spearce.egit.core/src/org/spearce/egit/core/ContainerTreeIterator.java
index 6d6b72e..2403252 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/ContainerTreeIterator.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/ContainerTreeIterator.java
@@ -106,6 +106,15 @@ public AbstractTreeIterator createSubtreeIterator(final Repository db)
 					Constants.TYPE_TREE);
 	}
 
+	/**
+	 * Get the ResourceEntry for the current entry.
+	 * 
+	 * @return the current entry
+	 */
+	public ResourceEntry getResourceEntry() {
+		return (ResourceEntry) current();
+	}
+
 	private Entry[] entries() {
 		final IResource[] all;
 		try {
@@ -120,7 +129,10 @@ public AbstractTreeIterator createSubtreeIterator(final Repository db)
 		return r;
 	}
 
-	static class ResourceEntry extends Entry {
+	/**
+	 * Wrapper for a resource in the Eclipse workspace
+	 */
+	static public class ResourceEntry extends Entry {
 		final IResource rsrc;
 
 		private final FileMode mode;
@@ -195,6 +207,15 @@ public InputStream openInputStream() throws IOException {
 			throw new IOException("Not a regular file: " + rsrc);
 		}
 
+		/**
+		 * Get the underlying resource of this entry.
+		 * 
+		 * @return the underlying resource
+		 */
+		public IResource getResource() {
+			return rsrc;
+		}
+
 		private File asFile() {
 			return ((IFile) rsrc).getLocation().toFile();
 		}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
index 189fc86..ce247f2 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java
@@ -739,6 +739,15 @@ public int isPathPrefix(final byte[] p, final int pLen) {
 	}
 
 	/**
+	 * Get the current subtree depth of this walker.
+	 * 
+	 * @return the current subtree depth of this walker.
+	 */
+	public int getDepth() {
+		return depth;
+	}
+
+	/**
 	 * Is the current entry a subtree?
 	 * <p>
 	 * This method is faster then testing the raw mode bits of all trees to see
-- 
1.6.1.2.309.g2ea3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux