/** * Convenience layer on top of restrict that returns the source * files as File objects (containing absolute paths if srcDir is * absolute). * * @param files the original set of files. * @param srcDir all files are relative to this directory. * @param destDir target files live here. If null file names * returned by the mapper are assumed to be absolute. * @param mapper knows how to construct a target file names from * source file names. * @param granularity The number of milliseconds leeway to give * before deciding a target is out of date. * @return an array of files. * @since Ant 1.6.2 */ public File[] restrictAsFiles(String[] files, File srcDir, File destDir, FileNameMapper mapper, long granularity) { return Stream.of(restrict(files, srcDir, destDir, mapper, granularity)) .map(name -> new File(srcDir, name)).toArray(File[]::new); }
private String[] restrict(String[] s, File baseDir) { return (mapper == null || force) ? s : new SourceFileScanner(this).restrict(s, baseDir, destDir, mapper); }
/** * Restrict the given set of files to those that are newer than * their corresponding target files. * * @param files the original set of files. * @param srcDir all files are relative to this directory. * @param destDir target files live here. if null file names * returned by the mapper are assumed to be absolute. * @param mapper knows how to construct a target file names from * source file names. * @return an array of filenames. */ public String[] restrict(String[] files, File srcDir, File destDir, FileNameMapper mapper) { return restrict(files, srcDir, destDir, mapper, FILE_UTILS.getFileTimestampGranularity()); }
/** * Scan a directory for files to check for "up to date"ness * @param srcDir the directory * @param files the files to scan for * @return true if the files are up to date */ protected boolean scanDir(File srcDir, String[] files) { SourceFileScanner sfs = new SourceFileScanner(this); FileNameMapper mapper = getMapper(); File dir = srcDir; if (mapperElement == null) { dir = null; } return sfs.restrict(files, srcDir, dir, mapper).length == 0; }
/** * Is the archive up to date in relationship to a list of files. * @param files the files to check * @param dir the base directory for the files. * @return true if the archive is up to date. * @since Ant 1.5.2 */ protected boolean archiveIsUpToDate(final String[] files, final File dir) { final SourceFileScanner sfs = new SourceFileScanner(this); final MergingMapper mm = new MergingMapper(); mm.setTo(tarFile.getAbsolutePath()); return sfs.restrict(files, dir, null, mm).length == 0; }
/** * Scans the directory looking for class files to be compiled. * The result is returned in the class variable compileList. * @param baseDir the base direction * @param files the list of files to scan * @param mapper the mapper of files to target files */ protected void scanDir(File baseDir, String[] files, FileNameMapper mapper) { String[] newFiles = files; if (idl) { log("will leave uptodate test to rmic implementation in idl mode.", Project.MSG_VERBOSE); } else if (iiop && iiopOpts != null && iiopOpts.contains("-always")) { log("no uptodate test as -always option has been specified", Project.MSG_VERBOSE); } else { SourceFileScanner sfs = new SourceFileScanner(this); newFiles = sfs.restrict(files, baseDir, getOutputDir(), mapper); } Stream.of(newFiles).map(s -> s.replace(File.separatorChar, '.')) .map(s -> s.substring(0, s.lastIndexOf(".class"))) .forEach(compileList::add); }
} else { final SourceFileScanner ds = new SourceFileScanner(this); toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity);
} else { SourceFileScanner sfs = new SourceFileScanner(this); upToDate = sfs.restrict(new String[] {sourceFile.getAbsolutePath()}, null, null, mapperElement.getImplementation()).length == 0;
files = scanner.getIncludedFiles(); SourceFileScanner sfs = new SourceFileScanner(this); files = sfs.restrict(files, srcDir, destDir, m); int count = files.length; if (count == 0) {
/** * Scans the directory looking for source files to be compiled. * The results are returned in the instance variable <code>reportFilesMap</code>. * * @param srcdir source directory * @param destdir destination directory * @param files included file names */ protected void scanDir(File srcdir, File destdir, String[] files) { RegexpPatternMapper mapper = new RegexpPatternMapper(); mapper.setFrom("^(.*)\\.(.*)$"); mapper.setTo("\\1.jasper"); SourceFileScanner scanner = new SourceFileScanner(this); String[] newFiles = scanner.restrict(files, srcdir, destdir, mapper); if (newFiles != null && newFiles.length > 0) { for (int i = 0; i < newFiles.length; i++) { reportFilesMap.put( (new File(srcdir, newFiles[i])).getAbsolutePath(), (new File(destdir, mapper.mapFileName(newFiles[i])[0])).getAbsolutePath() ); } } }
String[] files = ds.getIncludedFiles(); SourceFileScanner sfs = new SourceFileScanner(this); String[] newFiles = sfs.restrict( files, srcDir,
String[] files = ds.getIncludedFiles(); SourceFileScanner sfs = new SourceFileScanner(this); String[] newFiles = sfs.restrict( files, srcDir,