Boost::filesystem provides two methods to check if directories exist and create directories if not.
#include <boost/filesystem.hpp>
boost::filesystem::path filePath( "/a/b/c" );
if( !boost::filesystem::exists( filePath ) &&
!boost::filesystem::create_directories( filePath ) ) {
...
}
C++ standard didn’t provide them until C++17.