This completes the temporary file handling saga.
I found a way to use FILE_FLAG_DELETE_ON_CLOSE with fewer changes.