/** * Evaluate two times against this TimeComparison. * @param t1 the first time to compare. * @param t2 the second time to compare. * @return true if the comparison result fell within the parameters of this TimeComparison. */ public boolean evaluate(long t1, long t2) { return evaluate(t1, t2, FILE_UTILS.getFileTimestampGranularity()); }
/** * Compare two times. * @param t1 the first time to compare. * @param t2 the second time to compare. * @return a negative integer, a positive integer, or zero as t1 is * before, after, or equal to t2 accounting for the default granularity. */ public static int compare(long t1, long t2) { return compare(t1, t2, FILE_UTILS.getFileTimestampGranularity()); }
/** * Copy task constructor. */ public Copy() { fileUtils = FileUtils.getFileUtils(); granularity = fileUtils.getFileTimestampGranularity(); }
/** * Returns true if the source is older than the dest. * @param source source file (should be the older). * @param dest dest file (should be the newer). * @return true if the source is older than the dest, taking the granularity into account. * @since Ant 1.6.3 */ public boolean isUpToDate(File source, File dest) { return isUpToDate(source, dest, getFileTimestampGranularity()); }
/** * Compare two timestamps for being up to date using the * current granularity. * * @param sourceTime timestamp of source file. * @param destTime timestamp of dest file. * @return true if the dest file is considered up to date. */ public boolean isUpToDate(long sourceTime, long destTime) { return isUpToDate(sourceTime, destTime, getFileTimestampGranularity()); }
/** * 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()); }
/** * 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. * @return an array of files. */ public File[] restrictAsFiles(String[] files, File srcDir, File destDir, FileNameMapper mapper) { return restrictAsFiles(files, srcDir, destDir, mapper, FILE_UTILS.getFileTimestampGranularity()); }
/** * Tells which source files should be reprocessed based on the * last modification date of target files. * @param logTo where to send (more or less) interesting output. * @param source array of resources bearing relative path and last * modification date. * @param mapper filename mapper indicating how to find the target * files. * @param targets object able to map as a resource a relative path * at <b>destination</b>. * @return array containing the source files which need to be * copied or processed, because the targets are out of date or do * not exist. */ public static Resource[] selectOutOfDateSources(final ProjectComponent logTo, final Resource[] source, final FileNameMapper mapper, final ResourceFactory targets) { return selectOutOfDateSources(logTo, source, mapper, targets, FILE_UTILS.getFileTimestampGranularity()); }
private boolean isUpToDate(ResourceCollection c) { return dest != null && !forceOverwrite && c.stream().noneMatch(r -> SelectorUtils.isOutOfDate(r, dest, FILE_UTILS.getFileTimestampGranularity())); }
/** * Is the archive up to date in relationship to a list of files. * @param r the files to check * @return true if the archive is up to date. * @since Ant 1.7 */ protected boolean archiveIsUpToDate(final Resource r) { return SelectorUtils.isOutOfDate(new FileResource(tarFile), r, FileUtils.getFileUtils() .getFileTimestampGranularity()); }
throws IOException { if (!overwrite && !SelectorUtils.isOutOfDate(source, dest, FileUtils.getFileUtils().getFileTimestampGranularity())) { return;
private boolean isOutOfDate() { return force || (dest != null && SelectorUtils.isOutOfDate(new FileResource(src), new FileResource(dest), FileUtils.getFileUtils() .getFileTimestampGranularity()) ); }