NamedTemporary refactor

Split NamedTemporaryDirectory common functionality into a base class,
`NamedTemporary`.