RFR 8057113: (fs) Path should have a method to test the filename extension
daniel.fuchs at oracle.com
Fri Feb 16 18:32:41 UTC 2018
As David noted, .vimrc is a filename - not an extension,
and the Unix/Linux basename command will treat it as such:
$ basename ~/.vimrc .vimrc
I think we should try to honor this expectation.
$ basename ~/.vimrc.vimrc .vimrc
So would the code below work?
String filename = Optional.ofNullable(getFilename())
int index = filename.lastIndexOf('.');
if (index > 0) return filename.substring(index+1);
else return ""
On 16/02/2018 18:06, Brian Burkhalter wrote:
> On Feb 16, 2018, at 8:48 AM, Brian Burkhalter
> <brian.burkhalter at oracle.com <mailto:brian.burkhalter at oracle.com>> wrote:
>> On Feb 16, 2018, at 6:26 AM, David Lloyd <david.lloyd at redhat.com
>> <mailto:david.lloyd at redhat.com>> wrote:
>>> If lastDot is 0 or all the characters preceding lastDot are '.' then
>>> "" should be returned as well; this for example will not only return
>>> wrong results for ".." but also e.g. ".vimrc".
>> You are correct about “.vimrc” but the other cases appear to pass
>> (expected result in the test is “” for these four cases):
> This seems to be getting too complicated with all the special cases.
> Perhaps this should just be re-specified simply always to return
> getFileName().substring(getFileName().lastIndexOf(‘.”) + 1)
> unless getFileName() returns null or lastIndexOf(‘.’) returns -1 in
> which cases “” would be returned?
More information about the nio-dev