#temp #tempdir #async

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

#1720 in Filesystem

Download history 49/week @ 2023-11-03 42/week @ 2023-11-10 34/week @ 2023-11-17 32/week @ 2023-11-24 51/week @ 2023-12-01 51/week @ 2023-12-08 36/week @ 2023-12-15 35/week @ 2023-12-22 72/week @ 2023-12-29 57/week @ 2024-01-05 39/week @ 2024-01-12 53/week @ 2024-01-19 62/week @ 2024-01-26 32/week @ 2024-02-02 62/week @ 2024-02-09 68/week @ 2024-02-16

249 downloads per month
Used in 2 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
~70K SLoC