You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by im...@apache.org on 2005/08/31 20:19:24 UTC

svn commit: r265540 - in /jakarta/commons/proper/vfs/trunk: ./ src/java/org/apache/commons/vfs/ src/java/org/apache/commons/vfs/impl/ src/java/org/apache/commons/vfs/provider/ src/java/org/apache/commons/vfs/provider/compressed/ src/java/org/apache/com...

Author: imario
Date: Wed Aug 31 11:18:58 2005
New Revision: 265540

URL: http://svn.apache.org/viewcvs?rev=265540&view=rev
Log:
enh: uri style filename resolving as suggested by Philippe Poulard - see RELEASE_NOTES.txt for details

Modified:
    jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/VFS.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileProvider.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/HostFileNameParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java

Modified: jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/commons/proper/vfs/trunk/RELEASE_NOTES.txt Wed Aug 31 11:18:58 2005
@@ -1,5 +1,12 @@
 2005-
 
+filenames:
+add a type (file/folder) to filename.
+This is needed to allow URI style filename resolving
+e.g. base "file:///path/to/file" with relative name "any/file" results in "file:///path/to/any/file" instead
+of "file:///path/to/file/any/file"
+This is experimental code. Switch on with "VFS.setUriStyle(true);" before ANY other VFS operation.
+
 ant tasks:
 added antlib.xml - (Jacob Kjome)
 

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/FileName.java Wed Aug 31 11:18:58 2005
@@ -75,7 +75,7 @@
      * replaced by its character.
      *
      * @return The path.  Never returns null.
-     * @throws FileSystemException if the path is not correctly encoded 
+     * @throws FileSystemException if the path is not correctly encoded
      */
     public String getPathDecoded() throws FileSystemException;
 
@@ -157,15 +157,30 @@
     /**
      * Determines if another file name is an ancestor of this file name.
      */
-    boolean isAncestor(FileName ancestor);
+    public boolean isAncestor(FileName ancestor);
 
     /**
      * Determines if another file name is a descendent of this file name.
      */
-    boolean isDescendent(FileName descendent);
+    public boolean isDescendent(FileName descendent);
 
     /**
      * Determines if another file name is a descendent of this file name.
      */
-    boolean isDescendent(FileName descendent, NameScope nameScope);
+    public boolean isDescendent(FileName descendent, NameScope nameScope);
+
+    /**
+     * Returns the requested or current type of this name. <br />
+     * <p/>
+     * The "requested" type is the one determined during resolving the name. <br/>
+     * In this case the name is a {@link FileType#FOLDER} if it ends with an "/" else
+     * it will be a {@link FileType#FILE}<br/>
+     * </p>
+     * <p/>
+     * Once attached it will be changed to reflect the real type of this resource.
+     * </p>
+     *
+     * @return {@link FileType#FOLDER} or {@link FileType#FILE}
+     */
+    public FileType getType();
 }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/Resources.properties Wed Aug 31 11:18:58 2005
@@ -91,6 +91,9 @@
 # AbstractFileProvider
 vfs.provider/filename-parser-missing.error=No filename-parser implementation set.
 
+# AbstractFileName
+vfs.provider/filename-type.error=A filename can only be of type FileType.FOLDER or FileType.FILE
+
 # RandomAccess
 vfs.provider/random-access-invalid-position.error=Invalid position: "{0}"
 vfs.provider/random-access-open-failed.error=Could not access file "{0}" because it does not exist.

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/VFS.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/VFS.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/VFS.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/VFS.java Wed Aug 31 11:18:58 2005
@@ -27,6 +27,8 @@
  */
 public class VFS
 {
+    private static Boolean URI_STYLE = null;
+
     private static FileSystemManager instance;
 
     private VFS()
@@ -97,5 +99,23 @@
                 managerClassName,
                 e);
         }
+    }
+
+    public static boolean isUriStyle()
+    {
+        if (URI_STYLE == null)
+        {
+            URI_STYLE = Boolean.FALSE;
+        }
+        return URI_STYLE.booleanValue();
+    }
+
+    public static void setUriStyle(boolean uriStyle)
+    {
+        if (URI_STYLE != null && URI_STYLE.booleanValue() != uriStyle)
+        {
+            throw new IllegalStateException("URI STYLE ALREADY SET TO");
+        }
+        URI_STYLE = uriStyle ? Boolean.TRUE : Boolean.FALSE;
     }
 }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileSystemManager.java Wed Aug 31 11:18:58 2005
@@ -24,8 +24,10 @@
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemManager;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.FilesCache;
 import org.apache.commons.vfs.NameScope;
