RFR  File.mkdirs() method doesn't behave well when given /../
ivan.gerasimov at oracle.com
Mon Aug 12 17:07:07 UTC 2013
Forgot the link to the bug record
On 12.08.2013 20:02, Ivan Gerasimov wrote:
> Hello everybody!
> Would you please help review a small change to File.mkdirs() method?
> The current implementation of the method, when past an argument
> "dir1/../dir2" only tries to create dir2.
> mkdir -p 'dir1/../dir2' command on Linux creates both dir1 and dir2.
> java.nio.file.Files.createDirectories() also creates both dir1 and dir2.
> The proposed fix makes File.mkdirs() method to behave in the same way
> on all the platforms except for Windows.
> The problem with Windows is that it reports 'dir1/..' as existent even
> if dir1 does not exist.
> Because of that Files.createDirectories() doesn't work this way on
> Windows either.
> Proposed fix:
> - makes File.mkdirs() match the behavior of 'mkdir -p' on Linux,
> Solaris and MacOS, and
> - doesn't change its behavior on Windows.
> Sincerely yours,
> Ivan Gerasimov
More information about the core-libs-dev