如何在Linux中找到"temp"目录? [英] How do I find the 'temp' directory in Linux?
本文介绍了如何在Linux中找到"temp"目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Linux中找到"temp"目录?我正在编写一个与平台无关的C ++函数,该函数返回temp目录.在Mac和Windows中,有一个API可以返回这些结果.在Linux中,我很困惑.
How do I find the 'temp' directory in Linux? I am writing a platform neutral C++ function that returns the temp directory. In Mac and Windows, there is an API that returns these results. In Linux, I'm stumped.
推荐答案
检查以下变量:
- 环境变量
TMPDIR
-
宏
- The environment variable
TMPDIR
- The value of the
P_tmpdir
macro
如果全部失败,请尝试使用目录/tmp
.
If all fails try to use the directory /tmp
.
您还可以使用tempnam
函数生成唯一的临时文件名.
You can also use tempnam
function to generate a unique temporary file name.
这篇关于如何在Linux中找到"temp"目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文