Browse Source

Ensure the target file's parent directory exists.

Submitted by:	Russell Gold <russgold@acm.org>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267809 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
b63d11b051
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java

+ 10
- 0
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -295,6 +295,7 @@ public class XSLTProcess extends MatchingTask {
inFile = new File(baseDir,xmlFile);
outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt);
if (inFile.lastModified() > outFile.lastModified()) {
ensureDirectoryFor( outFile );
//-- command line status
log("Processing " + xmlFile + " to " + outFile, Project.MSG_VERBOSE);

@@ -311,4 +312,13 @@ public class XSLTProcess extends MatchingTask {

} //-- processXML

private void ensureDirectoryFor( File targetFile ) throws BuildException {
File directory = new File( targetFile.getParent() );
if (!directory.exists()) {
if (!directory.mkdirs()) {
throw new BuildException("Unable to create directory: "
+ directory.getAbsolutePath() );
}
}
}
} //-- XSLTProcess

Loading…
Cancel
Save