D-Programming-Language/phobos — pull request #1818 by CyberShadow (2013-12-28 05:06:59+00:00)
Title: std.file: Fix race condition when mkdirRecurse runs concurrently 

`mkdirRecurse` would throw if a directory was created between its `exists()` and `mkdir()` calls. This could occur if `mkdirRecurse` was called at the same time from mutiple threads or processes.

Instead of relying on the `exists()` check to indicate whether the next `mkdir()` should succeed, we explicitly ignore "already exists" errors from the OS. Note that this changes the behavior of `mkdirRecurse` when the leaf directory already existed: previously it would throw, whereas now it will silently succeed. The new behavior is conformant with some other implementations of "recursive mkdir": the `-p` flag of the GNU tool, Ruby's `mkpath`, Java's `mkdirs`, and Perl's `make_path`. (On the other hand, the old behavior was equivalent to the behavior of Python's `makedirs`).