better implementations of mktmpdir and force-to-string