How to .resolve*() and .relativize() Paths which are not issued from the same FileSystem?

Alan Bateman Alan.Bateman at oracle.com
Sun Nov 30 09:06:40 UTC 2014


On 29/11/2014 17:01, Francis Galiegue wrote:
> Hello,
>
> I am writing a generic java.nio.file API to allow users to implement
> FileSystem over various stuff (for instance, DropBox and Google Drive
> come to mind) but I have trouble with the methods mentioned in the
> subject.
>
> Let us suppose DropBox. I link the provider to URI scheme "dropbox".
>
> Now, I create two FileSystems out of the provider, on two different
> accounts. If I have a path issued from one provider and another issued
> from the second, at a first glance it does not make any sense to
> resolve/relativize one against the other.
I'm curious as to why you would disallow this? They may be to different 
dropbox accounts but I assume the file path syntax is the same and they 
have the same internal representation (as they are associated with the 
same file system provider). So if someone is moving a file from a folder 
in one dropbox account to another then I would expect it to work and for 
it not to loose the file name representation as part of the move.

-Alan


>
> However, the javadoc of java.nio.file only covers the case of
> different _providers_ for two different paths: "Unless otherwise
> noted, invoking a method of any class or interface in this package
> created by one provider with a parameter that is an object created by
> another provider, will throw ProviderMismatchException."
>
> And there is no such exception as FileSystemMismatchException defined;
> so, how do I handle this case? Do I define this (unchecked) exception?
> Should the documentation be updated to account for "incompatible"
> FileSystems? Do I throw ProviderMismatchException anyway?
>



More information about the nio-dev mailing list