commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Poulard <Philippe.Poul...@sophia.inria.fr>
Subject Re: [VFS] bug ?
Date Fri, 19 Aug 2005 12:13:53 GMT
Torsten Curdt wrote:
> 
> On 19.08.2005, at 10:07, Philippe Poulard wrote:
> 
>> hi Mario,
>>
>> there is a bug in VFS RC3 :
>>
>> StandardFileSystemManager fsm = null;
>> fsm = (StandardFileSystemManager) VFS.getManager();
>> fsm.setBaseFile( new File( System.getProperty( "user.dir" ) ) );
>> fsm.setDefaultProvider( new UrlFileProvider() );
>> FileObject fo = fsm.resolveFile( "file:///path/to/file" );
>> System.out.println( fsm.resolveFile( fo, "file:///chemin/vers/ 
>> fichier" ) );
>> System.out.println( fsm.resolveFile( fo, "/chemin/vers/fichier" ) );
>> System.out.println( fsm.resolveFile( fo, "chemin/vers/fichier" ) );
>>
>> output is :
>>
>> file:///chemin/vers/fichier
>> file:///chemin/vers/fichier
>> file:///path/to/file/chemin/vers/fichier
>>
>> the last must be :
>>
>> file:///path/to/chemin/vers/fichier
>>
>> the same with java.net.URI gives the right result :
>>
>> URI uri = new URI( "file:///path/to/file" );
>> System.out.println( uri.resolve( "file:///chemin/vers/fichier" ) );
>> System.out.println( uri.resolve( "/chemin/vers/fichier" ) );
>> System.out.println( uri.resolve( "chemin/vers/fichier" ) );
> 
> 
> Maybe the URI class is a bit smarter
> but why would you use a *file* as a
> base anyway????

well, it's somewhat obvious :

when you load an HTML document from a web server, you have :
http://www.acme.com/path/to/document.html
if the document contain :
<img src="picture.jpg"/>
<link rel="stylesheet" href="style.css">
both will be resolved according to the document location :
http://www.acme.com/path/to/picture.jpg
http://www.acme.com/path/to/style.css

i think there are many other examples where FILES are referencing 
resources they are using

> 
> VFS should probably check whether it's
> a dir and if not use the parent.

this is not a question of "is it a dir or a file"

if it doesn't end with "/", it must be resolved regarding the parent
if it ends with "/", just append the relative path

> 
> But IMHO the above example looks more
> like a wrong use of the API.

see RFCxxx about URIs

> 
> my 2 cents
> 
> cheers
> -- 
> Torsten

thanks for your reply
-- 
Cordialement,

            ///
           (. .)
  -----ooO--(_)--Ooo-----
|   Philippe Poulard    |
  -----------------------

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


Mime
View raw message