ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
Date Fri, 22 Aug 2003 11:23:48 GMT
antoine     2003/08/22 04:23:48

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/net FTP.java
  Log:
  Fixes unsensitive searches on case sensitive remote file systems
  
  Revision  Changes    Path
  1.51      +39 -3     ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
  
  Index: FTP.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- FTP.java	21 Aug 2003 16:56:12 -0000	1.50
  +++ FTP.java	22 Aug 2003 11:23:48 -0000	1.51
  @@ -660,17 +660,32 @@
                   this.client = parent.client;
                   Vector pathElements = SelectorUtils.tokenizePath(path);
                   try {
  -                    this.client.changeWorkingDirectory(parent.getAbsolutePath());
  +                    boolean result = this.client.changeWorkingDirectory(parent.getAbsolutePath());
  +                    //this should not happen, except if parent has been deleted by another
process
  +                    if (!result) {
  +                        return;
  +                    }
                       this.curpwd = parent.getAbsolutePath();
                   } catch (IOException ioe) {
                       throw new BuildException("could not change working dir to "
                       + parent.curpwd);
                   }
                   for (int fcount = 0; fcount < pathElements.size() - 1; fcount++) {
  +                    String currentPathElement = (String) pathElements.elementAt(fcount);
                       try {
  -                        this.client.changeWorkingDirectory((String) pathElements.elementAt(fcount));
  +                        boolean result = this.client.changeWorkingDirectory(currentPathElement);
  +                        if (!result && !isCaseSensitive()
  +                            && (remoteSystemCaseSensitive || !remoteSensitivityChecked))
{
  +                           currentPathElement = findPathElementCaseUnsensitive(this.curpwd,
  +                               currentPathElement);
  +                            if (currentPathElement == null) {
  +                                return;
  +                            }
  +                        } else if (!result) {
  +                            return;
  +                        }
                           this.curpwd = this.curpwd + remoteFileSep
  -                            + (String) pathElements.elementAt(fcount);
  +                            + currentPathElement;
                       } catch (IOException ioe) {
                           throw new BuildException("could not change working dir to "
                           + (String) pathElements.elementAt(fcount)
  @@ -681,6 +696,27 @@
                   String lastpathelement = (String) pathElements.elementAt(pathElements.size()
- 1);
                   FTPFile [] theFiles = listFiles(this.curpwd);
                   this.ftpFile = getFile(theFiles, lastpathelement);
  +            }
  +            /**
  +             * find a file in a directory in case unsensitive way
  +             * @param parentPath        where we are
  +             * @param soughtPathElement what is being sought
  +             * @return                  the first file found or null if not found
  +             */
  +            private String findPathElementCaseUnsensitive(String parentPath,
  +                               String soughtPathElement) {
  +                // we are already in the right path, so the second parameter
  +                // is false
  +                FTPFile[] theFiles = listFiles(parentPath, false);
  +                if (theFiles == null) {
  +                    return null;
  +                }
  +                for (int icounter = 0; icounter < theFiles.length; icounter++) {
  +                    if (theFiles[icounter].getName().equalsIgnoreCase(soughtPathElement))
{
  +                        return theFiles[icounter].getName();
  +                    }
  +                }
  +                return null;
               }
               /**
                * find out if the file exists
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message