| 498 | //========================================================================== |
| 499 | #ifdef _WIN32 |
| 500 | void DoCreatePath(const char *fn) |
| 501 | { |
| 502 | char drive[_MAX_DRIVE]; |
| 503 | char dir[_MAX_DIR]; |
| 504 | _splitpath_s(fn, drive, sizeof drive, dir, sizeof dir, nullptr, 0, nullptr, 0); |
| 505 | |
| 506 | if ('\0' == *dir) |
| 507 | { |
| 508 | // Root/current/parent directory always exists |
| 509 | return; |
| 510 | } |
| 511 | |
| 512 | char path[_MAX_PATH]; |
| 513 | _makepath_s(path, sizeof path, drive, dir, nullptr, nullptr); |
| 514 | |
| 515 | if ('\0' == *path) |
| 516 | { |
| 517 | // No need to process empty relative path |
| 518 | return; |
| 519 | } |
| 520 | |
| 521 | // Remove trailing path separator(s) |
| 522 | for (size_t i = strlen(path); 0 != i; --i) |
| 523 | { |
| 524 | char& lastchar = path[i - 1]; |
| 525 | |
| 526 | if ('/' == lastchar || '\\' == lastchar) |
| 527 | { |
| 528 | lastchar = '\0'; |
| 529 | } |
| 530 | else |
| 531 | { |
| 532 | break; |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | // Create all directories for given path |
| 537 | if ('\0' != *path) |
| 538 | { |
| 539 | DoCreatePath(path); |
| 540 | #ifdef _WIN32 |
| 541 | auto wpath = WideString(path); |
| 542 | _wmkdir(wpath.c_str()); |
| 543 | #else |
| 544 | _mkdir(path); |
| 545 | #endif |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | void CreatePath(const char *fn) |
| 550 | { |
no test coverage detected