Abstract the TMP directory logic to use system temp directories. RE: #1910