| 597 | } |
| 598 | |
| 599 | bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create) |
| 600 | { |
| 601 | bool will_create = false; |
| 602 | |
| 603 | /* See if we should be creating */ |
| 604 | if (can_create && cfg->create) |
| 605 | { |
| 606 | will_create = true; |
| 607 | |
| 608 | /* If the folder does not exist, attempt to create it. |
| 609 | * We're awfully nice. |
| 610 | */ |
| 611 | const char *folder = cfg->folder.c_str(); |
| 612 | char path[PLATFORM_MAX_PATH]; |
| 613 | char build[PLATFORM_MAX_PATH]; |
| 614 | |
| 615 | g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "cfg/%s", folder); |
| 616 | |
| 617 | if (!ke::file::IsDirectory(path)) |
| 618 | { |
| 619 | char *cur_ptr = path; |
| 620 | size_t len; |
| 621 | |
| 622 | ke::path::Format(path, sizeof(path), "%s", folder); |
| 623 | len = g_SourceMod.BuildPath(Path_Game, build, sizeof(build), "cfg"); |
| 624 | |
| 625 | do |
| 626 | { |
| 627 | /* Find next suitable path */ |
| 628 | char *next_ptr = cur_ptr; |
| 629 | while (*next_ptr != '\0') |
| 630 | { |
| 631 | if (IsPathSepChar(*next_ptr)) |
| 632 | { |
| 633 | *next_ptr = '\0'; |
| 634 | next_ptr++; |
| 635 | break; |
| 636 | } |
| 637 | next_ptr++; |
| 638 | } |
| 639 | if (*next_ptr == '\0') |
| 640 | { |
| 641 | next_ptr = NULL; |
| 642 | } |
| 643 | len += ke::path::Format(&build[len], |
| 644 | sizeof(build)-len, |
| 645 | "/%s", |
| 646 | cur_ptr); |
| 647 | if (!ke::file::CreateDirectory(build)) |
| 648 | break; |
| 649 | cur_ptr = next_ptr; |
| 650 | } while (cur_ptr); |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | /* Check if the file exists. */ |
| 655 | char file[PLATFORM_MAX_PATH]; |
| 656 | char local[PLATFORM_MAX_PATH]; |
no test coverage detected