Specify behavior of *Path::RelativeTo
for cases when it's impossible to build a relative path
#40
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
On Unix file system, it's always possible to build a relative path between two paths. On Windows, however, it is not universally possible: say, between different disks or between a DOS device and a disk. The latter aspect often surprises people when they use
java.nio.file.Path::relativize
(that throws an exception), so we better do something else: either show the nature of the method in its type, or invent an alternate behavior.Also, it is not possible between network shares.
We should decide and document the behavior of this method for these cases.
I am thinking about leaving a strict method that would return
null
for cases when it was unable to build a path, and a separate lax method likeRelativeToIfPossible
that would returnthis
for such cases.The text was updated successfully, but these errors were encountered: