#tempfile #filesystem #tmpfile

tempfile

A library for managing temporary files and directories

30 releases (stable)

3.0.5 Nov 26, 2018
3.0.3 Jul 17, 2018
3.0.0 Mar 25, 2018
2.2.0 Sep 27, 2017
0.5.1 May 22, 2015

#2 in Filesystem

Download history 24919/week @ 2018-10-11 31194/week @ 2018-10-18 25826/week @ 2018-10-25 30863/week @ 2018-11-01 31182/week @ 2018-11-08 31536/week @ 2018-11-15 31093/week @ 2018-11-22 33602/week @ 2018-11-29 37469/week @ 2018-12-06 39254/week @ 2018-12-13 34617/week @ 2018-12-20 25616/week @ 2018-12-27 23844/week @ 2019-01-03

136,011 downloads per month
Used in 1,334 crates (291 directly)

MIT/Apache

69KB
857 lines

tempfile

Crate Build Status Build status

A secure, cross-platform, temporary file library for Rust. In addition to creating temporary files, this library also allows users to securely open multiple independent references to the same temporary file (useful for consumer/producer patterns and surprisingly difficult to implement securely).

Documentation

Usage

Minimum required Rust version: 1.18.0

Add this to your Cargo.toml:

[dependencies]
tempfile = "3"

...and this to your crate root:

extern crate tempfile;

Example

extern crate tempfile;
use std::fs::File;
use std::io::{Write, Read, Seek, SeekFrom};

fn main() {
    // Write
    let mut tmpfile: File = tempfile::tempfile().unwrap();
    write!(tmpfile, "Hello World!").unwrap();

    // Seek to start
    tmpfile.seek(SeekFrom::Start(0)).unwrap();

    // Read
    let mut buf = String::new();
    tmpfile.read_to_string(&mut buf).unwrap();
    assert_eq!("Hello World!", buf);
}

Dependencies

~1MB
~13K SLoC