Do we have to traverse a symlink when trying to reach path from
basedir?
@param base base File (dir).
@param pathElements Vector of path elements (dirs...file).
@since Ant 1.6
343915
private boolean isSymlink(File base, Vector pathElements) {
        if (pathElements.size() > 0) {
            String current = (String) pathElements.remove(0);
            try {
                return FileUtil.isSymbolicLink(base, current)
                    || isSymlink(new File(base, current), pathElements);
            } catch (IOException ioe) {
                String msg = "IOException caught while checking "
                    + "for links, couldn't get canonical path!";
                // will be caught and redirected to Ant's logging system
                System.err.println(msg);
            }
        }
        return false;
    }
1144274
B append(BasePath<B> path) {
    ImmutableList.Builder<String> components = ImmutableList.builder();
    components.addAll(this.getSegments());
    components.addAll(path.getSegments());
    return createPathWithSegments(components.build());
  }
602451
public void setBaseEndpointDnsNames(java.util.Collection<String> baseEndpointDnsNames) {
        if (baseEndpointDnsNames == null) {
            this.baseEndpointDnsNames = null;
            return;
        }

        this.baseEndpointDnsNames = new com.amazonaws.internal.SdkInternalList<String>(baseEndpointDnsNames);
    }
746035
public static void walkFileSystem(File base, Closure action) {

        List<FileWalkState> m_states = new ArrayList<FileWalkState>();
        m_states.add(createFileWalkState(base));
        while (!m_states.isEmpty()) {
            // pop the top off the state stack, process it, then push states for all subdirectories onto it
            FileWalkState last = m_states.remove(m_states.size() - 1);
            action.execute(last);
            for (File dir : last.getDirectories()) {
                m_states.add(createFileWalkState(dir));
            }
        }
    }
377283
public void setNestedPath(final String nestedPath) {
        final String canonicalPath = normalizePath(nestedPath);
        this.nestedPathStack.clear();
        if(canonicalPath.isEmpty()) {
            this.currentPath = buildPath();
        } else {
            pushNestedPath(canonicalPath);
        }
    }
830853
private static void setupPaths( PathsType paths) {
        File voltDbRoot;
        // Handles default voltdbroot (and completely missing "paths" element).
        voltDbRoot = getVoltDbRoot(paths);
        //Snapshot
        setupSnapshotPaths(paths.getSnapshots(), voltDbRoot);
        //export overflow
        setupExportOverflow(paths.getExportoverflow(), voltDbRoot);
        // only use these directories in the enterprise version
        setupCommandLog(paths.getCommandlog(), voltDbRoot);
        setupCommandLogSnapshot(paths.getCommandlogsnapshot(), voltDbRoot);
        setupDROverflow(paths.getDroverflow(), voltDbRoot);
        setupLargeQuerySwap(paths.getLargequeryswap(), voltDbRoot);
    }
354036
private function setPaths($baseDirectory)
    {
        $this->setOption('ROOT', rtrim($baseDirectory, '/') . '/');
        $this->setOption('CORE', dirname(dirname(dirname(__DIR__))) . '/');
        $this->setOption('PUBLIC', self::ROOT() . 'public/');
        $this->setOption('TEMPLATES', self::ROOT() . 'templates/');
        $this->setOption('MODULES', self::ROOT() . 'modules/');
        $this->setOption('PLUGINS', self::ROOT() . 'plugins/');
        $this->setOption('COMPONENTS', self::ROOT() . 'components/');
    }
1264847
public void add(MultiPathImpl src, boolean bReversePaths) {
		for (int i = 0; i < src.getPathCount(); i++)
			addPath(src, i, !bReversePaths);
	}
829696
public void addPathElement(QPathEntry element) {
       if (relPath == null)
          this.relPath = new QPath(new QPathEntry[]{element});
       else
          this.relPath = QPath.makeChildPath(relPath, element, element.getIndex());
    }
347196
public static void setBaseDirectory(@NonNull File f){
        Preconditions.checkState(f.exists() && f.isDirectory(), "Specified base directory does not exist and/or is not a directory: %s", f.getAbsolutePath());
        baseDirectory = f;
    }
1220443
function (pathElements) {
            var configuration = this.$restHandler.$resourceConfiguration,
                parentResourceHandler = null,
                resourceStack = [],
                i;

            // build a stack of configurations
            for (i = 0; i < pathElements.length; i += 2) {
                var path = decodeURIComponent(pathElements[i]);
                configuration = configuration.getConfigurationForPath(path);

                if (!configuration) {
                    throw new HttpError("Configuration for '" + pathElements.slice(0, i + 1).join('/') + "' not found.", 404);
                }

                if (this.$restHandler.$modelClassResourceHandler[configuration.$.modelClassName]) {
                    configuration.$.resourceHandler = this.$restHandler.$modelClassResourceHandler[configuration.$.modelClassName];
                }

                if (!configuration.$.resourceHandler) {
                    // no resource handler assigned to resource, use a default resource handler
                    configuration.$.resourceHandler = new ResourceHandler();
                }

                var id = pathElements[i + 1];

                if (id) {
                    id = decodeURIComponent(id);
                }

                resourceStack.push({
                    resourceHandler: configuration.$.resourceHandler,
                    configuration: configuration,
                    id: id
                });

            }

            for (i = 0; i < resourceStack.length; i++) {
                var resourceEntry = resourceStack[i],
                    resourceHandler = resourceEntry.resourceHandler;

                // clone or get same instance
                resourceHandler = resourceHandler.getResourceHandlerInstance();

                // initialize handler
                resourceHandler.init(this.$restHandler, resourceEntry.configuration, resourceEntry.id, parentResourceHandler);
                parentResourceHandler = resourceHandler;

                if (!(resourceHandler instanceof ResourceHandler)) {
                    throw "Returned resource not an instance of Resource";
                }
            }

            // return top mose resourceHandler
            return parentResourceHandler;

        }