+import org.apache.commons.vfs.VFS;
 import org.apache.commons.vfs.cache.SoftRefFilesCache;
 import org.apache.commons.vfs.provider.AbstractFileName;
 import org.apache.commons.vfs.provider.AbstractFileProvider;
@@ -492,6 +494,15 @@
     public FileObject resolveFile(final FileObject baseFile, final String uri, final FileSystemOptions fileSystemOptions)
         throws FileSystemException
     {
+        final FileObject realBaseFile;
+        if (baseFile != null && VFS.isUriStyle() && baseFile.getName().getType() == FileType.FILE)
+        {
+            realBaseFile = baseFile.getParent();
+        }
+        else
+        {
+            realBaseFile = baseFile;
+        }
         // TODO: use resolveName and use this name to resolve the fileObject
 
 
@@ -510,7 +521,7 @@
             final FileProvider provider = (FileProvider) providers.get(scheme);
             if (provider != null)
             {
-                return provider.findFile(baseFile, uri, fileSystemOptions);
+                return provider.findFile(realBaseFile, uri, fileSystemOptions);
             }
 // Otherwise, assume a local file
         }
@@ -529,16 +540,16 @@
             {
                 throw new FileSystemException("vfs.impl/unknown-scheme.error", new Object[]{scheme, uri});
             }
-            return defaultProvider.findFile(baseFile, uri, fileSystemOptions);
+            return defaultProvider.findFile(realBaseFile, uri, fileSystemOptions);
         }
 
 // Assume a relative name - use the supplied base file
-        if (baseFile == null)
+        if (realBaseFile == null)
         {
             throw new FileSystemException("vfs.impl/find-rel-file.error", uri);
         }
 
