RFR 8057113: (fs) Path should have a method to test the filename extension
Alan Bateman
Alan.Bateman at oracle.com
Mon Feb 19 08:39:49 UTC 2018
On 16/02/2018 21:34, Roger Riggs wrote:
>
> To keep it simple, the last "." that is not the first character can be
> the delimiter for the extension.
>
> "." ext ""
> ".." ext ""
> ".a.b" ext "b"
> "......." ext ""
> ".....a" ext "a"
> "....a.b" ext "b"
> "..foo" ext "foo"
>
> It might be useful to check how native unix utilities parse these cases
Yes, a small survey is needed before proposing how some of the corner
cases should work. In the above, you'll find that Python splitpath will
split "..foo" into "..foo" and "". I believe .NET's Path.GetExtension
is simply the equivalent of lastIndexOf. The need for a survey is
something that came up when this issue was look into a long time ago.
One other thing is to consider whether getExtension is the right way to
expose this. I've no doubt it will be followed by a request to add a
method that returns the file name without the extension so we need to
see how that will work. At one point we had a prototype of a split
method that returned the name + extension pair, as 2 element String
array - I'm not saying that is the best solution of course.
-Alan
More information about the nio-dev
mailing list