You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ad...@apache.org on 2003/04/29 03:41:39 UTC
cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp FtpFileObject.java
adammurdoch 2003/04/28 18:41:38
Modified: vfs/src/java/org/apache/commons/vfs/provider/ftp
FtpFileObject.java
Log:
Skip . and .. elements when listing the children of an FTP file.
Revision Changes Path
1.18 +18 -2 jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java
Index: FtpFileObject.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/ftp/FtpFileObject.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- FtpFileObject.java 14 Mar 2003 04:15:18 -0000 1.17
+++ FtpFileObject.java 29 Apr 2003 01:41:38 -0000 1.18
@@ -61,6 +61,7 @@
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
+import java.util.ArrayList;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
@@ -142,10 +143,25 @@
final FTPClient client = ftpFs.getClient();
try
{
- children = client.listFiles( relPath );
- if ( children == null )
+ final FTPFile[] tmpChildren = client.listFiles( relPath );
+ if ( tmpChildren == null || tmpChildren.length == 0 )
{
children = EMPTY_FTP_FILE_ARRAY;
+ }
+ else
+ {
+ // Remove '.' and '..' elements
+ final ArrayList childList = new ArrayList();
+ for ( int i = 0; i < tmpChildren.length; i++ )
+ {
+ final FTPFile child = tmpChildren[ i ];
+ if ( ! child.getName().equals( "." )
+ && !child.getName().equals( ".." ) )
+ {
+ childList.add( child );
+ }
+ }
+ children = (FTPFile[])childList.toArray( new FTPFile[ childList.size() ] );
}
}
finally
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org