mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 09:13:07 +03:00
docs: note env var influence on temp_dir and env_clear on Windows
* docs: explicitly list env vars checked by temp_dir on Windows On Windows, temp_dir() internally calls GetTempPath2/GetTempPath which checks TMP, TEMP, USERPROFILE environment variables in order. This information was previously only available by following links to Microsoft docs. Making it explicit in Rust's own documentation improves discoverability. Addresses #125439. * docs: note env var influence on temp_dir and env_clear on Windows On Windows, nv::temp_dir() internally calls GetTempPath2/GetTempPath, which checks TMP, TEMP, and USERPROFILE in order. Document this lookup order directly in the emp_dir docs rather than requiring users to follow the link to Microsoft documentation. Also add a note on Command::env_clear explaining that clearing the environment affects the child process's emp_dir(), not the parent's. Closes #125439. * docs: drop Windows env_clear temp_dir note
This commit is contained in:
@@ -670,6 +670,17 @@ pub fn home_dir() -> Option<PathBuf> {
|
||||
///
|
||||
/// On Windows, the behavior is equivalent to that of [`GetTempPath2`][GetTempPath2] /
|
||||
/// [`GetTempPath`][GetTempPath], which this function uses internally.
|
||||
/// Specifically, for non-SYSTEM processes, the function checks for the
|
||||
/// following environment variables in order and returns the first path found:
|
||||
///
|
||||
/// 1. The path specified by the `TMP` environment variable.
|
||||
/// 2. The path specified by the `TEMP` environment variable.
|
||||
/// 3. The path specified by the `USERPROFILE` environment variable.
|
||||
/// 4. The Windows directory.
|
||||
///
|
||||
/// When called from a process running as SYSTEM,
|
||||
/// [`GetTempPath2`][GetTempPath2] returns `C:\Windows\SystemTemp`
|
||||
/// regardless of environment variables.
|
||||
///
|
||||
/// Note that, this [may change in the future][changes].
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user