Rework policies to return branches rather than path strings

This commit is contained in:
trapexit 2025-05-17 16:35:18 -05:00 • committed by GitHub
parent 7e084ea7db
commit 86b50d2d4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
86 changed files with 1259 additions and 3088 deletions

View file

@ -27,23 +27,21 @@
#include <limits>
#include <string>
using std::string;
namespace msplus
{
static
const
string*
create_1(const Branches::CPtr &branches_,
const string &fusepath_,
int *err_)
Branch*
create_1(const Branches::Ptr &branches_,
const std::string &fusepath_,
int *err_)
{
int rv;
uint64_t lus;
fs::info_t info;
const string *basepath;
Branch *obranch;
basepath = NULL;
obranch = nullptr;
lus = std::numeric_limits<uint64_t>::max();
for(auto &branch : *branches_)
{
@ -61,64 +59,64 @@ namespace msplus
if(info.spaceused >= lus)
continue;
lus = info.spaceused;;
basepath = &branch.path;
lus = info.spaceused;
obranch = &branch;
}
return basepath;
return obranch;
}
static
int
create(const Branches::CPtr &branches_,
create(const Branches::Ptr &branches_,
const char *fusepath_,
StrVec *paths_)
std::vector<Branch*> &paths_)
{
int error;
string fusepath;
const string *basepath;
Branch *branch;
std::string fusepath;
error = ENOENT;
fusepath = fusepath_;
for(;;)
{
basepath = msplus::create_1(branches_,fusepath,&error);
if(basepath)
branch = msplus::create_1(branches_,fusepath,&error);
if(branch)
break;
if(fusepath == "/")
break;
fusepath = fs::path::dirname(fusepath);
}
if(basepath == NULL)
if(!branch)
return (errno=error,-1);
paths_->push_back(*basepath);
paths_.emplace_back(branch);
return 0;
}
}
int
Policy::MSPLUS::Action::operator()(const Branches::CPtr &branches_,
Policy::MSPLUS::Action::operator()(const Branches::Ptr &branches_,
const char *fusepath_,
StrVec *paths_) const
std::vector<Branch*> &paths_) const
{
return Policies::Action::eplus(branches_,fusepath_,paths_);
}
int
Policy::MSPLUS::Create::operator()(const Branches::CPtr &branches_,
Policy::MSPLUS::Create::operator()(const Branches::Ptr &branches_,
const char *fusepath_,
StrVec *paths_) const
std::vector<Branch*> &paths_) const
{
return ::msplus::create(branches_,fusepath_,paths_);
}
int
Policy::MSPLUS::Search::operator()(const Branches::CPtr &branches_,
Policy::MSPLUS::Search::operator()(const Branches::Ptr &branches_,
const char *fusepath_,
StrVec *paths_) const
std::vector<Branch*> &paths_) const
{
return Policies::Search::eplus(branches_,fusepath_,paths_);
}