Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively load components #920

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions Server/Source/core_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,20 +1085,25 @@ class Core final : public ICore, public PlayerConnectEventHandler, public Consol
auto excludeCfg = config.getStrings("exclude");
if (!componentsCfg || componentsCfg->empty())
{
for (auto& de : ghc::filesystem::directory_iterator(path))
for (auto& de : ghc::filesystem::recursive_directory_iterator(path))
{
ghc::filesystem::path p = de.path();
if (p.extension() == LIBRARY_EXT)
{
if (excludeCfg && !excludeCfg->empty())
{
p.replace_extension("");
ghc::filesystem::path rel = ghc::filesystem::relative(p, path);
rel.replace_extension();
// Is this in the "don't load" list?
if (std::find(excludeCfg->begin(), excludeCfg->end(), p.filename().string()) != excludeCfg->end())
const auto isExcluded = [rel = std::move(rel)](const String& exclude)
{
return ghc::filesystem::path(exclude) == rel;
};
if (std::find_if(excludeCfg->begin(), excludeCfg->end(), isExcluded)
!= excludeCfg->end())
{
continue;
}
p.replace_extension(LIBRARY_EXT);
}

IComponent* component = loadComponent(p);
Expand All @@ -1121,8 +1126,15 @@ class Core final : public ICore, public PlayerConnectEventHandler, public Consol

if (excludeCfg && !excludeCfg->empty())
{
ghc::filesystem::path rel = ghc::filesystem::relative(file, path);
rel.replace_extension();
// Is this in the "don't load" list?
if (std::find(excludeCfg->begin(), excludeCfg->end(), file.filename().string()) != excludeCfg->end())
const auto isExcluded = [rel = std::move(rel)](const String& exclude)
{
return ghc::filesystem::path(exclude) == rel;
};
if (std::find_if(excludeCfg->begin(), excludeCfg->end(), isExcluded)
!= excludeCfg->end())
{
continue;
}
Expand Down
Loading