|
From: <caw...@us...> - 2006-12-01 05:09:15
|
Revision: 1677
http://svn.sourceforge.net/rubyeclipse/?rev=1677&view=rev
Author: cawilliams
Date: 2006-11-30 21:09:13 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
add code to avoid falling into an infinite loop because of recursive symlinks when traversing for ruby files
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java 2006-12-01 00:55:02 UTC (rev 1676)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java 2006-12-01 05:09:13 UTC (rev 1677)
@@ -11,6 +11,8 @@
package org.rubypeople.rdt.internal.core.builder;
+import java.io.IOException;
+import java.util.HashSet;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -18,6 +20,7 @@
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
@@ -25,9 +28,11 @@
private static final String RUBY_SOURCE_CONTENT_TYPE_ID = "org.rubypeople.rdt.core.rubySource";
private final List files;
+ private HashSet<String> visitedLinks;
public RubySourceFileCollectingVisitor(List files) {
this.files = files;
+ this.visitedLinks = new HashSet<String>();
}
public boolean visit(IResourceProxy proxy) throws CoreException {
@@ -50,6 +55,18 @@
files.add(resource);
}
return false;
+ case IResource.FOLDER:
+ try { // Avoid recursive symlinks!
+ IPath path = proxy.requestResource().getLocation();
+ String unique = path.toFile().getCanonicalPath();
+ if (visitedLinks.contains(unique))
+ return false;
+ visitedLinks.add(unique);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ }
}
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|