RFR: 8298318: (fs) APIs for handling filename extensions [v2]
Roger Riggs
rriggs at openjdk.org
Wed Nov 22 17:41:12 UTC 2023
On Mon, 20 Nov 2023 23:30:45 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Add to `java.nio.file.Path` a method `getExtension` to retrieve the `Path`'s extension, and companion methods `removeExtension` and `addExtension`.
>
> Brian Burkhalter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>
> - 8298318: Correct type in path.getExtension spec
> - Merge
> - 8298318: (fs) APIs for handling filename extensions
I thought we were moving away from the addExtension/removeExtension methods to the recommendation for `withExtension` and `withoutExtension`.
They have more useful semantics and avoid having to through multiple intermediate Paths to get to the desired result.
They could include (some) OS specific semantics while producing the useful and easy to understand result.
The APIs should not require the developer to be aware of and code around OS specific details.
For an outlier like ".gitconfig" they won't be using any of these functions, that's the full file name, semantically it does not have an extension and certainly one would not consider the leading "." to be the base name without the extension; that would be a directory. Even if the "." were considered to be part of the extension, that would leave the empty string as the base and is not meaningful if its empty.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16226#issuecomment-1823209088
More information about the nio-dev
mailing list