Module tempfile
Temporary files and directories with automatic cleanup.
- Crate
::tempfile. - docs.rs
- crates.io
- GitHub
tempfile provides secure, cross-platform temporary file and directory management
with automatic cleanup when the handles are dropped.
Managing temporary files correctly on many platforms involves a lot of technical tradeoffs and there are many ways to do it poorly. This crate is ancient and battle tested and well documented.
Examples
Creating and using a temporary directory:
use TempDir;
use File;
use Write;
let dir = with_prefix?;
// Create files inside the temporary directory
let file_path = dir.path.join;
let mut file = create?;
writeln!?;
assert!;
// Directory and all contents are deleted when dropped
drop;
assert!;
# Ok::
Modules
Structs
- Builder Create a new temporary file or directory with custom options.