[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-nio-dev
Subject:    Re: RFR: 8057113: (fs) Path should have a method to obtain the filename extension [v8]
From:       Brian Burkhalter <bpb () openjdk ! java ! net>
Date:       2021-05-27 19:37:10
Message-ID: SOj-rHHC-iCSP9n-BJklRGv7581mNTd3kJbw2FMPtSc=.f7b5063a-b8f3-491e-bc1e-27078a8d56af () github ! com
[Download RAW message or body]

On Fri, 12 Mar 2021 21:33:18 GMT, Brian Burkhalter <bpb@openjdk.org> wrote:

> > Please review this proposed change to add a method \
> > `java.nio.file.Path.getExtension()`. This was initially discussed in the thread \
> > http://mail.openjdk.java.net/pipermail/nio-dev/2018-February/004716.html. This \
> > method would return the filename extension of the file name of the `Path`. The \
> > extension is defined to be the portion of the file name after the last dot \
> > `(‘.')`. 
> > The definitions of file extension for about fifteen platforms and languages were \
> > surveyed to try to find a reasonable compromise for the definition of extension. \
> > The most common definition was the last segment of the name including and after \
> > the last dot. The second definition omitted the last dot from the extension. \
> > Java-related platforms all exclude the last dot. (One divergent definition in the \
> > internal Java NIO method `AbstractFileTypeDetector.getExtension(String)` defines \
> > the extension as the part after the *first* dot.) 
> > All examined cases define the extension to be an empty string if it cannot be \
> > determined. None of these cases used `null` to represent an indeterminate \
> > extension. 
> > Little in the way of specifying behavior for special cases (consisting mainly of \
> > file names with one or more leading dots) was found. Most definitions concern \
> > themselves only with the last dot and what comes after it and ignore leading dots \
> > altogether. A few definitions ignore a leading dot at the zeroth character. The \
> > current proposal ignores a dot at character zero. 
> > The behavior of the proposed method for some example cases is as:
> > 
> > 
> > .              -> 
> > ..             -> 
> > .a.b           -> b
> > ......         -> 
> > .....a         -> a
> > ....a.b        -> b
> > ..foo          -> foo
> > test.rb        -> rb
> > a/b/d/test.rb  -> rb
> > .a/b/d/test.rb -> rb
> > foo.           -> 
> > test           -> 
> > .profile       -> 
> > .profile.sh    -> sh
> > ..foo          -> foo
> > .....foo       -> foo
> > .vimrc         -> 
> > test.          -> 
> > test..         -> 
> > test...        -> 
> > foo.tar.gz     -> gz
> > foo.bar.       -> 
> > image.jpg      -> jpg
> > music.mp3      -> mp3
> > video.mp4      -> mp4
> > document.txt   -> txt
> > foo.tar.gz     -> gz
> > foo.bar.       ->
> 
> Brian Burkhalter has updated the pull request incrementally with one additional \
> commit since the last revision: 
> 8057113: Change first sentence; change param name

PR extension.

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

PR: https://git.openjdk.java.net/jdk/pull/2319


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic