本文介绍了如何在C ++中创建一个临时目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C ++中编写一个函数,它创建一个临时目录。这样的功能应该尽可能最便携,例如。它应该在linux,mac和win32环境下工作。我如何实现呢?
I'm writing a function in C++ which creates a temporary directory. Such function should be as most portable as possible, e.g. it should work under linux, mac and win32 environments. How do I achieve that?
推荐答案
Boost文件系统库的第3版提供了 unique_path()
生成一个适合创建临时文件或目录的路径名。
Version 3 of Boost Filesystem Library provides function unique_path()
for generating a path name suitable for creating a temporary file or directory.
using namespace boost::filesystem;
path ph = unique_path();
create_directories(ph);
这篇关于如何在C ++中创建一个临时目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!