add utils.path.ensure_dir_exists

Ensures that a directory exists, and protects against a common race condition when multiple processes try to create the same directory.

We managed to omit protection against this race condition in enough times that I think a utility is warranted.