-        return baseFile.resolveFile(uri);
+        return realBaseFile.resolveFile(uri);
     }
 
     /**
@@ -555,8 +566,8 @@
     /**
      * Resolves a name, relative to the root.
      *
-     * @param base the base filename
-     * @param name the name
+     * @param base  the base filename
+     * @param name  the name
      * @param scope the {@link NameScope}
      * @return
      * @throws FileSystemException
@@ -566,6 +577,16 @@
                                 final NameScope scope)
         throws FileSystemException
     {
+        final FileName realBase;
+        if (base != null && VFS.isUriStyle() && base.getType() == FileType.FILE)
+        {
+            realBase = base.getParent();
+        }
+        else
+        {
+            realBase = base;
+        }
+
         final StringBuffer buffer = new StringBuffer(name);
 
         // Adjust separators
@@ -575,24 +596,28 @@
         if (name.length() == 0 || name.charAt(0) != FileName.SEPARATOR_CHAR)
         {
             // Supplied path is not absolute
-            buffer.insert(0, FileName.SEPARATOR_CHAR);
-            buffer.insert(0, base.getPath());
+            if (!VFS.isUriStyle())
+            {
+                // when using uris the parent already do have the trailing "/"
+                buffer.insert(0, FileName.SEPARATOR_CHAR);
+            }
+            buffer.insert(0, realBase.getPath());
         }
 
         //// UriParser.canonicalizePath(buffer, 0, name.length());
 
         // Normalise the path
-        UriParser.normalisePath(buffer);
+        FileType fileType = UriParser.normalisePath(buffer);
 
         // Check the name is ok
         final String resolvedPath = buffer.toString();
-        if (!AbstractFileName.checkName(base.getPath(), resolvedPath, scope))
+        if (!AbstractFileName.checkName(realBase.getPath(), resolvedPath, scope))
         {
             throw new FileSystemException("vfs.provider/invalid-descendent-name.error", name);
         }
 
-        String scheme = base.getScheme();
-        String fullPath = base.getRootURI() + resolvedPath;
+        String scheme = realBase.getScheme();
+        String fullPath = realBase.getRootURI() + resolvedPath;
         final FileProvider provider = (FileProvider) providers.get(scheme);
         if (provider != null)
         {
@@ -601,7 +626,7 @@
             // the base. Then we can get rid of the string operation.
             //// String fullPath = base.getRootURI() + resolvedPath.substring(1);
 
-            return provider.parseUri(base, fullPath);
+            return provider.parseUri(realBase, fullPath);
         }
 
         if (scheme != null)
@@ -609,13 +634,13 @@
 // An unknown scheme - hand it to the default provider - if possible
             if (defaultProvider != null)
             {
-                return defaultProvider.parseUri(base, fullPath);
+                return defaultProvider.parseUri(realBase, fullPath);
             }
         }
 
         // todo: avoid fallback to this point
         // this happens if we have a virtual filesystem (no provider for scheme)
-        return ((AbstractFileName) base).createName(resolvedPath);
+        return ((AbstractFileName) realBase).createName(resolvedPath, fileType);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileName.java Wed Aug 31 11:18:58 2005
@@ -16,6 +16,7 @@
 package org.apache.commons.vfs.impl;
 
 import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.AbstractFileName;
 
 /**
@@ -26,14 +27,14 @@
  */
 public class VirtualFileName extends AbstractFileName
 {
-    public VirtualFileName(final String scheme, final String absPath)
+    public VirtualFileName(final String scheme, final String absPath, final FileType type)
     {
-        super(scheme, absPath);
+        super(scheme, absPath, type);
     }
 
-    public FileName createName(String absPath)
+    public FileName createName(String absPath, FileType type)
     {
-        return new VirtualFileName(getScheme(), absPath);
+        return new VirtualFileName(getScheme(), absPath, type);
     }
 
     protected void appendRootUri(StringBuffer buffer)

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileProvider.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileProvider.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/VirtualFileProvider.java Wed Aug 31 11:18:58 2005
@@ -18,6 +18,7 @@
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileObject;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.AbstractVfsContainer;
 
 
@@ -52,7 +53,7 @@
     public FileObject createFileSystem(final String rootUri) throws FileSystemException
     {
         final FileName rootName =
-            new VirtualFileName(rootUri, FileName.ROOT_PATH);
+            new VirtualFileName(rootUri, FileName.ROOT_PATH, FileType.FOLDER);
         // final FileName rootName =
         //    new BasicFileName(rootUri, FileName.ROOT_PATH);
         final VirtualFileSystem fs = new VirtualFileSystem(rootName, null);

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileName.java Wed Aug 31 11:18:58 2005
@@ -17,7 +17,9 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.NameScope;
+import org.apache.commons.vfs.VFS;
 
 /**
  * A default file name implementation.
@@ -30,6 +32,7 @@
 {
     private final String scheme;
     private final String absPath;
+    private FileType type;
 
     // Cached stuff
     private String uri;
@@ -39,13 +42,21 @@
     private String decodedAbsPath;
 
     public AbstractFileName(final String scheme,
-                            final String absPath)
+                            final String absPath, FileType type)
     {
         this.rootUri = null;
         this.scheme = scheme;
+        this.type = type;
         if (absPath != null && absPath.length() > 0)
         {
-            this.absPath = absPath;
+            if (absPath.endsWith("/"))
+            {
+                this.absPath = absPath.substring(0, absPath.length() - 1);
+            }
+            else
+            {
+                this.absPath = absPath;
+            }
         }
         else
         {
@@ -74,7 +85,6 @@
      * Implement Comparable
      *
      * @param obj another abstractfilename
-     * @return
      */
     public int compareTo(Object obj)
     {
@@ -107,7 +117,7 @@
     /**
      * Factory method for creating name instances.
      */
-    public abstract FileName createName(String absPath);
+    public abstract FileName createName(String absPath, FileType type);
 
     /**
      * Builds the root URI for this file name.  Note that the root URI must not
@@ -142,14 +152,23 @@
      */
     public String getPath()
     {
+        if (VFS.isUriStyle())
+        {
+            return absPath + getUriTrailer();
+        }
         return absPath;
     }
 
+    protected String getUriTrailer()
+    {
+        return getType() == FileType.FOLDER ? "/" : "";
+    }
+
     public String getPathDecoded() throws FileSystemException
     {
         if (decodedAbsPath == null)
         {
-            decodedAbsPath = UriParser.decode(absPath);
+            decodedAbsPath = UriParser.decode(getPath());
         }
 
         return decodedAbsPath;
@@ -176,7 +195,7 @@
         {
             parentPath = getPath().substring(0, idx);
         }
-        return createName(parentPath);
+        return createName(parentPath, FileType.FOLDER);
     }
 
     /**
@@ -375,14 +394,47 @@
     }
 
     /**
+     * Returns the requested or current type of this name. <br />
+     * <p/>
+     * The "requested" type is the one determined during resolving the name. <br/>
+     * In this case the name is a {@link FileType#FOLDER} if it ends with an "/" else
+     * it will be a {@link FileType#FILE}<br/>
+     * </p>
+     * <p/>
+     * Once attached it will be changed to reflect the real type of this resource.
+     * </p>
+     *
+     * @return {@link FileType#FOLDER} or {@link FileType#FILE}
+     */
+    public FileType getType()
+    {
+        return type;
+    }
+
+    /**
+     * sets the type of this file e.g. when it will be attached.
+     *
+     * @param type {@link FileType#FOLDER} or {@link FileType#FILE}
+     */
+    void setType(FileType type) throws FileSystemException
+    {
+        if (type != FileType.FOLDER && type != FileType.FILE)
+        {
+            throw new FileSystemException("vfs.provider/filename-type.error");
+        }
+
+        this.type = type;
+    }
+
+    /**
      * Checks whether a path fits in a particular scope of another path.
      *
      * @param basePath An absolute, normalised path.
      * @param path     An absolute, normalised path.
      */
     public static boolean checkName(final String basePath,
-                              final String path,
-                              final NameScope scope)
+                                    final String path,
+                                    final NameScope scope)
     {
         if (scope == NameScope.FILE_SYSTEM)
         {
@@ -394,7 +446,13 @@
         {
             return false;
         }
-        final int baseLen = basePath.length();
+
+        int baseLen = basePath.length();
+        if (VFS.isUriStyle())
+        {
+            // strip the trailing "/"
+            baseLen--;
+        }
 
         if (scope == NameScope.CHILD)
         {

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractFileObject.java Wed Aug 31 11:18:58 2005
@@ -60,7 +60,7 @@
     // private static final FileObject[] EMPTY_FILE_ARRAY = {};
     private static final FileName[] EMPTY_FILE_ARRAY = {};
 
-    private final FileName name;
+    private final AbstractFileName name;
     private final AbstractFileSystem fs;
 
     private DefaultFileContent content;
@@ -79,7 +79,7 @@
     protected AbstractFileObject(final FileName name,
                                  final AbstractFileSystem fs)
     {
-        this.name = name;
+        this.name = (AbstractFileName) name;
         this.fs = fs;
     }
 
@@ -913,10 +913,10 @@
             catch (final Exception exc)
             {
                 throw new FileSystemException("vfs.provider/rename.error", new Object[]
-                {
-                    getName(),
-                    destFile.getName()
-                }, exc);
+                    {
+                        getName(),
+                        destFile.getName()
+                    }, exc);
             }
         }
         else
@@ -1169,7 +1169,7 @@
                 finally
                 {
                     attached = false;
-                    type = null;
+                    setFileType(null);
                     parent = null;
 
                     fs.fileDetached(this);
@@ -1217,11 +1217,11 @@
                 // now the type could already be injected by doAttach (e.g from parent to child)
                 if (type == null)
                 {
-                    type = doGetType();
+                    setFileType(doGetType());
                 }
                 if (type == null)
                 {
-                    type = FileType.IMAGINARY;
+                    setFileType(FileType.IMAGINARY);
                 }
             }
             catch (Exception exc)
@@ -1356,8 +1356,8 @@
      * files.
      */
     public void findFiles(final FileSelector selector,
-                           final boolean depthwise,
-                           final List selected) throws FileSystemException
+                          final boolean depthwise,
+                          final List selected) throws FileSystemException
     {
         try
         {
@@ -1460,7 +1460,23 @@
 
     protected void injectType(FileType fileType)
     {
-        type = fileType;
+        setFileType(fileType);
+    }
+
+    private void setFileType(FileType type)
+    {
+        if (type != FileType.IMAGINARY)
+        {
+            try
+            {
+                name.setType(type);
+            }
+            catch (FileSystemException e)
+            {
+                throw new RuntimeException(e.getMessage());
+            }
+        }
+        this.type = type;
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/GenericFileName.java Wed Aug 31 11:18:58 2005
@@ -16,6 +16,7 @@
 package org.apache.commons.vfs.provider;
 
 import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
 
 /**
  * A file name that represents a 'generic' URI, as per RFC 2396.  Consists of
@@ -41,9 +42,11 @@
                               final int defaultPort,
                               final String userName,
                               final String password,
-                              final String path)
+                              final String path,
+                              final FileType type
+    )
     {
-        super(scheme, path);
+        super(scheme, path, type);
         this.hostName = hostName;
         this.defaultPort = defaultPort;
         this.password = password;
@@ -98,7 +101,7 @@
         return defaultPort;
     }
 
-    public FileName createName(String absPath)
+    public FileName createName(String absPath, FileType type)
     {
         return new GenericFileName(
             getScheme(),
@@ -107,7 +110,8 @@
             defaultPort,
             userName,
             password,
-            absPath);
+            absPath,
+            type);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/HostFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/HostFileNameParser.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/HostFileNameParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/HostFileNameParser.java Wed Aug 31 11:18:58 2005
@@ -17,15 +17,16 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 
 /**
  * Implementation for any url based filesystem.<br />
  * Parses the url into user/password/host/port/path<br />
  * Does not handle a query string (after ?)
  *
- * @see URLFileNameParser URLFileNameParser for the implementation which also handles the query string too
  * @author imario@apache.org
  * @version $Revision$ $Date$
+ * @see URLFileNameParser URLFileNameParser for the implementation which also handles the query string too
  */
 public class HostFileNameParser extends AbstractFileNameParser
 {
@@ -55,7 +56,9 @@
         final Authority auth = extractToPath(filename, name);
 
         // Decode and normalise the file name
-        final String path = normalizePath(name);
+        UriParser.canonicalizePath(name, 0, name.length(), this);
+        FileType fileType = UriParser.normalisePath(name);
+        final String path = name.toString();
 
         return new GenericFileName(
             auth.scheme,
@@ -64,16 +67,8 @@
             defaultPort,
             auth.userName,
             auth.password,
-            path);
-    }
-
-    protected String normalizePath(final StringBuffer name)
-        throws FileSystemException
-    {
-        UriParser.canonicalizePath(name, 0, name.length(), this);
-        UriParser.normalisePath(name);
-        final String path = name.toString();
-        return path;
+            path,
+            fileType);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileName.java Wed Aug 31 11:18:58 2005
@@ -16,6 +16,7 @@
 package org.apache.commons.vfs.provider;
 
 import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
 
 /**
  * A file name for layered files.
@@ -29,9 +30,10 @@
 
     public LayeredFileName(final String scheme,
                            final FileName outerUri,
-                           final String path)
+                           final String path,
+                           final FileType type)
     {
-        super(scheme, path);
+        super(scheme, path, type);
         this.outerUri = outerUri;
     }
 
@@ -43,9 +45,9 @@
         return outerUri;
     }
 
-    public FileName createName(String path)
+    public FileName createName(String path, FileType type)
     {
-        return new LayeredFileName(getScheme(), getOuterName(), path);
+        return new LayeredFileName(getScheme(), getOuterName(), path, type);
     }
 
     protected void appendRootUri(StringBuffer buffer)

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/LayeredFileNameParser.java Wed Aug 31 11:18:58 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 
 /**
  * Implementation for layered filesystems.
@@ -54,10 +55,10 @@
 
         // Decode and normalise the path
         UriParser.canonicalizePath(name, 0, name.length(), this);
-        UriParser.normalisePath(name);
+        FileType fileType = UriParser.normalisePath(name);
         final String path = name.toString();
 
-        return new LayeredFileName(scheme, rootUri, path);
+        return new LayeredFileName(scheme, rootUri, path, fileType);
     }
 
     /**
@@ -68,7 +69,7 @@
     {
         // Looking for <name>!<abspath> (staring at the end)
         int maxlen = uri.length();
-        int pos = maxlen-1;
+        int pos = maxlen - 1;
         for (; pos > 0 && uri.charAt(pos) != '!'; pos--)
         {
         }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileName.java Wed Aug 31 11:18:58 2005
@@ -4,6 +4,7 @@
 import org.apache.commons.httpclient.util.URIUtil;
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 
 public class URLFileName extends GenericFileName
 {
@@ -16,9 +17,10 @@
                        final String userName,
                        final String password,
                        final String path,
+                       final FileType type,
                        final String queryString)
     {
-        super(scheme, hostName, port, defaultPort, userName, password, path);
+        super(scheme, hostName, port, defaultPort, userName, password, path, type);
         this.queryString = queryString;
     }
 
@@ -80,7 +82,7 @@
         return sb.toString();
     }
 
-    public FileName createName(final String absPath)
+    public FileName createName(final String absPath, FileType type)
     {
         return new URLFileName(getScheme(),
             getHostName(),
@@ -89,6 +91,7 @@
             getUserName(),
             getPassword(),
             absPath,
+            type,
             getQueryString());
     }
 

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/URLFileNameParser.java Wed Aug 31 11:18:58 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 
 /**
  * Implementation for any url based filesystem.<br />
@@ -49,7 +50,9 @@
         String queryString = UriParser.extractQueryString(name);
 
         // Decode and normalise the file name
-        final String path = normalizePath(name);
+        UriParser.canonicalizePath(name, 0, name.length(), this);
+        FileType fileType = UriParser.normalisePath(name);
+        final String path = name.toString();
 
         return new URLFileName(
             auth.scheme,
@@ -59,6 +62,7 @@
             auth.userName,
             auth.password,
             path,
+            fileType,
             queryString);
     }
 }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/UriParser.java Wed Aug 31 11:18:58 2005
@@ -17,6 +17,8 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.VFS;
 
 /**
  * Utilities for dealing with URIs.  See RFC 2396 for details.
@@ -82,12 +84,18 @@
      * <li>Removes trailing separator.
      * </ul>
      */
-    public static void normalisePath(final StringBuffer path)
+    public static FileType normalisePath(final StringBuffer path)
         throws FileSystemException
     {
+        FileType fileType = FileType.FOLDER;
         if (path.length() == 0)
         {
-            return;
+            return fileType;
+        }
+
+        if (path.charAt(path.length() - 1) != '/')
+        {
+            fileType = FileType.FILE;
         }
 
         // Adjust separators
@@ -99,7 +107,7 @@
         {
             if (path.length() == 1)
             {
-                return;
+                return fileType;
             }
             startFirstElem = 1;
         }
@@ -158,10 +166,15 @@
         }
 
         // Remove trailing separator
-        if (maxlen > 0 && path.charAt(maxlen - 1) == SEPARATOR_CHAR && maxlen > 1)
+        if (!VFS.isUriStyle())
         {
-            path.delete(maxlen - 1, maxlen);
+            if (maxlen > 0 && path.charAt(maxlen - 1) == SEPARATOR_CHAR && maxlen > 1)
+            {
+                path.delete(maxlen - 1, maxlen);
+            }
         }
+
+        return fileType;
     }
 
     /**
@@ -371,7 +384,7 @@
      */
     public static String encode(final String decodedStr)
     {
-        return encode(decodedStr,  null);
+        return encode(decodedStr, null);
     }
 
     public static String encode(final String decodedStr, final char[] reserved)
@@ -387,7 +400,7 @@
 
     public static String[] encode(String[] strings)
     {
-        for (int i = 0; i<strings.length; i++)
+        for (int i = 0; i < strings.length; i++)
         {
             strings[i] = encode(strings[i]);
         }
@@ -427,8 +440,8 @@
                 if (match)
                 {
                     // this is a reserved character, not allowed to decode
-                    index+=2;
-                    count-=2;
+                    index += 2;
+                    count -= 2;
                     continue;
                 }
 
@@ -457,7 +470,7 @@
         {
             if (name.charAt(pos) == '?')
             {
-                String queryString = name.substring(pos+1);
+                String queryString = name.substring(pos + 1);
                 name.delete(pos, name.length());
                 return queryString;
             }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/compressed/CompressedFileFileProvider.java Wed Aug 31 11:18:58 2005
@@ -20,6 +20,7 @@
 import org.apache.commons.vfs.FileSystem;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.AbstractLayeredFileProvider;
 import org.apache.commons.vfs.provider.FileProvider;
 import org.apache.commons.vfs.provider.LayeredFileName;
@@ -69,7 +70,7 @@
         throws FileSystemException
     {
         final FileName name =
-            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH);
+            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
         return createFileSystem(name, file, fileSystemOptions);
     }
 

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/jar/JarFileProvider.java Wed Aug 31 11:18:58 2005
@@ -21,6 +21,7 @@
 import org.apache.commons.vfs.FileSystem;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.LayeredFileName;
 import org.apache.commons.vfs.provider.zip.ZipFileProvider;
 
@@ -47,13 +48,13 @@
         Collection combined = new ArrayList();
         combined.addAll(ZipFileProvider.capabilities);
         combined.addAll(Arrays.asList(new Capability[]
-        {
-            Capability.ATTRIBUTES,
-            Capability.FS_ATTRIBUTES,
-            Capability.SIGNING,
-            Capability.MANIFEST_ATTRIBUTES,
-            Capability.VIRTUAL
-        }));
+            {
+                Capability.ATTRIBUTES,
+                Capability.FS_ATTRIBUTES,
+                Capability.SIGNING,
+                Capability.MANIFEST_ATTRIBUTES,
+                Capability.VIRTUAL
+            }));
         capabilities = Collections.unmodifiableCollection(combined);
     }
 
@@ -76,7 +77,7 @@
         throws FileSystemException
     {
         final FileName name =
-            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH);
+            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
         return new JarFileSystem(name, file, fileSystemOptions);
     }
 

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/GenericFileNameParser.java Wed Aug 31 11:18:58 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 
 /**
  * A general-purpose file name parser.
@@ -31,6 +32,7 @@
 
     /**
      * retrieve a instance to this parser
+     *
      * @return the parser
      */
     public static GenericFileNameParser getInstance()
@@ -62,8 +64,8 @@
      * here the rootFilename can only be "/" (see above) put this "/" is also in the pathname
      * so its of no value for the LocalFileName instance
      */
-    protected FileName createFileName(String scheme, final String rootFile, final String path)
+    protected FileName createFileName(String scheme, final String rootFile, final String path, final FileType type)
     {
-        return new LocalFileName(scheme, "", path);
+        return new LocalFileName(scheme, "", path, type);
     }
 }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java Wed Aug 31 11:18:58 2005
