Crates.io | temp-dir |
lib.rs | temp-dir |
version | 0.1.14 |
source | src |
created_at | 2021-03-18 22:55:47.081452 |
updated_at | 2024-10-03 07:52:22.784668 |
description | Simple temporary directory with cleanup |
homepage | |
repository | https://gitlab.com/leonhard-llc/ops |
max_upload_size | |
id | 370792 |
size | 24,913 |
Provides a TempDir
struct.
std
forbid(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 unsafe
test_dir
TestDir
structtemp_testdir
mktemp
unsafe
use 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.14
0/0 0/0 0/0 0/0 0/0
AsRef<Path>
std::io::Error
instead of String
.cleanup
.Eq
, Ord
, Hash
leak
.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