temporary-files

std::tmpfile() not picking TMPDIR location

浪尽此生 提交于 2020-12-13 19:15:30
问题 I am using std::tmpfile() to create temporary files, but I want to use the location other than /tmp. I am exporting $TMPDIR to point to the new location, but std::tmpfile() doesn't pick the new location. How to create temporary files with std::tmpfile() in a folder other than /tmp? 回答1: A quick test program #include <stdio.h> #include <stdlib.h> #include <cstdlib> #include <iostream> int main() { const char* tf = std::tmpnam(nullptr); std::cout << "tmpfile: " << tf << '\n'; return 0; } and an

std::tmpfile() not picking TMPDIR location

不羁岁月 提交于 2020-12-13 19:14:30
问题 I am using std::tmpfile() to create temporary files, but I want to use the location other than /tmp. I am exporting $TMPDIR to point to the new location, but std::tmpfile() doesn't pick the new location. How to create temporary files with std::tmpfile() in a folder other than /tmp? 回答1: A quick test program #include <stdio.h> #include <stdlib.h> #include <cstdlib> #include <iostream> int main() { const char* tf = std::tmpnam(nullptr); std::cout << "tmpfile: " << tf << '\n'; return 0; } and an