Expand description

Create temporary directory and file.

  • No dependencies.
  • Create in any directory.
  • Add prefix and suffix in the name.
  • Auto deletion.
use maketemp::TempDir;
use std::path::Path;
 
fn main() {
    let p;
     
    {
        // create temporary directory.
        let dir = TempDir::open();
        p = dir.path().to_string();
         
        // true.
        println!("path {} exists: {} ",&p,Path::new(&p).exists());
         
        // delete `dir` automatically here.
    }
     
    // false.
    println!("path: {} exists: {}",&p,Path::new(&p).exists());
}

Structs

Temporary Directory.

Temporary File.