Package org.owasp.dependencycheck.org.apache.tools.ant

Examples of org.owasp.dependencycheck.org.apache.tools.ant.DirectoryScanner


    /**
     * Testing the expected use of the directory scanner.
     */
    @Test
    public void testExpectedUse() {
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir("./target");
        scanner.setIncludes("/test-classes/**");
        scanner.scan();

        File base = new File("./target");
        for (String t : scanner.getIncludedFiles()) {
            assertTrue(t.startsWith("test-classes"));
            File test = new File(base, t);
            assertTrue(test.exists());
        }
    }
View Full Code Here


                antStylePaths = Arrays.asList(files);
            }

            final Set<File> paths = new HashSet<File>();
            for (String file : antStylePaths) {
                final DirectoryScanner scanner = new DirectoryScanner();
                String include = file.replace('\\', '/');
                File baseDir;

                if (include.startsWith("//")) {
                    throw new InvalidScanPathException("Unable to scan paths specified by //");
                } else if (include.startsWith("./")) {
                    baseDir = new File(".");
                    include = include.substring(2);
                } else if (include.startsWith("/")) {
                    baseDir = new File("/");
                    include = include.substring(1);
                } else if (include.contains("/")) {
                    final int pos = include.indexOf('/');
                    final String tmp = include.substring(0, pos);
                    if (tmp.contains("*") || tmp.contains("?")) {
                        baseDir = new File(".");
                    } else {
                        baseDir = new File(tmp);
                        include = include.substring(pos + 1);
                    }
                } else { //no path info - must just be a file in the working directory
                    baseDir = new File(".");
                }
                scanner.setBasedir(baseDir);
                scanner.setIncludes(include);
                if (excludes != null && excludes.length > 0) {
                    scanner.addExcludes(excludes);
                }
                scanner.scan();
                if (scanner.getIncludedFilesCount() > 0) {
                    for (String s : scanner.getIncludedFiles()) {
                        final File f = new File(baseDir, s);
                        paths.add(f);
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.owasp.dependencycheck.org.apache.tools.ant.DirectoryScanner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.