Author: bodewig
Date: Wed Nov 12 19:50:53 2008
New Revision: 713626
URL: http://svn.apache.org/viewvc?rev=713626&view=rev
Log:
keep track of links that haven't been followed
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java?rev=713626&r1=713625&r2=713626&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java Wed Nov
12 19:50:53 2008
@@ -395,6 +395,16 @@
*/
private int maxLevelsOfSymlinks = MAX_LEVELS_OF_SYMLINKS;
+
+ /**
+ * Absolute paths of all symlinks that haven't been followed but
+ * would have been if followsymlinks had been true or
+ * maxLevelsOfSymlinks had been higher.
+ *
+ * @since Ant 1.8.0
+ */
+ private Set/*<String>*/ notFollowedSymlinks = new HashSet();
+
/**
* Sole constructor.
*/
@@ -827,6 +837,7 @@
if (basedir != null && !followSymlinks
&& SYMLINK_UTILS.isSymbolicLink(basedir)) {
+ notFollowedSymlinks.add(basedir.getAbsolutePath());
basedir = null;
}
@@ -979,6 +990,9 @@
if (myfile != null && myfile.exists()) {
if (!followSymlinks && currentPath.isSymlink(basedir)) {
+ if (!isExcluded(currentPath)) {
+ notFollowedSymlinks.add(myfile.getAbsolutePath());
+ }
continue;
}
if (myfile.isDirectory()) {
@@ -1038,6 +1052,7 @@
dirsDeselected = new VectorSet();
everythingIncluded = (basedir != null);
scannedDirs.clear();
+ notFollowedSymlinks.clear();
}
/**
@@ -1187,6 +1202,9 @@
File file = new File(dir, newfiles[i]);
(file.isDirectory()
? dirsExcluded : filesExcluded).addElement(name);
+ if (!isExcluded(name)) {
+ notFollowedSymlinks.add(file.getAbsolutePath());
+ }
} else {
noLinks.add(newfiles[i]);
}
@@ -1225,6 +1243,7 @@
+ file.getAbsolutePath()
+ " -- too many levels of symbolic"
+ " links.");
+ notFollowedSymlinks.add(file.getAbsolutePath());
continue;
}
@@ -1676,6 +1695,23 @@
}
/**
+ * Absolute paths of all symbolic links that haven't been followed
+ * but would have been followed had followsymlinks been true or
+ * maxLevelsOfSymlinks been bigger.
+ *
+ * @since Ant 1.8.0
+ */
+ public synchronized String[] getNotFollowedSymlinks() {
+ String[] links;
+ synchronized (this) {
+ links = (String[]) notFollowedSymlinks
+ .toArray(new String[notFollowedSymlinks.size()]);
+ }
+ Arrays.sort(links);
+ return links;
+ }
+
+ /**
* Add default exclusions to the current exclusions set.
*/
public synchronized void addDefaultExcludes() {