You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Gilles Gaillard (JIRA)" <ji...@apache.org> on 2007/04/06 20:02:32 UTC

[jira] Commented: (VFS-123) [FTP Provider] Unvisible files in sub directories with space in their names

    [ https://issues.apache.org/jira/browse/VFS-123?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12487294 ] 

Gilles Gaillard commented on VFS-123:
-------------------------------------

A possible implementation of the workaround:

    private FTPFile[] internalListFiles(String relPath) throws IOException {
      FTPFile[] result = getFtpClient().listFiles(relPath);
      if (result==null || result.length==0){
        boolean mayEncode = !relPath.equals(URIUtil.encodePath(relPath));
        // The system cannot find the file specified.
        if (mayEncode && getFtpClient().getReplyCode()==FTPReply.CODE_550){
          String pwd = getFtpClient().printWorkingDirectory();
          try {
            getFtpClient().changeWorkingDirectory(relPath);
            result = getFtpClient().listFiles();
          } 
          finally {
            getFtpClient().changeWorkingDirectory(pwd);
          }
        }
      }
      return result;
    }
    
    public FTPFile[] listFiles(String relPath) throws IOException
    {
        try
        {
            return internalListFiles(relPath);
        }
        catch (IOException e)
        {
            disconnect();
            return internalListFiles(relPath);
        }
    }


> [FTP Provider] Unvisible files in sub directories with space in their names
> ---------------------------------------------------------------------------
>
>                 Key: VFS-123
>                 URL: https://issues.apache.org/jira/browse/VFS-123
>             Project: Commons VFS
>          Issue Type: Bug
>         Environment: all
>            Reporter: Gilles Gaillard
>            Priority: Trivial
>
> In class FTPClientWrapper, The method 
>   FTPFile[] listFiles(String relPath)
> returns an empty array if the relpath parameter contains a 'space' character (for example: 'test dir/child1'). 
> In such a case the FTP server will respond with an error 550 and a message looking like: 'invalid directory 'test'.
> The workaround is 
>   1. to detect such a case
>   2. to perform a CWD to the targeted directory, request the listFiles
>   3. CWD to the previous working directory.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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