| 312 | } |
| 313 | |
| 314 | void |
| 315 | MakePath(std::string const& path) |
| 316 | { |
| 317 | std::string subPath; |
| 318 | auto dirs = SplitString(path, std::string() + DIR_SEP_WIN32 + DIR_SEP_POSIX); |
| 319 | if (dirs.empty()) |
| 320 | { |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | auto iter = dirs.begin(); |
| 325 | #ifdef US_PLATFORM_POSIX |
| 326 | // Start with the root '/' directory |
| 327 | subPath = DIR_SEP; |
| 328 | #else |
| 329 | // Start with the drive letter` |
| 330 | subPath = *iter + DIR_SEP; |
| 331 | ++iter; |
| 332 | #endif |
| 333 | for (; iter != dirs.end(); ++iter) |
| 334 | { |
| 335 | subPath += *iter; |
| 336 | errno = 0; |
| 337 | #ifdef US_PLATFORM_WINDOWS |
| 338 | if (us_mkdir(subPath.c_str())) |
| 339 | #else |
| 340 | if (us_mkdir(subPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) |
| 341 | #endif |
| 342 | { |
| 343 | if (errno != EEXIST) |
| 344 | { |
| 345 | throw std::invalid_argument(GetLastCErrorStr()); |
| 346 | } |
| 347 | } |
| 348 | subPath += DIR_SEP; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | void |
| 353 | RemoveDirectoryRecursive(std::string const& path) |