| Crates.io | temp-dir |
| lib.rs | temp-dir |
| version | 0.1.16 |
| created_at | 2021-03-18 22:55:47.081452+00 |
| updated_at | 2025-05-06 22:37:26.840986+00 |
| description | Simple temporary directory with cleanup |
| homepage | |
| repository | https://gitlab.com/leonhard-llc/ops |
| max_upload_size | |
| id | 370792 |
| size | 26,359 |
Provides a TempDir struct.
stdforbid(unsafe_code)std::fs::remove_dir_all
which may be unreliable on Windows.
See rust#29497 and
remove_dir_all crate.tempdir
tempfile
unsafe, dependencies full of unsafetest_dir
TestDir structtemp_testdir
mktemp
unsafeuse temp_dir::TempDir;
let d = TempDir::new().unwrap();
// Prints "/tmp/t1a9b-0".
println!("{:?}", d.path());
let f = d.child("file1");
// Prints "/tmp/t1a9b-0/file1".
println!("{:?}", f);
std::fs::write(&f, b"abc").unwrap();
assert_eq!(
"abc",
std::fs::read_to_string(&f).unwrap(),
);
// Prints "/tmp/t1a9b-1".
println!(
"{:?}", TempDir::new().unwrap().path());
Metric output format: x/y
x = unsafe code used by the build
y = total unsafe code found in the crate
Symbols:
🔒 = No `unsafe` usage found, declares #![forbid(unsafe_code)]
❓ = No `unsafe` usage found, missing #![forbid(unsafe_code)]
☢️ = `unsafe` usage found
Functions Expressions Impls Traits Methods Dependency
0/0 0/0 0/0 0/0 0/0 🔒 temp-dir 0.1.16
0/0 0/0 0/0 0/0 0/0
dont_delete_on_drop(). Thanks to A L Manning for discussion.AsRef<Path>std::io::Error instead of String.cleanup.Eq, Ord, Hashleak.std::fs::remove_dir_all being unreliable on Windows.
Warn about predictable directory and file names.
Thanks to Reddit user
burntsushi.TempDir::panic_on_cleanup_error.
Thanks to Reddit users
KhorneLordOfChaos
and
dpc_pw
for their comments.License: Apache-2.0