1 pub const DEFAULT_BUF_SIZE: usize = 8 * 1024;
4 #[allow(dead_code)] // not used on emscripten
8 use crate::path::{Path, PathBuf};
11 pub struct TempDir(PathBuf);
14 pub fn join(&self, path: &str) -> PathBuf {
15 let TempDir(ref p) = *self;
19 pub fn path(&self) -> &Path {
20 let TempDir(ref p) = *self;
25 impl Drop for TempDir {
27 // Gee, seeing how we're testing the fs module I sure hope that we
28 // at least implement this correctly!
29 let TempDir(ref p) = *self;
30 fs::remove_dir_all(p).unwrap();
34 pub fn tmpdir() -> TempDir {
35 let p = env::temp_dir();
36 let mut r = rand::thread_rng();
37 let ret = p.join(&format!("rust-{}", r.next_u32()));
38 fs::create_dir(&ret).unwrap();