DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{"**/*.java"}); scanner.setBasedir("C:/Temp"); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles();
private boolean hasMatch(File dir, String pattern, boolean bCaseSensitive) throws InterruptedException { class Cancel extends RuntimeException {} DirectoryScanner ds = bound == Integer.MAX_VALUE ? new DirectoryScanner() : new DirectoryScanner() { int ticks; long start = System.currentTimeMillis(); @Override public synchronized boolean isCaseSensitive() { if (!filesIncluded.isEmpty() || !dirsIncluded.isEmpty() || ticks++ > bound || System.currentTimeMillis() - start > 5000) { throw new Cancel(); } filesNotIncluded.clear(); dirsNotIncluded.clear(); // notFollowedSymlinks might be large, but probably unusual // scannedDirs will typically be largish, but seems to be needed return super.isCaseSensitive(); } }; ds.setBasedir(reading(dir)); ds.setIncludes(new String[] {pattern}); ds.setCaseSensitive(bCaseSensitive); try { ds.scan(); } catch (Cancel c) { if (ds.getIncludedFilesCount()!=0 || ds.getIncludedDirsCount()!=0) { return true; } else { throw new InterruptedException("no matches found within " + bound); } } return ds.getIncludedFilesCount()!=0 || ds.getIncludedDirsCount()!=0; }
ds.setCaseSensitive(false); ds.setIncludes(new String[] { "**/index.html", "**/index.htm", "**/toc.html", "**/toc.htm"
private synchronized void ensureDirectoryScannerSetup() { dieOnCircularReference(); if (ds == null) { ds = new DirectoryScanner(); PatternSet ps = mergePatterns(getProject()); ds.setIncludes(ps.getIncludePatterns(getProject())); ds.setExcludes(ps.getExcludePatterns(getProject())); ds.setSelectors(getSelectors(getProject())); if (useDefaultExcludes) { ds.addDefaultExcludes(); } ds.setCaseSensitive(caseSensitive); ds.setFollowSymlinks(followSymlinks); } }
logs = new ArrayList<File>(); String basedir = "/logs/xxx/production/jboss"; String[] include = {"pvmk*/xxx-production-zzzzz*/xxx-production-zzzzz*-XXX-Metrics.log"}; System.out.println(new Timestamp(System.currentTimeMillis())); System.out.println("Reading files..."); DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(include); scanner.setBasedir(basedir); scanner.setCaseSensitive( true ); scanner.scan(); String[] files = scanner.getIncludedFiles(); for (String file : files) { System.out.println("Loading file: " + file ); File log; log = new File(new String ("/logs/xxx/production/jboss/" + file)); logs.add(log); }
private List<String> fetchPropertyFiles(File targetDirectory, TaskListener listener) { List<String> propertyFiles = new ArrayList<>(); if (StringUtils.isNotEmpty(classificationsFilePattern)) { DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{classificationsFilePattern}); scanner.setBasedir(targetDirectory); scanner.setCaseSensitive(false); scanner.scan(); propertyFiles = getFullMetaDataPath(scanner.getIncludedFiles(), targetDirectory.toString()); for (String propertyFile : propertyFiles) { log(listener, String.format("Found Properties File - %s ", propertyFile)); } } return propertyFiles; }
private void parseReportIn(final String baseDir, final FauxPasReportParser parser) { DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{reportPath()}); scanner.setBasedir(baseDir); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); for (String filename : files) { LOGGER.info("Processing FauxPas report {}", filename); parser.parseReport(new File(filename)); } }
/** * Configures the scanner and runs the scan. * * @param scanner the scanner to configure and run the scan. */ protected void configureAndScan(final DirectoryScanner scanner) { scanner.setCaseSensitive(true); scanner.setIncludes(includes); scanner.setExcludes(excludes); scanner.scan(); }
DirectoryScanner scanner = new DirectoryScanner(); if (!inputPath.startsWith("/") || inputPath.startsWith(".")) { scanner.setBasedir("."); } scanner.setIncludes(new String[]{inputPath}); scanner.setCaseSensitive(false); scanner.scan(); String[] foundFiles = scanner.getIncludedFiles();
DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{"**/myfile*.txt"}); scanner.setBasedir("C:/Temp"); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles();
DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{"**/*.txt"}); scanner.setBasedir("C:\\Files"); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles();
DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{"**/*.java"}); scanner.setBasedir("C:/Temp"); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles();
public FilePath[] invoke(File f, VirtualChannel channel) throws IOException { FilePath base = new FilePath(f); ArrayList<FilePath> localDirectoryPaths= new ArrayList<>(); String[] includes = input.split(DIR_SEP); DirectoryScanner ds = new DirectoryScanner(); ds.setIncludes(includes); ds.setCaseSensitive(false); ds.setBasedir(f); ds.scan(); String[] dirs = ds.getIncludedDirectories(); for (String dir : dirs) { localDirectoryPaths.add(base.child(dir)); } FilePath[] lfp = {};//trick to have an empty array as a parameter, so the returned array will contain the elements return localDirectoryPaths.toArray(lfp); }
private String[] getFiles(File container) { DirectoryScanner ds; if (container.isDirectory()) { ds = new DirectoryScanner(); if (log.isDebugEnabled()) { log.debug("Scanning directory for sql files: " + container.getAbsolutePath()); } } else { ds = new ZipScanner(); if (log.isDebugEnabled()) { log.debug("Scanning zip file for sql files: " + container.getAbsolutePath()); } } ds.setIncludes(getArray(include)); ds.setExcludes(getArray(exclude)); if (ds instanceof ZipScanner) { ((ZipScanner) ds).setSrc(container); } else { ds.setBasedir(container); } ds.setCaseSensitive(true); ds.scan(); String[] files = ds.getIncludedFiles(); return files; }
private String[] getFiles(File container) { DirectoryScanner ds; if (container.isDirectory()) { ds = new DirectoryScanner(); if (log.isDebugEnabled()) { log.debug("Scanning directory for sql files: " + container.getAbsolutePath()); } } else { ds = new ZipScanner(); if (log.isDebugEnabled()) { log.debug("Scanning zip file for sql files: " + container.getAbsolutePath()); } } ds.setIncludes(getArray(include)); ds.setExcludes(getArray(exclude)); if (ds instanceof ZipScanner) { ((ZipScanner) ds).setSrc(container); } else { ds.setBasedir(container); } ds.setCaseSensitive(true); ds.scan(); String[] files = ds.getIncludedFiles(); return files; }
@Override public void execute(SensorContext context) { TailorReportParser parser = new TailorReportParser(context); DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{reportPath()}); scanner.setBasedir(context.fileSystem().baseDir().getAbsolutePath()); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); for (String filename : files) { LOGGER.info("Processing Tailor report {}", filename); parser.parseReport(new File(filename)); } } }
@Override public void execute(SensorContext context) { CoberturaReportParser parser = new CoberturaReportParser(context); DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{reportPath()}); scanner.setBasedir(context.fileSystem().baseDir().getAbsolutePath()); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); for (String filename : files) { LOGGER.info("Processing Cobertura report {}", filename); parser.parseReport(new File(filename)); } } }
@Override public void execute(SensorContext context) { SwiftLintReportParser parser = new SwiftLintReportParser(context); DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{reportPath()}); scanner.setBasedir(context.fileSystem().baseDir().getAbsolutePath()); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); for (String filename : files) { LOGGER.info("Processing SwiftLint report {}", filename); parser.parseReport(new File(filename)); } } }
@Override public void execute(SensorContext context) { OCLintParser parser = new OCLintParser(context); DirectoryScanner scanner = new DirectoryScanner(); scanner.setIncludes(new String[]{reportPath()}); scanner.setBasedir(context.fileSystem().baseDir().getAbsolutePath()); scanner.setCaseSensitive(false); scanner.scan(); String[] files = scanner.getIncludedFiles(); for (String filename : files) { LOGGER.info("Processing OCLint report {}", filename); parser.parseReport(new File(filename)); } } }
/** * Configures the scanner and runs the scan. * * @param scanner the scanner to configure and run the scan. */ protected final void configureAndScan(final DirectoryScanner scanner) { scanner.setCaseSensitive(true); if (includes.length > 0) { scanner.setIncludes(includes); } if (excludes.length > 0) { scanner.setExcludes(excludes); } scanner.setSelectors(selectors); scanner.scan(); }