Is this really useful? I think we need to know where this is written to. Also, mkdtemp() makes a temporary dir, in /tmp under unix systems and thus is not reliable (because it will be deleted eventually).

I would make the directory argument mandatory.