C++ – How to create directory tree in C++/Linux


I want an easy way to create multiple directories in C++/Linux.

For example I want to save a file lola.file in the directory:


but if the directories are not there I want them to be created automagically. A working example would be perfect.

Best Solution

Easy with Boost.Filesystem: create_directories

#include <boost/filesystem.hpp>

Returns: true if a new directory was created, otherwise false.