512595
public void setFilePaths(Path... filePaths) {
		if (!supportsMultiPaths() && filePaths.length > 1) {
			throw new UnsupportedOperationException(
				"Multiple paths are not supported by this FileInputFormat.");
		}
		if (filePaths.length < 1) {
			throw new IllegalArgumentException("At least one file path must be specified.");
		}
		if (filePaths.length == 1) {
			// set for backwards compatibility
			this.filePath = filePaths[0];
		} else {
			// clear file path in case it had been set before
			this.filePath = null;
		}

		this.filePaths = filePaths;
	}
1045406
public static void createFileWithParentDirectories(Path path,
            FileAttribute<?>... attrs) {
        createDirectories(path.getParent(), attrs);
        createFile(path, attrs);
    }
1050608
public void setRoots(java.util.Collection<Root> roots) {
        if (roots == null) {
            this.roots = null;
            return;
        }

        this.roots = new java.util.ArrayList<Root>(roots);
    }
981809
@Override
	protected void addPaths(Set<String> paths, Collection<Map<String, Object>> commits) {
		paths.add("application.yml");
	}
406957
static public void scanRoot(File root,
                                Set<String> suffixes,
                                List<String> excludes,
                                List<String> includes,
                                Map<String,Source> foundFiles,
                                Map<String,Module> foundModules,
                                final Module currentModule,
                                boolean permitSourcesWithoutPackage,
                                boolean inGensrc,
                                boolean inLinksrc)
                                        throws IOException, ProblemException {

        if (root == null)
            return;

        FileSystem fs = root.toPath().getFileSystem();

        if (includes.isEmpty()) {
            includes = Collections.singletonList("**");
        }

        List<PathMatcher> includeMatchers = createPathMatchers(fs, includes);
        List<PathMatcher> excludeMatchers = createPathMatchers(fs, excludes);

        Files.walkFileTree(root.toPath(), new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

                Path relToRoot = root.toPath().relativize(file);

                if (includeMatchers.stream().anyMatch(im -> im.matches(relToRoot))
                        && excludeMatchers.stream().noneMatch(em -> em.matches(relToRoot))
                        && suffixes.contains(Util.fileSuffix(file))) {

                    // TODO: Test this.
                    Source existing = foundFiles.get(file);
                    if (existing != null) {
                        throw new IOException("You have already added the file "+file+" from "+existing.file().getPath());
                    }
                    existing = currentModule.lookupSource(file.toString());
                    if (existing != null) {

                            // Oups, the source is already added, could be ok, could be not, lets check.
                            if (inLinksrc) {
                                // So we are collecting sources for linking only.
                                if (existing.isLinkedOnly()) {
                                    // Ouch, this one is also for linking only. Bad.
                                    throw new IOException("You have already added the link only file " + file + " from " + existing.file().getPath());
                                }
                                // Ok, the existing source is to be compiled. Thus this link only is redundant
                                // since all compiled are also linked to. Continue to the next source.
                                // But we need to add the source, so that it will be visible to linking,
                                // if not the multi core compile will fail because a JavaCompiler cannot
                                // find the necessary dependencies for its part of the source.
                                foundFiles.put(file.toString(), existing);
                            } else {
                                // We are looking for sources to compile, if we find an existing to be compiled
                                // source with the same name, it is an internal error, since we must
                                // find the sources to be compiled before we find the sources to be linked to.
                                throw new IOException("Internal error: Double add of file " + file + " from " + existing.file().getPath());
                            }

                    } else {

                        //////////////////////////////////////////////////////////////
                        // Add source
                        Source s = new Source(currentModule, file.toString(), file.toFile());
                        if (inGensrc) {
                            s.markAsGenerated();
                        }
                        if (inLinksrc) {
                            s.markAsLinkedOnly();
                        }
                        String pkg = packageOfJavaFile(root.toPath(), file);
                        pkg = currentModule.name() + ":" + pkg;
                        foundFiles.put(file.toString(), s);
                        currentModule.addSource(pkg, s);
                        //////////////////////////////////////////////////////////////
                    }
                }

                return FileVisitResult.CONTINUE;
            }
        });
    }
1020594
static public void visitElements( XMLNode root, String path, ElementVisitor ev )
    {
        // Get last element in path
        int idx = path.lastIndexOf( '<' );
        String head = path.substring( 0, idx );
        String tag = path.substring( idx + 1, path.length() - 1 );

        XMLNode elem = findElementPath( root, head );
        if ( elem == null )
        {
            return;
        }

        // Iterate through all child nodes
        XMLNode n = elem.getNested();
        while ( n != null )
        {
            if ( n.isElement() && n.getName().equals( tag ) )
            {
                ev.visitElement( n );
            }
            n = n.getNext();
        }
    }