Browse Source

sanity checks for <touch>

Submitted by:	David Rees <d.rees.l@usa.net>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268898 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
2276ae89a2
1 changed files with 9 additions and 1 deletions
  1. +9
    -1
      src/main/org/apache/tools/ant/taskdefs/Touch.java

+ 9
- 1
src/main/org/apache/tools/ant/taskdefs/Touch.java View File

@@ -138,6 +138,10 @@ public class Touch extends Task {
Locale.US); Locale.US);
try { try {
setMillis(df.parse(dateTime).getTime()); 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) { } catch (ParseException pe) {
throw new BuildException(pe.getMessage(), pe, location); 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) { if (project.getJavaVersion() == Project.JAVA_1_1) {
return; return;
} }


Loading…
Cancel
Save