#temp-dir #temp #async #content

tmpdir

Useful to create temp directories and copy their contents on completion of some action. Tmp dirs will be created using [env::temp_dir] with some random characters prefixed to prevent a name clash

1 stable release

1.0.0 Feb 24, 2023

#1105 in Filesystem

Download history 10/week @ 2024-01-06 15/week @ 2024-01-13 32/week @ 2024-01-20 30/week @ 2024-01-27 5/week @ 2024-02-03 43/week @ 2024-02-10 74/week @ 2024-02-17 132/week @ 2024-02-24 133/week @ 2024-03-02 202/week @ 2024-03-09 94/week @ 2024-03-16 223/week @ 2024-03-23 234/week @ 2024-03-30 124/week @ 2024-04-06 123/week @ 2024-04-13 113/week @ 2024-04-20

717 downloads per month
Used in 3 crates

MIT license

12KB
164 lines

TmpDir

Useful to create temp directories and copying their contents on completion of some action. Tmp dirs will be created using env::temp_dir with some random characters prefixed to prevent a name clash

copy will traverse recursively through a directory and copy all file contents to some destination dir. It will not follow symlinks.

Example

use tmpdir::TmpDir;
use tokio::{fs, io::AsyncWriteExt};

let tmp = TmpDir::new("foo").await.unwrap();
let new_tmp = TmpDir::new("bar").await.unwrap();

new_tmp.copy(tmp.as_ref()).await;
new_tmp.close().await; // not necessary to explicitly call

lib.rs:

TmpDir

Useful to create temp directories and copying their contents on completion of some action. Tmp dirs will be created using env::temp_dir with some random characters prefixed to prevent a name clash

copy will traverse recursively through a directory and copy all file contents to some destination dir. It will not follow symlinks.

Example

use tmpdir::TmpDir;
use tokio::{fs, io::AsyncWriteExt};

let new_tmp = TmpDir::new("bar").await.unwrap();
new_tmp.copy(tmp.as_ref()).await;
new_tmp.close().await; // not necessary to explicitly call

Dependencies

~3–4.5MB
~71K SLoC