commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Hartford" <dhartf...@ghsinc.com>
Subject [VFS] SFTP and non-unix SFTP servers
Date Tue, 22 Jun 2004 14:39:44 GMT
Hey all,
Doing great work with the VFS/SFTP project!  A little more than just the JSCH project as far
as learning curve, but nice to have one interface to handle ALL FileSystems!!

In using SFTP in VFS, I came across a problem with the 'doListChildren' method in org.apache.commons.vfs.provider.sftp.SftpFileObject

The 'stat' string describing the file is not always in unix ls format (unfortunately).  Here
is an example one that I came across trying to use this in the realworld (minus quotes):

" 0  Jun 21, 2004 10:37 filename.txt"

For now, changed that method to have this block:

==code==
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
*/

            final String stat = (String) iterator.next();
            final StringTokenizer tokens = new StringTokenizer(stat);
            int count = tokens.countTokens();
            count--;
            // TODO - check there are the correct number of tokens
            // TODO - handle names with spaces in 'em
            for (int i = 0; i < count; tokens.nextToken(), i++)
            {
            }
            final String name = tokens.nextToken();
            if (name.equals(".") || name.equals("..") || name.equals("./") || name.equals("../"))
            {
                continue;
            }
            children.add(name);

==end code==


Doesn't solve the 'handle name with spaces' problem, but at least takes care of the count,
and also added "./" and "../" exclusions.

-D


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


Mime
View raw message