@@ -16,6 +16,7 @@
 package org.apache.commons.vfs.provider.local;
 
 import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.AbstractFileName;
 
 /**
@@ -30,9 +31,10 @@
 
     protected LocalFileName(final String scheme,
                             final String rootFile,
-                            final String path)
+                            final String path,
+                            final FileType type)
     {
-        super(scheme, path);
+        super(scheme, path, type);
         this.rootFile = rootFile;
     }
 
@@ -47,9 +49,9 @@
     /**
      * Factory method for creating name instances.
      */
-    public FileName createName(final String path)
+    public FileName createName(final String path, FileType type)
     {
-        return new LocalFileName(getScheme(), rootFile, path);
+        return new LocalFileName(getScheme(), rootFile, path, type);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileNameParser.java Wed Aug 31 11:18:58 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.AbstractFileNameParser;
 import org.apache.commons.vfs.provider.UriParser;
 import org.apache.commons.vfs.provider.VfsComponentContext;
@@ -75,14 +76,15 @@
         final String rootFile = extractRootPrefix(filename, name);
 
         // Normalise the path
-        UriParser.normalisePath(name);
+        FileType fileType = UriParser.normalisePath(name);
         final String path = name.toString();
 
         return createFileName(
             scheme,
             rootFile,
-            path);
+            path,
+            fileType);
     }
 
