ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
Date Wed, 25 Sep 2002 14:08:48 GMT
bodewig     2002/09/25 07:08:48

  Modified:    src/main/org/apache/tools/ant/taskdefs Ant.java
               src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
  Log:
  Make <ftp>'s MKDIR action work recursively (if necessary).
  
  PR: 12576
  Submitted by:	Kyle Adams <kadams at gfs.com>
  
  Revision  Changes    Path
  1.67      +1 -0      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java
  
  Index: Ant.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- Ant.java	13 Sep 2002 08:54:26 -0000	1.66
  +++ Ant.java	25 Sep 2002 14:08:48 -0000	1.67
  @@ -473,6 +473,7 @@
               Method cloneM = c.getMethod("clone", new Class[0]);
               if (cloneM != null) {
                   copy = cloneM.invoke(orig, new Object[0]);
  +                log("Adding clone of reference " + oldKey, Project.MSG_DEBUG);
               }
           } catch (Exception e) {
               // not Clonable
  
  
  
  1.29      +33 -13    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- FTP.java	23 Sep 2002 16:01:43 -0000	1.28
  +++ FTP.java	25 Sep 2002 14:08:48 -0000	1.29
  @@ -67,6 +67,7 @@
   import java.io.InputStream;
   import java.io.OutputStream;
   import java.util.Locale;
  +import java.util.StringTokenizer;
   import java.util.Vector;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
  @@ -101,6 +102,7 @@
    * @author Glenn McAllister <a href="mailto:glennm@ca.ibm.com">
    *      glennm@ca.ibm.com</a>
    * @author <a href="mailto:umagesh@apache.org">Magesh Umasankar</a>
  + * @author <a href="mailto:kadams@gfs.com">Kyle Adams</a>
    * @since Ant 1.3
    */
   public class FTP
  @@ -938,22 +940,40 @@
        */
       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:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message