FYI: Patches should be filed on bugzilla as attachment, to avoid line truncation. They should also be generated with 'cvs diff -u'. Thanks, --DD
-----Original Message----- From: Kyle Adams [mailto:[EMAIL PROTECTED] Sent: Thursday, September 12, 2002 9:22 AM To: [EMAIL PROTECTED] Subject: [PATCH] 12576 FTP creation of remote directories The attached patch handles remote directory creation iteratively, creating any missing parent directories that are necessary to create the entire path. ================= --- ftp.java 2002-09-12 09:31:04.000000000 -0400 +++ FTP-modified.java 2002-09-12 09:47:20.000000000 -0400 @@ -866,23 +866,34 @@ * @param dir The directory to create (format must be correct for host * type) */ - protected void makeRemoteDir(FTPClient ftp, String dir) - throws IOException, BuildException { + protected void makeRemoteDir( FTPClient ftp, String dir ) + throws IOException, BuildException { if (verbose) { 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("subdir: " + 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. + handleMkDirFailure(ftp); + if (verbose) { + log("directory already exists"); + } + } else { + if (verbose) { + log("directory created OK"); + } + ftp.changeWorkingDirectory(subdir); + } } } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
