From 0c41fc850b6633c1685484872a5c26369e9645cb Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 3 Aug 2004 22:36:48 +0000 Subject: [PATCH] Do the right thing when a patch involves a brand new file in a brand new directory. --- src/java/com/threerings/getdown/tools/Patcher.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/getdown/tools/Patcher.java b/src/java/com/threerings/getdown/tools/Patcher.java index 096ab1a..e1ea5f6 100644 --- a/src/java/com/threerings/getdown/tools/Patcher.java +++ b/src/java/com/threerings/getdown/tools/Patcher.java @@ -1,5 +1,5 @@ // -// $Id: Patcher.java,v 1.4 2004/07/28 07:45:44 mdb Exp $ +// $Id: Patcher.java,v 1.5 2004/08/03 22:36:48 mdb Exp $ package com.threerings.getdown.tools; @@ -18,6 +18,7 @@ import com.sun.javaws.jardiff.JarDiffPatcher; import com.samskivert.io.StreamUtil; import org.apache.commons.io.CopyUtils; +import com.threerings.getdown.Log; import com.threerings.getdown.util.ProgressObserver; /** @@ -93,6 +94,14 @@ public class Patcher _buffer = new byte[COPY_BUFFER_SIZE]; } + // make sure the file's parent directory exists + File pdir = target.getParentFile(); + if (!pdir.exists()) { + if (!pdir.mkdirs()) { + Log.warning("Failed to create parent for '" + target + "'."); + } + } + InputStream in = null; FileOutputStream fout = null; try {