Crate temp_dir[−][src]
temp-dir
Provides a TempDir
struct.
Features
- Makes a directory in a system temporary directory
- Recursively deletes the directory and its contents on drop
- Optional name prefix
- No dependencies
forbid(unsafe_code)
Limitations
- Not security-hardened.
Alternatives
test_dir
- Has a handy
TestDir
struct - Incomplete documentation
temp_testdir
- Incomplete documentation
mktemp
- Sets directory mode 0700 on unix
- Contains
unsafe
- No readme or online docs
Related Crates
Example
use temp_dir::TempDir; let d = TempDir::new().unwrap(); // Prints "/tmp/t1a9b0". println!("{:?}", d.path()); let f = d.child("file1"); // Prints "/tmp/t1a9b0/file1". println!("{:?}", f); std::fs::write(&f, b"abc").unwrap(); assert_eq!( "abc", std::fs::read_to_string(&f).unwrap(), ); // Prints "/tmp/t1a9b1". println!( "{:?}", TempDir::new().unwrap().path());
Cargo Geiger Safety Report
Structs
TempDir | The path of an existing writable directory in a system temporary directory. |