commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morten Primdahl <>
Subject [VFS] FtpFileObject and Sun Solaris symbolic links
Date Tue, 15 Jul 2003 16:57:25 GMT

Hi. I've noted that solaris symbolic links resolve themselves as first
(and only) child.

This results in valid folders immediatly below a link get imaginary type,
because the child FileObject asks the parent to verify its existence,
from FtpFileObject.getInfo:

     if ( parent != null )
        fileInfo = parent.getChildFile( getName().getBaseName(), flush );

The parent symlink can only see its own name as child, and this cannot get
the fileInfo for the child, which results in an imaginary type, which is
wrong. Demonstration, this works fine on linux:

[linux]~>mkdir dir
[linux]~>mkdir dir/subdir
[linux]~>ln -s dir link
[linux]~>java FType ftp://user:pass@linux/dir/subdir
 >> Type for ftp://user:pass@linux/dir/subdir is: folder
[linux]~>java FType ftp://user:pass@linux/link/subdir
 >> Type for ftp://user:pass@linux/link/subdir is: folder

But on solaris, the subdir directory becomes imaginary and not folder:

[solaris]~>java FType ftp://user:pass@solaris/dir/subdir
 >> Type for ftp://user:pass@solaris/dir/subdir is: folder
[solaris]~>java FType ftp://user:pass@solaris/link/subdir
 >> Type for ftp://user:pass@solaris/link/subdir is: imaginary
[solaris]~>mkdir link/subdir/subsubdir
[solaris]~>java FType ftp://user:pass@solaris/link/subdir/subsubdir
 >> Type for ftp://user:pass@solaris/link/subdir/subsubdir is: folder

The source for FType:

import org.apache.commons.vfs.FileType;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.provider.ftp.FtpFileProvider;
import org.apache.commons.vfs.impl.DefaultFileSystemManager;


public class FType {

    private DefaultFileSystemManager getFileSystemManager() throws IOException {

         DefaultFileSystemManager mgr = new DefaultFileSystemManager();
         mgr.addProvider("ftp", new FtpFileProvider());

         return mgr;

     public FileType resolveFolderType(String uri) throws IOException {

         DefaultFileSystemManager mgr = null;

         try {
             mgr = getFileSystemManager();
             FileObject fo = mgr.resolveFile(uri);

             return fo.getType();
         finally {

             try {
             catch (Exception e) {

     public static void main(String[] args) throws Exception {
         FType ft = new FType();
         System.out.println(">> Type for "+args[0]+" is: "+ft.resolveFolderType(args[0]));


I do not yet have a patch for this, I may not get the time to make one, but I'll
try. At least this behaviour has been documented :)



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message