AggelosT
AggelosT

Reputation: 168

How can I find the temporary directory on Windows using Rust? (Like /tmp on Unix-like)

What would be the easiest way to find the temporary file directory on Windows (The equivalent of /tmp on Unix-like OSes)? Is it saved on an environment variable, or is it always a specific one? I want to find it for a Rust crate, so Rust-only answers. If possible I'd like to avoid anything but the std crate.

Upvotes: 1

Views: 1239

Answers (1)

EvilTak
EvilTak

Reputation: 7579

std::env::temp_dir() returns a path to the system temporary directory. According to the docs when this answer was posted,

On Windows, the behavior is equivalent to that of GetTempPath2 / GetTempPath, which this function uses internally.

Upvotes: 4

Related Questions