neilcsmith-net commented on code in PR #9820:
URL: https://github.com/apache/netbeans/pull/9820#discussion_r4681242575
##########
platform/openide.filesystems/src/org/openide/filesystems/FileUtil.java:
##########
@@ -833,16 +833,30 @@ public static File toFile(FileObject fo) {
return retVal;
}
- /** Finds appropriate java.nio.file.Path to FileObject if possible.
- * If not possible then null is returned.
- * This is the inverse operation of {@link #toFileObject}.
- * @param fo FileObject whose corresponding Path will be looked for
- * @return java.nio.file.Path or null if no corresponding File exists.
+ /** Finds appropriate {@link Path} for given {@code FileObject}.
+ * Since version <em>9.50</em> it is guaranteed that the return value
+ * <em>will never be {@code null}</em> for an object with valid {@link
FileObject#getFileSystem()}.
+ * A fully functional {@link Path}
+ * instance is created even for fully virtual {@code FileObject}s.
+ *
+ * This is the inverse operation of {@link
#toFileObject(java.nio.file.Path) }.
+ * @param fo object to find corresponding Path for
+ * @return {@link Path} for the {@code FileObject} never {@code null}
+ *
* @since 9.32
*/
public static Path toPath(FileObject fo) {
+ Parameters.notNull("fo", fo);
File f = toFile(fo);
Review Comment:
> it should be listed in [this
table](https://bits.netbeans.org/dev/javadoc/org-openide-filesystems/index.html#group-property)
Yes, I checked there before commenting. Would have thought there and/or in
the Javadoc for the method?
> ...for the future I'd like to do something bigger:
> let us **add** `FileObject implements Path`!
Every `FileObject` _having_ a `Path` sounds great. Every `FileObject`
_being_ a `Path` might not be so good an idea. Paths from the same provider
are special cased (eg. in
[`Files::copy`](https://github.com/openjdk/jdk/blob/99bec664cde9783be19ec58a8de826699a6d1001/src/java.base/share/classes/java/nio/file/Files.java#L1190)
and the providers expect to be able to cast to implementation (eg.
[`UnixPath`](https://github.com/openjdk/jdk/blob/99bec664cde9783be19ec58a8de826699a6d1001/src/java.base/unix/classes/sun/nio/fs/UnixPath.java#L173)).
That means that a `FileObject` from `masterfs` would bypass the optimal
same-provider pathways.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists