Stebalien / tempfile

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

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

Closed smalis-msft closed 3 months ago

smalis-msft commented 3 months 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 3 months 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).