Does this work? I wasn't sure what to do if workingDirectory was null (I'm not even sure if it would ever be null - I'm not too familiar with FTP). In the end I just decided to leave CWD as is if workingDirectory is null.
I've also attached the update patch file (along with appropriate comments) to the bug in bugzilla. Kyle >>> [EMAIL PROTECTED] 09/23/02 11:28AM >>> Kyle, do you see any way to store the CWD before creating the directory tree and change back to that when you are done (probably in a finally clause). This is the only problem I can identify at first glance. Stefan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--- FTP.orig 2002-09-19 04:27:10.000000000 -0400 +++ FTP.java 2002-09-23 15:03:49.000000000 -0400 @@ -99,6 +99,7 @@ * @author Glenn McAllister <a href="mailto:[EMAIL PROTECTED]"> * [EMAIL PROTECTED]</a> * @author <a href="mailto:[EMAIL PROTECTED]">Magesh Umasankar</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Kyle Adams</a> * @since Ant 1.3 */ public class FTP @@ -868,23 +869,41 @@ */ protected void makeRemoteDir(FTPClient ftp, String dir) throws IOException, BuildException { + String workingDirectory = ftp.printWorkingDirectory(); if (verbose) { - log("creating directory: " + dir); + log("Creating directory: " + dir); } - - if (!ftp.makeDirectory(dir)) { - // codes 521, 550 and 553 can be produced by FTP Servers - // to indicate that an attempt to create a directory has - // failed because the directory already exists. - handleMkDirFailure(ftp); - if (verbose) { - log("directory already exists"); - } - } else { - if (verbose) { - log("directory created OK"); + if (dir.indexOf("/") == 0) { + ftp.changeWorkingDirectory("/"); + } + String subdir = new String(); + StringTokenizer st = new StringTokenizer(dir, "/"); + while (st.hasMoreTokens()) { + subdir = st.nextToken(); + log("Checking " + subdir, Project.MSG_DEBUG); + if (!ftp.changeWorkingDirectory(subdir)) { + if(!ftp.makeDirectory(subdir)) { + // codes 521, 550 and 553 can be produced by FTP Servers + // to indicate that an attempt to create a directory has + // failed because the directory already exists. + int rc = ftp.getReplyCode(); + if (!(ignoreNoncriticalErrors && (rc == 550 || rc == 553 || rc==521))) { + throw new BuildException("could not create directory: " + ftp.getReplyString()); + } + if (verbose) { + log("Directory already exists"); + } + } else { + if (verbose) { + log("Directory created OK"); + } + ftp.changeWorkingDirectory(subdir); + } } } + if (workingDirectory != null) { + ftp.changeWorkingDirectory(workingDirectory); + } } /**
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
