Does the transcript of your interaction look something like this:

> cd ftp://jbarrett:[EMAIL PROTECTED]/
Current folder is ftp://jbarrett:[EMAIL PROTECTED]/
> ls
Contents of ftp://jbarrett:[EMAIL PROTECTED]/
Command failed:
org.apache.commons.vfs.FileSystemException: Could not list the contents of 
"ftp://jbarrett:[EMAIL PROTECTED]/" because it is not a folder.
        at 
org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileObject.java:470)
        at org.apache.commons.vfs.example.Shell.listChildren(Shell.java:292)
        at org.apache.commons.vfs.example.Shell.ls(Shell.java:283)
        at org.apache.commons.vfs.example.Shell.handleCommand(Shell.java:157)
        at org.apache.commons.vfs.example.Shell.go(Shell.java:125)
        at org.apache.commons.vfs.example.Shell.main(Shell.java:88)
> 

I think I've found the problem.  Here's the stack trace (sort of):
Shell.listChildren() ->
AbstractFileObject.getChildren() -> 
AbstractFileObject.attach() ->
FtpFileObject.doAttach() ->
FtpFileObject.getInfo() 

Now getInfo looks like this:

    private void getInfo( boolean flush ) throws IOException
    {
        final FtpFileObject parent = (FtpFileObject)getParent();
        if ( parent != null )
        {
            fileInfo = parent.getChildFile( getName().getBaseName(), flush );
        }
        if ( fileInfo == null || !fileInfo.isDirectory() )
        {
            children = EMPTY_FTP_FILE_ARRAY;
        }
    }

It looks like getParent() returns null because we're currently at the root file of the 
filesystem.  That means fileinfo stays equal to null, which means our file type gets 
set to imaginary.  Imaginary files can't have children, so an exception is thrown.

So the point is, I think we need to get an FTPFile instance for the root file of an 
FTP file system and set fileInfo to it.  Not sure how to get the FTPFile instance -- 
from looking at the api for FTPClient, the only way to get FTPFiles is via listFiles, 
which only produces children.  Any other thoughts?

> -----Original Message-----
> From: Bernard Johnson
> [mailto:[EMAIL PROTECTED]
> Sent: Sunday, March 09, 2003 9:36 PM
> To: [EMAIL PROTECTED]
> Subject: [VFS] "Could not list the contents of..."
> 
> 
> I'm looking at using the VFS component in a piece of software 
> I'm developing.  Currently, I'm experimenting with the Shell 
> example program.  I can cp files from http locations, but 
> when I try to cd to the location and ls the files, I get the 
> message above, followed by the specifier of the location.
> 
> Local locations work file.  Http and Ftp locations give the 
> error message.  Is there something special I need to do to 
> get the directory listing?
> 
> Ideally, I'd like to be able to "walk" a remote location 
> (both http and ftp) to get a listing of files at that location.
> 
> Thanks
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to