create a directory first, if needed.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1701 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2007-01-08 03:57:47 +00:00
1 parent 7e91be5aaf
commit 833cb3270b
1 file changed
+4 -1
+4 -1
View File
@@ -436,6 +436,7 @@ public final class FilePath implements Serializable {
/**
* Writes to this file.
* If this file already exists, it will be overwritten.
* If the directory doesn't exist, it will be created.
*/
public OutputStream write() throws IOException {
if(channel==null)
@@ -444,7 +445,9 @@ public final class FilePath implements Serializable {
final Pipe p = Pipe.createLocalToRemote();
channel.callAsync(new Callable<Void,IOException>() {
public Void call() throws IOException {
FileOutputStream fos = new FileOutputStream(new File(remote));
File f = new File(remote);
f.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(f);
Util.copyStream(p.getIn(),fos);
fos.close();
p.getIn().close();