An implementation of Python's tempfile.tempdir algorithm in C