You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@excalibur.apache.org by cz...@apache.org on 2007/03/29 11:31:16 UTC

svn commit: r523650 - /excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/FileSource.java

Author: cziegeler
Date: Thu Mar 29 02:31:15 2007
New Revision: 523650

URL: http://svn.apache.org/viewvc?view=rev&rev=523650
Log:
Fix for some problems with file url handling as discussed recently

Modified:
    excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/FileSource.java

Modified: excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/FileSource.java
URL: http://svn.apache.org/viewvc/excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/FileSource.java?view=diff&rev=523650&r1=523649&r2=523650
==============================================================================
--- excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/FileSource.java (original)
+++ excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/FileSource.java Thu Mar 29 02:31:15 2007
@@ -80,7 +80,7 @@
 
     /**
      * Builds a FileSource, given an URI scheme and a File.
-     * 
+     *
      * @param scheme
      * @param file
      * @throws SourceException
@@ -98,6 +98,13 @@
         try
         {
             uri = file.toURL().toExternalForm();
+            // toExternalForm() is buggy, see e.g. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4924415
+            // therefore we check if file: is followed by just one slash
+            // TODO when we move to JDK 1.4+, we should use file.toURI().toASCIIString() instead.
+            if ( uri.length() > 6 && uri.startsWith("file:/") && uri.charAt(6) != '/' )
+            {
+                uri = "file://" + uri.substring(6);
+            }
         }
         catch (MalformedURLException mue)
         {
@@ -186,7 +193,7 @@
 
     /**
      * Return a validity object based on the file's modification date.
-     * 
+     *
      * @see org.apache.excalibur.source.Source#getValidity()
      */
     public SourceValidity getValidity()
@@ -390,11 +397,11 @@
         {
             throw new SourceNotFoundException("Cannot delete non-existing file " + m_file.toString());
         }
-        
+
         if (!m_file.delete())
         {
             throw new SourceException("Could not delete " + m_file.toString() + " (unknown reason)");
-        } 
+        }
     }
 
     //----------------------------------------------------------------------------------
@@ -490,10 +497,10 @@
                         m_source.getFile().delete();
                     }
                     // Rename temp file to destination file
-                    if (!m_tmpFile.renameTo(m_source.getFile())) 
+                    if (!m_tmpFile.renameTo(m_source.getFile()))
                     {
-                       throw new IOException("Could not rename " + 
-                         m_tmpFile.getAbsolutePath() + 
+                       throw new IOException("Could not rename " +
+                         m_tmpFile.getAbsolutePath() +
                          " to " + m_source.getFile().getAbsolutePath());
                     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org