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

Francis Galiegue fgaliegue at gmail.com
Mon Dec 1 19:13:45 UTC 2014


On Mon, Dec 1, 2014 at 9:52 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> On 30/11/2014 21:47, Francis Galiegue wrote:
>>
>> :
>> OK, that makes sense -- however I didn't know that the first path was
>> valid at all; or even whether it can represent anything at all...
>
> It just provides access to file "foo" in the working directory of drive
> "C:".
>

OK, thanks for the information...

>
>
>> :
>> Well, if you cannot convert from/to the necessary byte array, you are
>> supposed to throw an InvalidPathException, correct? In UnixPath I see
>> that a Charset{De,En}coder is used for these purposes with a
>> CodingErrorAction of REPORT.
>
> As it's all the one file system provider then you shouldn't need to do any
> encoding or decoding.
>

I was talking about _different_ providers here. Which makes me wonder,
while we are at it, why the code for decoding/encoding path names is
in UnixPath at all... (side note: short of changing the system
encoding, you cannot alter the behaviour of this {de,en}coding
process)

>>
>> And there's even a contradiction there: what is "the empty path"? An
>> empty path attached to the file system of "path" or "other"? On Linux,
>> it returns "other" unconditionally, which says it's the first part
>> which takes precedence.
>>
>> So, should this last part of the documentation be removed?
>>
> The empty path is defined is in the class description. I don't see any
> obvious with the resolveSibling's javadoc, it' just trying to be explicit as
> to how it behaves when the the path or given path is the empty path.
>

As I said: an empty path _for which filesystem_? The one associated
with the path you try to .resolveSibling() against or the one of the
path given as an argument? This is what the documentation is not clear
about (without even going to the provider level).

-- 
Francis Galiegue, fgaliegue at gmail.com, https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/parboiled1/grappa (redde
Caesaris: https://github.com/sirthias)


More information about the nio-dev mailing list