[Jboss-cvs] JBossAS SVN: r55524 - projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 11 10:27:25 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-08-11 10:27:23 -0400 (Fri, 11 Aug 2006)
New Revision: 55524

Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/FileImpl.java
   projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/FileSystemVFS.java
Log:
Ensure that the URL of a VFS corresponding to a directory ends in '/' so that URLs created relative to it are under the directory.

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/FileImpl.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/FileImpl.java	2006-08-11 14:26:47 UTC (rev 55523)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/FileImpl.java	2006-08-11 14:27:23 UTC (rev 55524)
@@ -48,6 +48,13 @@
    private transient List<VirtualFile> recursiveChildren;
    private transient InputStream contentIS;
 
+   /**
+    * Create a FileImpl from a File.
+    * @param file - the File instance
+    * @param vfsPath - the path relative to the vfs root for this file
+    * @param vfs - the VFS containing file
+    * @throws IOException - thrown if file.exists() == false
+    */
    public FileImpl(URL path, String vfsPath, FileSystemVFS vfs)
       throws IOException
    {
@@ -56,8 +63,21 @@
       this.file = new File(path.getPath());
       if( file.exists() == false )
          throw new FileNotFoundException(file.getCanonicalPath());
+      // If this is a directory and vfsPath does not end in '/', rebuild path, vfsPath
+      if( file.isDirectory() && vfsPath.endsWith("/") == false )
+      {
+         this.vfsPath += '/';
+         this.path = new URL(vfs.getRootURL(), this.vfsPath);
+      }
       this.vfs = vfs;
    }
+   /**
+    * Create a FileImpl from a File.
+    * @param file - the File instance
+    * @param vfsPath - the path relative to the vfs root for this file
+    * @param vfs - the VFS containing file
+    * @throws IOException - thrown if file.exists() == false
+    */
    public FileImpl(File file, String vfsPath, FileSystemVFS vfs)
       throws IOException
    {

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/FileSystemVFS.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/FileSystemVFS.java	2006-08-11 14:26:47 UTC (rev 55523)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/vfs/file/FileSystemVFS.java	2006-08-11 14:27:23 UTC (rev 55524)
@@ -218,9 +218,12 @@
                }
                else
                {
-                  URL atomParentURL = prevVF == null ? rootURL : prevVF.toURL();
-                  URL filePath = new URL(atomParentURL, atom);
-                  atomVF = new FileImpl(filePath, atomPath, this);
+                  /* The file needs to be created with a valid URL that ends in '/'
+                     if the file is a directory. Creating a FileImpl from a File
+                     handles this.
+                  */
+                  File atomFile = new File(absPath, atom);
+                  atomVF = new FileImpl(atomFile, atomPath, this);
                }
                fileCache.put(atomPath, atomVF);
                prevVF = atomVF;




More information about the jboss-cvs-commits mailing list