Author: imario
Date: Mon Mar  7 23:47:22 2005
New Revision: 156508

URL: http://svn.apache.org/viewcvs?view=rev&rev=156508
Log:
directly create the LocalFileName from an java.io.File (or its path) to avoid 
uri-encoding/decoding back and forth.

Modified:
    
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
    
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java
    
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java

Modified: 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java?view=diff&r1=156507&r2=156508
==============================================================================
--- 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
 (original)
+++ 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/AbstractOriginatingFileProvider.java
 Mon Mar  7 23:47:22 2005
@@ -1,12 +1,12 @@
 /*
  * Copyright 2002, 2003,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -64,7 +64,7 @@
     /**
      * Locates a file from its parsed URI.
      */
-    private synchronized FileObject findFile(final FileName name, final 
FileSystemOptions fileSystemOptions)
+    protected synchronized FileObject findFile(final FileName name, final 
FileSystemOptions fileSystemOptions)
         throws FileSystemException
     {
         // Check in the cache for the file system

Modified: 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java?view=diff&r1=156507&r2=156508
==============================================================================
--- 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java
 (original)
+++ 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/DefaultLocalFileProvider.java
 Mon Mar  7 23:47:22 2005
@@ -88,9 +88,11 @@
     public FileObject findLocalFile(final String name)
         throws FileSystemException
     {
-        // TODO - tidy this up, no need to turn the name into an absolute URI,
-        // and then straight back again
-        return findFile(null, "file:" + name, null);
+        StringBuffer uri = new StringBuffer(name.length() + 5);
+        uri.append("file:");
+        uri.append(name);
+        FileName filename = parseUri(uri.toString(), false);
+        return findFile(filename, null);
     }
 
     /**
@@ -99,8 +101,16 @@
     public FileObject findLocalFile(final File file)
         throws FileSystemException
     {
-        // TODO - tidy this up, should build file object straight from the file
-        return findFile(null, "file:" + file.getAbsolutePath(), null);
+        return findLocalFile(file.getAbsolutePath());
+    }
+
+    /**
+     * Parses a URI.
+     */
+    protected FileName parseUri(final String uri, final boolean uriEncoded)
+        throws FileSystemException
+    {
+        return LocalFileName.parseUri(uri, uriEncoded, parser);
     }
 
     /**
@@ -109,7 +119,7 @@
     protected FileName parseUri(final String uri)
         throws FileSystemException
     {
-        return LocalFileName.parseUri(uri, parser);
+        return parseUri(uri, true);
     }
 
     /**

Modified: 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java?view=diff&r1=156507&r2=156508
==============================================================================
--- 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
 (original)
+++ 
jakarta/commons/sandbox/vfs/trunk/src/java/org/apache/commons/vfs/provider/local/LocalFileName.java
 Mon Mar  7 23:47:22 2005
@@ -1,12 +1,12 @@
 /*
  * Copyright 2002, 2003,2004 The Apache Software Foundation.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -44,7 +44,7 @@
      *
      * @todo Make parser a static field
      */
-    public static LocalFileName parseUri(final String uri,
+    public static LocalFileName parseUri(final String uri, final boolean 
uriEncoded,
                                          final LocalFileNameParser parser)
         throws FileSystemException
     {
@@ -54,7 +54,10 @@
         final String scheme = UriParser.extractScheme(uri, name);
 
         // Remove encoding, and adjust the separators
-        UriParser.decode(name, 0, name.length());
+        if (uriEncoded)
+        {
+            UriParser.decode(name, 0, name.length());
+        }
         UriParser.fixSeparators(name);
 
         // Extract the root prefix



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to