Browse Source

keep track of links that haven't been followed

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@713626 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
5f7fbe8b73
1 changed files with 36 additions and 0 deletions
  1. +36
    -0
      src/main/org/apache/tools/ant/DirectoryScanner.java

+ 36
- 0
src/main/org/apache/tools/ant/DirectoryScanner.java View File

@@ -395,6 +395,16 @@ public class DirectoryScanner
*/ */
private int maxLevelsOfSymlinks = MAX_LEVELS_OF_SYMLINKS; 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. * Sole constructor.
*/ */
@@ -827,6 +837,7 @@ public class DirectoryScanner


if (basedir != null && !followSymlinks if (basedir != null && !followSymlinks
&& SYMLINK_UTILS.isSymbolicLink(basedir)) { && SYMLINK_UTILS.isSymbolicLink(basedir)) {
notFollowedSymlinks.add(basedir.getAbsolutePath());
basedir = null; basedir = null;
} }


@@ -979,6 +990,9 @@ public class DirectoryScanner


if (myfile != null && myfile.exists()) { if (myfile != null && myfile.exists()) {
if (!followSymlinks && currentPath.isSymlink(basedir)) { if (!followSymlinks && currentPath.isSymlink(basedir)) {
if (!isExcluded(currentPath)) {
notFollowedSymlinks.add(myfile.getAbsolutePath());
}
continue; continue;
} }
if (myfile.isDirectory()) { if (myfile.isDirectory()) {
@@ -1038,6 +1052,7 @@ public class DirectoryScanner
dirsDeselected = new VectorSet(); dirsDeselected = new VectorSet();
everythingIncluded = (basedir != null); everythingIncluded = (basedir != null);
scannedDirs.clear(); scannedDirs.clear();
notFollowedSymlinks.clear();
} }


/** /**
@@ -1187,6 +1202,9 @@ public class DirectoryScanner
File file = new File(dir, newfiles[i]); File file = new File(dir, newfiles[i]);
(file.isDirectory() (file.isDirectory()
? dirsExcluded : filesExcluded).addElement(name); ? dirsExcluded : filesExcluded).addElement(name);
if (!isExcluded(name)) {
notFollowedSymlinks.add(file.getAbsolutePath());
}
} else { } else {
noLinks.add(newfiles[i]); noLinks.add(newfiles[i]);
} }
@@ -1225,6 +1243,7 @@ public class DirectoryScanner
+ file.getAbsolutePath() + file.getAbsolutePath()
+ " -- too many levels of symbolic" + " -- too many levels of symbolic"
+ " links."); + " links.");
notFollowedSymlinks.add(file.getAbsolutePath());
continue; continue;
} }


@@ -1675,6 +1694,23 @@ public class DirectoryScanner
return directories; return directories;
} }


/**
* 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. * Add default exclusions to the current exclusions set.
*/ */


Loading…
Cancel
Save