From 596d7e465f62f4783ed3ac41870098d56d018322 Mon Sep 17 00:00:00 2001 From: glennm Date: Wed, 1 Nov 2000 14:58:08 +0000 Subject: [PATCH] Added error message if a single file specified by the file attribute is missing. Also fixed up the message indicating how many files are being copied to correctly use "file" and "files". Reported by: Diane Holt git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268138 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/Copy.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java index 3d947e795..583843780 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copy.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java @@ -167,13 +167,17 @@ public class Copy extends Task { // deal with the single file if (file != null) { - if (destFile == null) { - destFile = new File(destDir, file.getName()); - } + if (file.exists()) { + if (destFile == null) { + destFile = new File(destDir, file.getName()); + } - if (forceOverwrite || - (file.lastModified() > destFile.lastModified())) { - fileCopyMap.put(file.getAbsolutePath(), destFile.getAbsolutePath()); + if (forceOverwrite || + (file.lastModified() > destFile.lastModified())) { + fileCopyMap.put(file.getAbsolutePath(), destFile.getAbsolutePath()); + } + } else { + log("Could not find file " + file.getAbsolutePath() + " to copy."); } } @@ -279,8 +283,9 @@ public class Copy extends Task { */ protected void doFileOperations() { if (fileCopyMap.size() > 0) { - log("Copying " + fileCopyMap.size() + " files to " + - destDir.getAbsolutePath() ); + log("Copying " + fileCopyMap.size() + + " file" + (fileCopyMap.size() == 1 ? "" : "s") + + " to " + destDir.getAbsolutePath() ); Enumeration e = fileCopyMap.keys(); while (e.hasMoreElements()) {