提问人:AggelosT 提问时间:1/13/2023 更新时间:1/13/2023 访问量:351
如何使用 Rust 在 Windows 上找到临时目录?(像类 Unix 上的 /tmp)
How can I find the temporary directory on Windows using Rust? (Like /tmp on Unix-like)
问:
在 Windows 上查找临时文件目录的最简单方法是什么(相当于在类 Unix 操作系统上)?它是保存在环境变量上,还是始终是特定的变量?我想为 Rust 板条箱找到它,所以只有 Rust 回答。如果可能的话,除了板条箱,我想避免任何东西。/tmp
std
答:
3赞
EvilTak
1/13/2023
#1
std::env::temp_dir()
返回系统临时目录的路径。根据发布此答案时的文档,
在 Windows 上,该行为等效于此函数在内部使用的
GetTempPath2
/GetTempPath
的行为。
上一个:DRF 创建指向图像的临时链接
下一个:在 Hive 中创建临时函数
评论
std::env::temp_dir
tempfile
而不是重新实现其功能。tempfile
tempfile
tempdir