From be64ef83f1b95911479b5ff29aa9914477773dd6 Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Tue, 7 Sep 2010 23:45:04 +0000 Subject: [PATCH] Create the directories for generated files if necessary git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6147 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/presents/tools/InvocationTask.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/presents/tools/InvocationTask.java b/src/java/com/threerings/presents/tools/InvocationTask.java index 905e7a8db..878930d2e 100644 --- a/src/java/com/threerings/presents/tools/InvocationTask.java +++ b/src/java/com/threerings/presents/tools/InvocationTask.java @@ -411,7 +411,11 @@ public abstract class InvocationTask extends GenTask if (_header != null) { data = _header + data; } - new PrintWriter(new File(path), "UTF-8").append(data).close(); + File dest = new File(path); + if (!dest.getParentFile().exists() && !dest.getParentFile().mkdirs()) { + throw new BuildException("Unable to create directory for " + dest.getAbsolutePath()); + } + new PrintWriter(dest, "UTF-8").append(data).close(); } protected static void checkedAdd (List list, T value)