mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Rework policies to return branches rather than path strings
This commit is contained in:
parent
7e084ea7db
commit
86b50d2d4e
86 changed files with 1259 additions and 3088 deletions
|
|
@ -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_);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue