ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Morris" <David.Mor...@plumcreek.com>
Subject Re: FTP Support
Date Wed, 12 Jun 2002 15:55:18 GMT
Steve,

Here is a patch for the FTP class that allows FTP to work against an 
iSeries system. Please let me know if it is appropriate. I had a hard 
time deciding whether this belongs in Ant or the underlying 
org.apache.commons.net support.

My thought with changing the commons.net FTP class was that it would 
fix the list files for anything relying on that package. To fix it
there I would 
patch it to set the system as a property when a connection is
established 
and then set the listfmt in the getfiles if the default
FTPFileLIstParser is 
being used.

David Morris

Index: src/main/org/apache/tools/ant/taskdefs/optional/net/ftp.java 
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/net/ftp.java,v

retrieving revision 1.22
diff -u -r1.22 ftp.java 
---
src/main/org/apache/tools/ant/taskdefs/optional/net/ftp.java	1
Jun 2002 12:26:41 -0000	1.22
+++
src/main/org/apache/tools/ant/taskdefs/optional/net/ftp.java	12
Jun 2002 15:31:52 -0000
@@ -53,9 +53,9 @@
  */
 package org.apache.tools.ant.taskdefs.optional.net;
 
-import com.oroinc.net.ftp.FTPClient;
-import com.oroinc.net.ftp.FTPFile;
-import com.oroinc.net.ftp.FTPReply;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.FileScanner;
@@ -132,6 +132,7 @@
     private String chmod = null;
     private String umask = null;
     private FileUtils fileUtils = FileUtils.newFileUtils();
+    private String system;
 
     protected static final String[] ACTION_STRS = {
         "sending",
@@ -612,7 +613,10 @@
                 log("creating remote directory " +
resolveFile(dir.getPath()),
                     Project.MSG_VERBOSE);
                 if(!ftp.makeDirectory(resolveFile(dir.getPath()))) {
+                    boolean saveIgnoreNoncriticalErrors =
ignoreNoncriticalErrors;
+                    ignoreNoncriticalErrors = true;
                     handleMkDirFailure(ftp);
+                    ignoreNoncriticalErrors =
saveIgnoreNoncriticalErrors;
                 }
                 dirCache.addElement(dir);
             }
@@ -924,9 +928,19 @@
             }
 
             log("login succeeded", Project.MSG_VERBOSE);
+            
+            // Retrieve the system
+            ftp.syst();
+            
+            if (FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
+                system = ftp.getReplyString();
+                if (system.substring(5,11).equals("OS/400")) {
+                    doSiteCommand(ftp, "listfmt 1");
+                }
+            }
 
             if (binary) {
-               
ftp.setFileType(com.oroinc.net.ftp.FTP.IMAGE_FILE_TYPE);
+               
ftp.setFileType(org.apache.commons.net.ftp.FTP.IMAGE_FILE_TYPE);
                 if
(!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
                     throw new BuildException("could not set transfer
type: " +


>>> steve_l@iseran.com 06/10/02 10:04PM >>>

...if that is what it takes. Better yet, have it work it out for
itself


--
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