3 ms·
If it's only a temp file (as opposed to a dir) and it's Linux, you may want to use O_TMPFILE (possibly O_EXCL too) when open()ing the file instead of the RAII w
by tomjakubowski 4y ago
If it's only a temp file (as opposed to a dir) and it's Linux, you may want to use O_TMPFILE (possibly O_EXCL too) when open()ing the file instead of the RAII wrapper. That ensures the OS will delete the file even if the program is killed.
- notriddle 4y agohttps://docs.rs/tempfile/3.3.0/src/tempfile/file/imp/unix.rs.html#71-86 https://docs.rs/tempfile/3.3.0/src/tempfile/file/imp/unix.rs...
- ComputerGuru 4y agoAn additional (and more important) constraint to being on Linux and creating a single file is that this assumes you are the one creating the file, which is oftentimes not the case. e.g. in my rust ffmpeg wrapper, I have pipelines that invoke ffmpeg and through it create multiple intermediate files that need to be cleaned up at the end of the run in all cases (success and failure).