Stebalien / tempfile

Temporary file library for rust
http://stebalien.com/projects/tempfile-rs
Apache License 2.0
1.15k stars 113 forks source link

Feature request: Add a way to generate a random path without creating a file #297

Closed smalis-msft closed 1 month ago

smalis-msft commented 1 month ago

Certain APIs take a file pat, but expect there to be no file at that path so that they can create it (e.g. UnixListener::bind). It would be handy to have a way to generate random paths to pass to functions like these, without having to go through the dance of making a NamedTempFile, extracting the path, and then deleting it.

Stebalien commented 1 month ago

See (Builder::make](https://docs.rs/tempfile/latest/tempfile/struct.Builder.html#method.make). Especially the example.

I'm very reluctant to implement tmpnam for safety reasons (see the warnings on the man page).