Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 15520 invoked from network); 12 Sep 2002 14:34:19 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Sep 2002 14:34:19 -0000 Received: (qmail 3121 invoked by uid 97); 12 Sep 2002 14:34:51 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 3088 invoked by uid 97); 12 Sep 2002 14:34:51 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 3071 invoked by uid 98); 12 Sep 2002 14:34:50 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: From: Dominique Devienne To: "'Ant Developers List'" Subject: RE: [PATCH] 12576 FTP creation of remote directories Date: Thu, 12 Sep 2002 09:34:10 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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:kadams@gfs.com] Sent: Thursday, September 12, 2002 9:22 AM To: ant-dev@jakarta.apache.org 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: For additional commands, e-mail: -- To unsubscribe, e-mail: For additional commands, e-mail: