MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / SM_ExecuteConfig

Function SM_ExecuteConfig

core/CoreConfig.cpp:599–732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597}
598
599bool 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];

Callers 2

SM_ExecuteForPluginFunction · 0.85
SM_ExecuteAllConfigsFunction · 0.85

Calls 11

SM_ExecuteConfigFileFunction · 0.85
SM_GenerateConfigFileFunction · 0.85
BuildPathMethod · 0.80
GetPropertyMethod · 0.80
IsPathSepCharFunction · 0.70
c_strMethod · 0.45
sizeMethod · 0.45
initMethod · 0.45
LogErrorMethod · 0.45
GetFilenameMethod · 0.45

Tested by

no test coverage detected