| 118 | } |
| 119 | |
| 120 | static int makeDir(const std::string &path) |
| 121 | { |
| 122 | std::string npath = normalizePath(path); |
| 123 | |
| 124 | struct stat st; |
| 125 | int status = 0; |
| 126 | |
| 127 | if (stat(path.c_str(), &st) != 0) |
| 128 | { |
| 129 | #if WIN32 |
| 130 | status = _mkdir(path.c_str()); |
| 131 | #else |
| 132 | status = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); |
| 133 | #endif |
| 134 | if (status != 0 && errno != EEXIST) |
| 135 | status = -1; |
| 136 | } |
| 137 | else if (!(S_IFDIR & st.st_mode)) |
| 138 | { |
| 139 | errno = ENOTDIR; |
| 140 | status = -1; |
| 141 | } |
| 142 | |
| 143 | return status; |
| 144 | } |
| 145 | |
| 146 | /** Make all subdirectories. |
| 147 | */ |