bodewig 01/03/29 02:08:57
Modified: src/main/org/apache/tools/ant/taskdefs Touch.java
Log:
sanity checks for <touch>
Submitted by: David Rees <[EMAIL PROTECTED]>
Revision Changes Path
1.8 +9 -1
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Touch.java
Index: Touch.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Touch.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Touch.java 2001/03/29 09:37:12 1.7
+++ Touch.java 2001/03/29 10:08:55 1.8
@@ -138,6 +138,10 @@
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);
}
@@ -189,8 +193,12 @@
}
}
}
+
+ protected void touch(File file) throws BuildException {
+ if (!file.canWrite()) {
+ throw new BuildException("Can not change modification date of
read-only file " + file);
+ }
- protected void touch(File file) {
if (project.getJavaVersion() == Project.JAVA_1_1) {
return;
}