12 bool is_dir(const char *path) {
15 if (_stat(path, &info) != 0) {
18 return (info.st_mode & _S_IFDIR) != 0;
21 if (stat(path, &info) != 0) {
24 return (info.st_mode & S_IFDIR) != 0;
29 bool make_dir(const char *path) {
31 int ret = _mkdir(path);
33 int ret = mkdir(path, 0777);
39 bool make_dirs(const std::string &path) {
40 if (make_dir(path.c_str())) {
50 auto pos = path.find_last_of("\\/");
52 auto pos = path.find_last_of('/');
54 if (pos == std::string::npos) {
57 if (!make_dirs(path.substr(0, pos))) {
62 return make_dir(path.c_str());
65 // something's there, check if it's a dir and we're good
66 return is_dir(path.c_str());
69 // whatever else went wrong, it can't be good