-    protected abstract FileName createFileName(String scheme, final String rootFile, final String path);
+    protected abstract FileName createFileName(String scheme, final String rootFile, final String path, final FileType type);
 }

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileName.java Wed Aug 31 11:18:58 2005
@@ -16,6 +16,7 @@
 package org.apache.commons.vfs.provider.local;
 
 import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
 
 /**
  * A local file URI.
@@ -27,17 +28,18 @@
 {
     protected WindowsFileName(final String scheme,
                               final String rootFile,
-                              final String path)
+                              final String path,
+                              final FileType type)
     {
-        super(scheme, rootFile, path);
+        super(scheme, rootFile, path, type);
     }
 
     /**
      * Factory method for creating name instances.
      */
-    public FileName createName(final String path)
+    public FileName createName(final String path, FileType type)
     {
-        return new WindowsFileName(getScheme(), getRootFile(), path);
+        return new WindowsFileName(getScheme(), getRootFile(), path, type);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/WindowsFileNameParser.java Wed Aug 31 11:18:58 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 
 /**
  * A parser for Windows file names.
@@ -37,9 +38,9 @@
         return extractWindowsRootPrefix(uri, name);
     }
 
-    protected FileName createFileName(String scheme, final String rootFile, final String path)
+    protected FileName createFileName(String scheme, final String rootFile, final String path, final FileType type)
     {
-        return new WindowsFileName(scheme, rootFile, path);
+        return new WindowsFileName(scheme, rootFile, path, type);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileName.java Wed Aug 31 11:18:58 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.GenericFileName;
 
 /**
@@ -42,9 +43,10 @@
         final String password,
         final String domain,
         final String share,
-        final String path)
+        final String path,
+        final FileType type)
     {
-        super(scheme, hostName, port, DEFAULT_PORT, userName, password, path);
+        super(scheme, hostName, port, DEFAULT_PORT, userName, password, path, type);
         this.share = share;
         this.domain = domain;
     }
@@ -84,7 +86,7 @@
     /**
      * Factory method for creating name instances.
      */
-    public FileName createName(final String path)
+    public FileName createName(final String path, FileType type)
     {
         return new SmbFileName(
             getScheme(),
@@ -94,7 +96,8 @@
             getPassword(),
             domain,
             share,
-            path);
+            path,
+            type);
     }
 
     /**

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/smb/SmbFileNameParser.java Wed Aug 31 11:18:58 2005
@@ -17,6 +17,7 @@
 
 import org.apache.commons.vfs.FileName;
 import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.FileNameParser;
 import org.apache.commons.vfs.provider.URLFileNameParser;
 import org.apache.commons.vfs.provider.UriParser;
@@ -67,7 +68,7 @@
 
         // Normalise the path.  Do this after extracting the share name,
         // to deal with things like smb://hostname/share/..
-        UriParser.normalisePath(name);
+        FileType fileType = UriParser.normalisePath(name);
         final String path = name.toString();
 
         return new SmbFileName(
@@ -78,7 +79,8 @@
             auth.password,
             domain,
             share,
-            path);
+            path,
+            fileType);
     }
 
     private String extractDomain(String username)

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/tar/TarFileProvider.java Wed Aug 31 11:18:58 2005
@@ -21,6 +21,7 @@
 import org.apache.commons.vfs.FileSystem;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.AbstractLayeredFileProvider;
 import org.apache.commons.vfs.provider.FileProvider;
 import org.apache.commons.vfs.provider.LayeredFileName;
@@ -37,14 +38,14 @@
     implements FileProvider
 {
     protected final static Collection capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[]
-    {
-        Capability.GET_LAST_MODIFIED,
-        Capability.GET_TYPE,
-        Capability.LIST_CHILDREN,
-        Capability.READ_CONTENT,
-        Capability.URI,
-        Capability.VIRTUAL
-    }));
+        {
+            Capability.GET_LAST_MODIFIED,
+            Capability.GET_TYPE,
+            Capability.LIST_CHILDREN,
+            Capability.READ_CONTENT,
+            Capability.URI,
+            Capability.VIRTUAL
+        }));
 
     public TarFileProvider()
     {
@@ -65,7 +66,7 @@
         throws FileSystemException
     {
         final FileName rootName =
-            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH);
+            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
         return new TarFileSystem(rootName, file, fileSystemOptions);
     }
 

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/temp/TemporaryFileProvider.java Wed Aug 31 11:18:58 2005
@@ -20,6 +20,7 @@
 import org.apache.commons.vfs.FileSystem;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.AbstractFileProvider;
 import org.apache.commons.vfs.provider.FileProvider;
 import org.apache.commons.vfs.provider.UriParser;
@@ -92,7 +93,7 @@
         // Parse the name
         final StringBuffer buffer = new StringBuffer(uri);
         final String scheme = UriParser.extractScheme(uri, buffer);
-        UriParser.normalisePath(buffer);
+        FileType fileType = UriParser.normalisePath(buffer);
         final String path = buffer.toString();
 
         // Create the temp file system if it does not exist

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/url/UrlFileName.java Wed Aug 31 11:18:58 2005
@@ -1,7 +1,7 @@
 package org.apache.commons.vfs.provider.url;
 
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.URLFileName;
-import org.apache.commons.vfs.provider.UriParser;
 
 /**
  * Created by IntelliJ IDEA.
@@ -12,9 +12,9 @@
  */
 public class UrlFileName extends URLFileName
 {
-    public UrlFileName(final String scheme, final String hostName, final int port, final int defaultPort, final String userName, final String password, final String path, final String queryString)
+    public UrlFileName(final String scheme, final String hostName, final int port, final int defaultPort, final String userName, final String password, final String path, final FileType type, final String queryString)
     {
-        super(scheme, hostName, port, defaultPort, userName, password, path, queryString);
+        super(scheme, hostName, port, defaultPort, userName, password, path, type, queryString);
     }
 
     protected void appendRootUri(final StringBuffer buffer)

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java?rev=265540&r1=265539&r2=265540&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/provider/zip/ZipFileProvider.java Wed Aug 31 11:18:58 2005
@@ -21,6 +21,7 @@
 import org.apache.commons.vfs.FileSystem;
 import org.apache.commons.vfs.FileSystemException;
 import org.apache.commons.vfs.FileSystemOptions;
+import org.apache.commons.vfs.FileType;
 import org.apache.commons.vfs.provider.AbstractLayeredFileProvider;
 import org.apache.commons.vfs.provider.FileProvider;
 import org.apache.commons.vfs.provider.LayeredFileName;
@@ -40,15 +41,15 @@
     implements FileProvider
 {
     protected final static Collection capabilities = Collections.unmodifiableCollection(Arrays.asList(new Capability[]
-    {
-        Capability.GET_LAST_MODIFIED,
-        Capability.GET_TYPE,
-        Capability.LIST_CHILDREN,
-        Capability.READ_CONTENT,
-        Capability.URI,
-        Capability.COMPRESS,
-        Capability.VIRTUAL
-    }));
+        {
+            Capability.GET_LAST_MODIFIED,
+            Capability.GET_TYPE,
+            Capability.LIST_CHILDREN,
+            Capability.READ_CONTENT,
+            Capability.URI,
+            Capability.COMPRESS,
+            Capability.VIRTUAL
+        }));
 
     public ZipFileProvider()
     {
@@ -69,7 +70,7 @@
         throws FileSystemException
     {
         final FileName rootName =
-            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH);
+            new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER);
         return new ZipFileSystem(rootName, file, fileSystemOptions);
     }
 



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