From 2276ae89a23d3e7f8166e7bd38fcf6ab1075b1e9 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 29 Mar 2001 10:08:55 +0000 Subject: [PATCH] sanity checks for Submitted by: David Rees git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268898 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/Touch.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Touch.java b/src/main/org/apache/tools/ant/taskdefs/Touch.java index 537cb0788..8d3d79c8d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Touch.java +++ b/src/main/org/apache/tools/ant/taskdefs/Touch.java @@ -138,6 +138,10 @@ public class Touch extends Task { Locale.US); try { setMillis(df.parse(dateTime).getTime()); + if (millis < 0) { + throw new BuildException("Date of " + dateTime + + " results in negative milliseconds value relative to epoch (January 1, 1970, 00:00:00 GMT)."); + } } catch (ParseException pe) { throw new BuildException(pe.getMessage(), pe, location); } @@ -190,7 +194,11 @@ public class Touch extends Task { } } - protected void touch(File file) { + protected void touch(File file) throws BuildException { + if (!file.canWrite()) { + throw new BuildException("Can not change modification date of read-only file " + file); + } + if (project.getJavaVersion() == Project.JAVA_1_1) { return; }