commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (NET-449) listFiles bug with folder that begins with "-"
Date Sat, 14 Jul 2012 12:56:34 GMT

     [ https://issues.apache.org/jira/browse/NET-449?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sebb updated NET-449:
---------------------

    Description: 
FTP Server status:

{code}
root@xxx-srv:/data/Library# tree -A
.
├── -dash
│   ├── -dash.txt
│   ├── file1.txt
│   └── file2.txt
└── test
    ├── file2.txt
    └── file.txt
{code}

Test code:

{code} 
final FTPClient ftp = new FTPClient();
ftp.connect(host, port);
ftp.login(login, pwd);
System.out.println("PWD: " + ftp.printWorkingDirectory());
final FTPFile[] listFiles = ftp.listFiles();
for (int i = 0; i < listFiles.length; i++) {
   System.out.println("[" + i + "] " + listFiles[i]);
}

System.out.println("Files in /-dash");
final FTPFile[] listFiles2 = ftp.listFiles("/-dash");
for (int i = 0; i < listFiles2.length; i++) {
   System.out.println("[" + i + "] " + listFiles2[i]);
}

System.out.println("Files in -dash");
final FTPFile[] listFiles3 = ftp.listFiles("-dash");
for (int i = 0; i < listFiles3.length; i++) {
   System.out.println("[" + i + "] " + listFiles3[i]);
}
{code} 

results:
{code} 
PWD: /
[0] -dash
[1] test
Files in /-dash
[0] -dash.txt
[1] file1.txt
[2] file2.txt
Files in -dash
[0] -dash
[1] .
[2] ..
[3] test
{code} 
When listing "-dash", it list the current directory instead of the destination one.
If I do the same test with the folder test, this time it works as expected.

  was:
FTP Server status:

{code}
root@xxx-srv:/data/Library# tree -A
.
├── -dash
│   ├── -dash.txt
│   ├── file1.txt
│   └── file2.txt
└── test
    ├── file2.txt
    └── file.txt
{code}

Test code:

{code} 
final org.apache.commons.net.ftp.FTPClient ftp = new org.apache.commons.net.ftp.FTPClient();
		    ftp.connect(host, port);
		    ftp.login(login, pwd);
		    
		    System.out.println("PWD: " + ftp.printWorkingDirectory());
		    final FTPFile[] listFiles = ftp.listFiles();
		    for (int i = 0; i < listFiles.length; i++) {
		        System.out.println("[" + i + "] " + listFiles[i]);
		    }
		    
		    System.out.println("Files in /-dash");
		    final FTPFile[] listFiles2 = ftp.listFiles("/-dash");
		    for (int i = 0; i < listFiles2.length; i++) {
		        System.out.println("[" + i + "] " + listFiles2[i]);
		    }
		    
		    System.out.println("Files in -dash");
		    final FTPFile[] listFiles3 = ftp.listFiles("-dash");
		    for (int i = 0; i < listFiles3.length; i++) {
		        System.out.println("[" + i + "] " + listFiles3[i]);
		    }
{code} 

results:
{code} 
PWD: /
[0] -dash
[1] test
Files in /-dash
[0] -dash.txt
[1] file1.txt
[2] file2.txt
Files in -dash
[0] -dash
[1] .
[2] ..
[3] test
{code} 
When listing "-dash", it list the current directory instead of the destination one.
If I do the same test with the folder test, this time it works as expected.


Fix code alignment; simplify.
                
> listFiles bug with folder that begins with "-"
> ----------------------------------------------
>
>                 Key: NET-449
>                 URL: https://issues.apache.org/jira/browse/NET-449
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.1
>            Reporter: Stéphane Verger
>
> FTP Server status:
> {code}
> root@xxx-srv:/data/Library# tree -A
> .
> ├── -dash
> │   ├── -dash.txt
> │   ├── file1.txt
> │   └── file2.txt
> └── test
>     ├── file2.txt
>     └── file.txt
> {code}
> Test code:
> {code} 
> final FTPClient ftp = new FTPClient();
> ftp.connect(host, port);
> ftp.login(login, pwd);
> System.out.println("PWD: " + ftp.printWorkingDirectory());
> final FTPFile[] listFiles = ftp.listFiles();
> for (int i = 0; i < listFiles.length; i++) {
>    System.out.println("[" + i + "] " + listFiles[i]);
> }
> System.out.println("Files in /-dash");
> final FTPFile[] listFiles2 = ftp.listFiles("/-dash");
> for (int i = 0; i < listFiles2.length; i++) {
>    System.out.println("[" + i + "] " + listFiles2[i]);
> }
> System.out.println("Files in -dash");
> final FTPFile[] listFiles3 = ftp.listFiles("-dash");
> for (int i = 0; i < listFiles3.length; i++) {
>    System.out.println("[" + i + "] " + listFiles3[i]);
> }
> {code} 
> results:
> {code} 
> PWD: /
> [0] -dash
> [1] test
> Files in /-dash
> [0] -dash.txt
> [1] file1.txt
> [2] file2.txt
> Files in -dash
> [0] -dash
> [1] .
> [2] ..
> [3] test
> {code} 
> When listing "-dash", it list the current directory instead of the destination one.
> If I do the same test with the folder test, this time it works as expected.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message