split off temporary file/dir logic into a module