mirror of https://github.com/trapexit/mergerfs.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.5 KiB
77 lines
1.5 KiB
#include "branch_tier.hpp"
|
|
|
|
#include "fmt/core.h"
|
|
|
|
#include "fs_glob.hpp"
|
|
|
|
#include <cassert>
|
|
|
|
|
|
namespace l
|
|
{
|
|
static
|
|
void
|
|
load_branch_literal(toml::table const &v_,
|
|
std::vector<Branch2> &branches_)
|
|
{
|
|
branches_.emplace_back(v_);
|
|
}
|
|
|
|
static
|
|
void
|
|
load_branch_glob(toml::table const &v_,
|
|
std::vector<Branch2> &branches_)
|
|
{
|
|
toml::table table;
|
|
std::string pattern;
|
|
std::vector<std::string> paths;
|
|
|
|
pattern = v_.at("path").as_string();
|
|
fs::glob(pattern,&paths);
|
|
|
|
table = v_;
|
|
branches_.resize(branches_.size() + paths.size());
|
|
for(auto &path : paths)
|
|
{
|
|
table["path"] = path;
|
|
branches_.emplace_back(table);
|
|
}
|
|
}
|
|
|
|
static
|
|
void
|
|
load_branch_scan(toml::table const &v_,
|
|
std::vector<Branch2> &branches_)
|
|
{
|
|
assert(("not currently supported",0));
|
|
}
|
|
}
|
|
|
|
BranchTier::BranchTier()
|
|
{
|
|
|
|
}
|
|
|
|
BranchTier::BranchTier(toml::value const &v_)
|
|
{
|
|
auto const &branches = toml::find(v_,"branch").as_array();
|
|
|
|
for(auto const &branch : branches)
|
|
{
|
|
bool enabled;
|
|
std::string type;
|
|
auto const &table = branch.as_table();
|
|
|
|
enabled = toml::find_or(branch,"enabled",false);
|
|
if(!enabled)
|
|
continue;
|
|
|
|
type = table.at("type").as_string();
|
|
if(type == "literal")
|
|
l::load_branch_literal(table,_branches);
|
|
else if(type == "glob")
|
|
l::load_branch_glob(table,_branches);
|
|
else if(type == "scan")
|
|
l::load_branch_scan(table,_branches);
|
|
}
|
|
}
|