#temp-dir #directory #temporary #path

maketemp

Create temporary directory and files

1 unstable release

0.1.0 Mar 21, 2022

#1190 in Filesystem

21 downloads per month

MIT license

27KB
481 lines

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());
}

No runtime deps