You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Morten Primdahl <mo...@kikobu.com> on 2003/07/15 18:57:25 UTC

[VFS] FtpFileObject and Sun Solaris symbolic links

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;

import java.io.IOException;

public class FType {

    private DefaultFileSystemManager getFileSystemManager() throws IOException {

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

         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 {
                 mgr.close();
             }
             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 :)

BR,

Morten





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