CS-FreeStyle / 10000-How-To-Do-in-CS

1 stars 0 forks source link

if folder not exits, create it in C++ on Linux #108

Open liuty10 opened 4 years ago

liuty10 commented 4 years ago

https://stackoverflow.com/questions/675039/how-can-i-create-directory-tree-in-c-linux

#include <sys/stat.h>

struct stat info;                                         
if (stat(logpath, &info) != 0){                           
    mode_t mode = 0755;                                   
    int ret = mkdir(logpath, mode);                       
    if (ret != 0) fprintf(stderr, "create file failed!"); 
}