From b63d11b05127869902892020ab0faa8e83a5c55b Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 21 Jul 2000 09:43:15 +0000 Subject: [PATCH] Ensure the target file's parent directory exists. Submitted by: Russell Gold git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267809 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/XSLTProcess.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index a6ca82a75..bcafae9f1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -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