add create_unused_dir function to create a directory which does not yet exist#3551
Conversation
This will append _%d until a new folder could be created. If the base folder name does not exists, it is used directly, so the simple, most common case is the cleanest
|
@Flamefire What's the use case for this? Always good to know. Also, I think it makes sense to re-use the existing |
|
This is for the build directories in meson, cmake, ... where for each build (iteration, extension, bundle component) a new, empty build dir is (usually) required. We had that on Slack where someone reported a failure and I wanted to get this function into framework instead of hacking it into meson only As for And finally: I'd like to have a simple folder name, e.g. |
This will append _%d until a new folder could be created.
If the base folder name does not exists, it is used directly, so the simple, most common case is the cleanest
Note that I didn't use our
mkdirfunction to reduce the possibility of a race condition where the folder gets created between the check and theos.mkdircall. This solution pushes the burden to Python, which at least reduces the window for such an issue.