如何在 C++/Linux 中创建目录树? [英] How can I create directory tree in C++/Linux?
本文介绍了如何在 C++/Linux 中创建目录树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一种在 C++/Linux 中创建多个目录的简单方法.
I want an easy way to create multiple directories in C++/Linux.
比如我想在目录下保存一个文件lola.file:
For example I want to save a file lola.file in the directory:
/tmp/a/b/c
但如果目录不存在,我希望它们自动创建.一个工作示例将是完美的.
but if the directories are not there I want them to be created automagically. A working example would be perfect.
推荐答案
Easy with Boost.Filesystem: create_directories
Easy with Boost.Filesystem: create_directories
#include <boost/filesystem.hpp>
//...
boost::filesystem::create_directories("/tmp/a/b/c");
返回:true
如果创建了新目录,否则 false
.
Returns: true
if a new directory was created, otherwise false
.
这篇关于如何在 C++/Linux 中创建目录树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文