RFR: 8298318: (fs) APIs for handling filename extensions [v2]

Anthony Vanelverdinghe duke at openjdk.org
Fri Dec 1 07:25:07 UTC 2023


On Thu, 30 Nov 2023 20:29:24 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> Developers that are working with dot-files, know it and won't be looking for file extensions at all.

I assume you're using "dot-files" in a very strict sense here, thinking of specific examples such as `.gitconfig` or `.bashrc`. Because in the sense I'm accustomed to, "a file starting with a dot", surely such files can have file extensions and I'd want to look for those extensions.

> They also know whether the files they are working with have extensions [...]

If I'd be making anything generic, like an implementation of `find` or a file explorer or whatnot, how would I be able to know whether any given file has an extension? I wouldn't, which is exactly what I'd use this API for.

> The API will be practical and easy to use even if it ignores the leading dots (as do Guava and Apache Commons).

What do you mean with this, esp. "as do Guava and Apache Commons"? Because [just a few days ago](https://github.com/openjdk/jdk/pull/16226#issuecomment-1828339847) I demonstrated that both Guava and Apache Commons do *not* ignore the leading dots, both in specification and implementation.

> It will also be consistent with other APIs in OpenJDK that look at extensions including Files.probeContentType.

What do you mean with this? Because on Windows, `Files.probeContentType(Path.of("C:\\Music\.mp3"))` returns `audio/mpeg`, as I'd expect (FWIW, I used an empty file to make sure the probing used the filename and not the file's content).

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16226#issuecomment-1835602751


More information about the nio-dev mailing list