Closed dvdsk closed 1 year ago
Unfortunately, no (at least on Linux, macOS, etc.). Tempfile cleanup works by immediately unlinking (deleting) the file in question, which means it has no path.
tempfile_in
exists so you can create the temporary file in a specific filesystem.
I am writing test code where I need to load in a (large) file for multiple tests. As I am doing tdd the tests are going to fail/crash a lot.
tempfile
is great as it shifts the responsibility of closing the file to the OS.This is what I would like to write:
I can not use it however since I need the path to the file.
The docs state
tempfile()
does not rely on paths, on the other handtempfile_in()
exists so it seems like there is some control over the file's path.Would it be possible to get that same OS driven cleanup while also exposing the file's path?