code

if (mkdir(finalpath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1)
{
if( errno == EEXIST ) {
// alredy exists
} else {
// something else
std::cout << "cannot create sessionnamefolder error:" << strerror(errno) << std::endl;
}
}

need to include <sys/stat.h> for S_IRWXU, S_IRWXG;

 

 

参考

1. ​​create-folder-if-it-doesnt-exist-do-nothing-if-it-does​​;