adammurdoch    2002/10/31 19:18:48

  Modified:    vfs/src/java/org/apache/commons/vfs/provider
                        AbstractFileSystem.java
  Log:
  - Added getRootName().
  - resolveFile( FileName ) now checks that the supplied name is actually a name from 
the file system.
  
  Revision  Changes    Path
  1.13      +15 -5     
jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java
  
  Index: AbstractFileSystem.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/AbstractFileSystem.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AbstractFileSystem.java   31 Oct 2002 10:35:18 -0000      1.12
  +++ AbstractFileSystem.java   1 Nov 2002 03:18:48 -0000       1.13
  @@ -55,15 +55,15 @@
    */
   package org.apache.commons.vfs.provider;
   
  +import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Map;
  -import java.util.ArrayList;
  +import org.apache.commons.vfs.FileChangeEvent;
  +import org.apache.commons.vfs.FileListener;
   import org.apache.commons.vfs.FileName;
   import org.apache.commons.vfs.FileObject;
  -import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.FileSystem;
  -import org.apache.commons.vfs.FileListener;
  -import org.apache.commons.vfs.FileChangeEvent;
  +import org.apache.commons.vfs.FileSystemException;
   import org.apache.commons.vfs.util.Messages;
   
   /**
  @@ -106,6 +106,12 @@
       protected abstract FileObject createFile( final FileName name )
           throws FileSystemException;
   
  +    /** Returns the name of the root of this file system. */ 
  +    protected FileName getRootName()
  +    {
  +        return rootName;
  +    }
  +
       /**
        * Adds a file object to the cache.
        */
  @@ -176,7 +182,11 @@
        */
       public FileObject resolveFile( final FileName name ) throws FileSystemException
       {
  -        // TODO - assert that name is from this file system
  +        if ( !rootName.getRootURI().equals( name.getRootURI() ) )
  +        {
  +            throw new FileSystemException( 
"vfs.provider/mismatched-fs-for-name.error", new Object[] { name, rootName } );
  +        }
  +
           FileObject file = (FileObject)files.get( name );
           if ( file == null )
           {
  
  
  

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

Reply via email to