|
@ -18,8 +18,11 @@ |
|
|
|
|
|
|
|
|
#include "branch.hpp"
|
|
|
#include "branch.hpp"
|
|
|
#include "ef.hpp"
|
|
|
#include "ef.hpp"
|
|
|
|
|
|
#include "from_string.hpp"
|
|
|
#include "fs_glob.hpp"
|
|
|
#include "fs_glob.hpp"
|
|
|
#include "fs_realpathize.hpp"
|
|
|
#include "fs_realpathize.hpp"
|
|
|
|
|
|
#include "nonstd/optional.hpp"
|
|
|
|
|
|
#include "num.hpp"
|
|
|
#include "str.hpp"
|
|
|
#include "str.hpp"
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
#include <string>
|
|
@ -29,239 +32,381 @@ |
|
|
|
|
|
|
|
|
using std::string; |
|
|
using std::string; |
|
|
using std::vector; |
|
|
using std::vector; |
|
|
|
|
|
using nonstd::optional; |
|
|
|
|
|
|
|
|
bool |
|
|
|
|
|
Branch::ro(void) const |
|
|
|
|
|
{ |
|
|
|
|
|
return (mode == Branch::RO); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
|
Branch::nc(void) const |
|
|
|
|
|
|
|
|
Branch::Branch(const uint64_t &default_minfreespace_) |
|
|
|
|
|
: _default_minfreespace(&default_minfreespace_) |
|
|
{ |
|
|
{ |
|
|
return (mode == Branch::NC); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool |
|
|
|
|
|
Branch::ro_or_nc(void) const |
|
|
|
|
|
{ |
|
|
|
|
|
return ((mode == Branch::RO) || |
|
|
|
|
|
(mode == Branch::NC)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
split(const std::string &s_, |
|
|
|
|
|
std::string *instr_, |
|
|
|
|
|
std::string *values_) |
|
|
|
|
|
|
|
|
int |
|
|
|
|
|
Branch::from_string(const std::string &str_) |
|
|
{ |
|
|
{ |
|
|
uint64_t offset; |
|
|
|
|
|
|
|
|
|
|
|
offset = s_.find_first_of('/'); |
|
|
|
|
|
*instr_ = s_.substr(0,offset); |
|
|
|
|
|
if(offset != std::string::npos) |
|
|
|
|
|
*values_ = s_.substr(offset); |
|
|
|
|
|
|
|
|
return -EINVAL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Branches::Branches() |
|
|
|
|
|
|
|
|
std::string |
|
|
|
|
|
Branch::to_string(void) const |
|
|
{ |
|
|
{ |
|
|
pthread_rwlock_init(&lock,NULL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
std::string rv; |
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
parse(const string &str_, |
|
|
|
|
|
Branches &branches_) |
|
|
|
|
|
{ |
|
|
|
|
|
string str; |
|
|
|
|
|
Branch branch; |
|
|
|
|
|
vector<string> globbed; |
|
|
|
|
|
|
|
|
|
|
|
str = str_; |
|
|
|
|
|
branch.mode = Branch::INVALID; |
|
|
|
|
|
if(str::endswith(str,"=RO")) |
|
|
|
|
|
branch.mode = Branch::RO; |
|
|
|
|
|
ef(str::endswith(str,"=RW")) |
|
|
|
|
|
branch.mode = Branch::RW; |
|
|
|
|
|
ef(str::endswith(str,"=NC")) |
|
|
|
|
|
branch.mode = Branch::NC; |
|
|
|
|
|
|
|
|
|
|
|
if(branch.mode != Branch::INVALID) |
|
|
|
|
|
str.resize(str.size() - 3); |
|
|
|
|
|
else |
|
|
|
|
|
branch.mode = Branch::RW; |
|
|
|
|
|
|
|
|
|
|
|
fs::glob(str,&globbed); |
|
|
|
|
|
fs::realpathize(&globbed); |
|
|
|
|
|
for(size_t i = 0; i < globbed.size(); i++) |
|
|
|
|
|
|
|
|
rv = path; |
|
|
|
|
|
rv += '='; |
|
|
|
|
|
switch(mode) |
|
|
{ |
|
|
{ |
|
|
branch.path = globbed[i]; |
|
|
|
|
|
branches_.push_back(branch); |
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
case Branch::Mode::RW: |
|
|
|
|
|
rv += "RW"; |
|
|
|
|
|
break; |
|
|
|
|
|
case Branch::Mode::RO: |
|
|
|
|
|
rv += "RO"; |
|
|
|
|
|
break; |
|
|
|
|
|
case Branch::Mode::NC: |
|
|
|
|
|
rv += "NC"; |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
set(Branches &branches_, |
|
|
|
|
|
const std::string &str_) |
|
|
|
|
|
{ |
|
|
|
|
|
vector<string> paths; |
|
|
|
|
|
|
|
|
|
|
|
branches_.clear(); |
|
|
|
|
|
|
|
|
|
|
|
str::split(str_,':',&paths); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < paths.size(); i++) |
|
|
|
|
|
|
|
|
if(_minfreespace.has_value()) |
|
|
{ |
|
|
{ |
|
|
Branches tmp; |
|
|
|
|
|
|
|
|
|
|
|
parse(paths[i],tmp); |
|
|
|
|
|
|
|
|
|
|
|
branches_.insert(branches_.end(), |
|
|
|
|
|
tmp.begin(), |
|
|
|
|
|
tmp.end()); |
|
|
|
|
|
|
|
|
rv += ','; |
|
|
|
|
|
rv += num::humanize(_minfreespace.value()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return rv; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
void |
|
|
add_begin(Branches &branches_, |
|
|
|
|
|
const std::string &str_) |
|
|
|
|
|
|
|
|
Branch::set_minfreespace(const uint64_t minfreespace_) |
|
|
{ |
|
|
{ |
|
|
vector<string> paths; |
|
|
|
|
|
|
|
|
|
|
|
str::split(str_,':',&paths); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < paths.size(); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
Branches tmp; |
|
|
|
|
|
|
|
|
|
|
|
parse(paths[i],tmp); |
|
|
|
|
|
|
|
|
|
|
|
branches_.insert(branches_.begin(), |
|
|
|
|
|
tmp.begin(), |
|
|
|
|
|
tmp.end()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
_minfreespace = minfreespace_; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
add_end(Branches &branches_, |
|
|
|
|
|
const std::string &str_) |
|
|
|
|
|
|
|
|
uint64_t |
|
|
|
|
|
Branch::minfreespace(void) const |
|
|
{ |
|
|
{ |
|
|
vector<string> paths; |
|
|
|
|
|
|
|
|
|
|
|
str::split(str_,':',&paths); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < paths.size(); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
Branches tmp; |
|
|
|
|
|
|
|
|
|
|
|
parse(paths[i],tmp); |
|
|
|
|
|
|
|
|
|
|
|
branches_.insert(branches_.end(), |
|
|
|
|
|
tmp.begin(), |
|
|
|
|
|
tmp.end()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if(_minfreespace.has_value()) |
|
|
|
|
|
return _minfreespace.value(); |
|
|
|
|
|
return *_default_minfreespace; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
erase_begin(Branches &branches_) |
|
|
|
|
|
|
|
|
bool |
|
|
|
|
|
Branch::ro(void) const |
|
|
{ |
|
|
{ |
|
|
branches_.erase(branches_.begin()); |
|
|
|
|
|
|
|
|
return (mode == Branch::Mode::RO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
erase_end(Branches &branches_) |
|
|
|
|
|
|
|
|
bool |
|
|
|
|
|
Branch::nc(void) const |
|
|
{ |
|
|
{ |
|
|
branches_.pop_back(); |
|
|
|
|
|
|
|
|
return (mode == Branch::Mode::NC); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
erase_fnmatch(Branches &branches_, |
|
|
|
|
|
const std::string &str_) |
|
|
|
|
|
|
|
|
bool |
|
|
|
|
|
Branch::ro_or_nc(void) const |
|
|
{ |
|
|
{ |
|
|
vector<string> patterns; |
|
|
|
|
|
|
|
|
|
|
|
str::split(str_,':',&patterns); |
|
|
|
|
|
|
|
|
return ((mode == Branch::Mode::RO) || |
|
|
|
|
|
(mode == Branch::Mode::NC)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for(Branches::iterator i = branches_.begin(); |
|
|
|
|
|
i != branches_.end();) |
|
|
|
|
|
{ |
|
|
|
|
|
int match = FNM_NOMATCH; |
|
|
|
|
|
|
|
|
namespace l |
|
|
|
|
|
{ |
|
|
|
|
|
static |
|
|
|
|
|
void |
|
|
|
|
|
split(const std::string &s_, |
|
|
|
|
|
std::string *instr_, |
|
|
|
|
|
std::string *values_) |
|
|
|
|
|
{ |
|
|
|
|
|
uint64_t offset; |
|
|
|
|
|
|
|
|
|
|
|
offset = s_.find_first_of('/'); |
|
|
|
|
|
*instr_ = s_.substr(0,offset); |
|
|
|
|
|
if(offset != std::string::npos) |
|
|
|
|
|
*values_ = s_.substr(offset); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for(vector<string>::const_iterator pi = patterns.begin(); |
|
|
|
|
|
pi != patterns.end() && match != 0; |
|
|
|
|
|
++pi) |
|
|
|
|
|
{ |
|
|
|
|
|
match = ::fnmatch(pi->c_str(),i->path.c_str(),0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Branches::Branches(const uint64_t &default_minfreespace_) |
|
|
|
|
|
: default_minfreespace(default_minfreespace_) |
|
|
|
|
|
{ |
|
|
|
|
|
pthread_rwlock_init(&lock,NULL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
i = ((match == 0) ? branches_.erase(i) : (i+1)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
namespace l |
|
|
|
|
|
{ |
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
parse_mode(const string &str_, |
|
|
|
|
|
Branch::Mode *mode_) |
|
|
|
|
|
{ |
|
|
|
|
|
if(str_ == "RW") |
|
|
|
|
|
*mode_ = Branch::Mode::RW; |
|
|
|
|
|
ef(str_ == "RO") |
|
|
|
|
|
*mode_ = Branch::Mode::RO; |
|
|
|
|
|
ef(str_ == "NC") |
|
|
|
|
|
*mode_ = Branch::Mode::NC; |
|
|
|
|
|
else |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
parse_minfreespace(const string &str_, |
|
|
|
|
|
optional<uint64_t> *minfreespace_) |
|
|
|
|
|
{ |
|
|
|
|
|
int rv; |
|
|
|
|
|
uint64_t uint64; |
|
|
|
|
|
|
|
|
|
|
|
rv = str::from(str_,&uint64); |
|
|
|
|
|
if(rv < 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
|
|
|
|
|
|
*minfreespace_ = uint64; |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
parse_branch(const string &str_, |
|
|
|
|
|
string *glob_, |
|
|
|
|
|
Branch::Mode *mode_, |
|
|
|
|
|
optional<uint64_t> *minfreespace_) |
|
|
|
|
|
{ |
|
|
|
|
|
int rv; |
|
|
|
|
|
string options; |
|
|
|
|
|
vector<string> v; |
|
|
|
|
|
|
|
|
|
|
|
str::rsplit1(str_,'=',&v); |
|
|
|
|
|
switch(v.size()) |
|
|
|
|
|
{ |
|
|
|
|
|
case 1: |
|
|
|
|
|
*glob_ = v[0]; |
|
|
|
|
|
*mode_ = Branch::Mode::RW; |
|
|
|
|
|
break; |
|
|
|
|
|
case 2: |
|
|
|
|
|
*glob_ = v[0]; |
|
|
|
|
|
options = v[1]; |
|
|
|
|
|
v.clear(); |
|
|
|
|
|
str::split(options,',',&v); |
|
|
|
|
|
switch(v.size()) |
|
|
|
|
|
{ |
|
|
|
|
|
case 2: |
|
|
|
|
|
rv = l::parse_minfreespace(v[1],minfreespace_); |
|
|
|
|
|
if(rv < 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
case 1: |
|
|
|
|
|
rv = l::parse_mode(v[0],mode_); |
|
|
|
|
|
if(rv < 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
break; |
|
|
|
|
|
case 0: |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
parse(const string &str_, |
|
|
|
|
|
const uint64_t &default_minfreespace_, |
|
|
|
|
|
BranchVec *branches_) |
|
|
|
|
|
{ |
|
|
|
|
|
int rv; |
|
|
|
|
|
string glob; |
|
|
|
|
|
vector<string> globbed; |
|
|
|
|
|
optional<uint64_t> minfreespace; |
|
|
|
|
|
Branch branch(default_minfreespace_); |
|
|
|
|
|
|
|
|
|
|
|
rv = l::parse_branch(str_,&glob,&branch.mode,&minfreespace); |
|
|
|
|
|
if(rv < 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
|
|
|
|
|
|
if(minfreespace.has_value()) |
|
|
|
|
|
branch.set_minfreespace(minfreespace.value()); |
|
|
|
|
|
|
|
|
|
|
|
fs::glob(glob,&globbed); |
|
|
|
|
|
fs::realpathize(&globbed); |
|
|
|
|
|
for(size_t i = 0; i < globbed.size(); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
branch.path = globbed[i]; |
|
|
|
|
|
branches_->push_back(branch); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
set(const std::string &str_, |
|
|
|
|
|
Branches *branches_) |
|
|
|
|
|
{ |
|
|
|
|
|
int rv; |
|
|
|
|
|
vector<string> paths; |
|
|
|
|
|
BranchVec tmp_branchvec; |
|
|
|
|
|
|
|
|
|
|
|
str::split(str_,':',&paths); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < paths.size(); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
rv = l::parse(paths[i],branches_->default_minfreespace,&tmp_branchvec); |
|
|
|
|
|
if(rv < 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
branches_->vec.clear(); |
|
|
|
|
|
branches_->vec.insert(branches_->vec.end(), |
|
|
|
|
|
tmp_branchvec.begin(), |
|
|
|
|
|
tmp_branchvec.end()); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
add_begin(const std::string &str_, |
|
|
|
|
|
Branches *branches_) |
|
|
|
|
|
{ |
|
|
|
|
|
int rv; |
|
|
|
|
|
vector<string> paths; |
|
|
|
|
|
BranchVec tmp_branchvec; |
|
|
|
|
|
|
|
|
|
|
|
str::split(str_,':',&paths); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < paths.size(); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
rv = l::parse(paths[i],branches_->default_minfreespace,&tmp_branchvec); |
|
|
|
|
|
if(rv < 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
branches_->vec.insert(branches_->vec.begin(), |
|
|
|
|
|
tmp_branchvec.begin(), |
|
|
|
|
|
tmp_branchvec.end()); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
add_end(const std::string &str_, |
|
|
|
|
|
Branches *branches_) |
|
|
|
|
|
{ |
|
|
|
|
|
int rv; |
|
|
|
|
|
vector<string> paths; |
|
|
|
|
|
BranchVec tmp_branchvec; |
|
|
|
|
|
|
|
|
|
|
|
str::split(str_,':',&paths); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < paths.size(); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
rv = l::parse(paths[i],branches_->default_minfreespace,&tmp_branchvec); |
|
|
|
|
|
if(rv < 0) |
|
|
|
|
|
return rv; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
branches_->vec.insert(branches_->vec.end(), |
|
|
|
|
|
tmp_branchvec.begin(), |
|
|
|
|
|
tmp_branchvec.end()); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
erase_begin(BranchVec *branches_) |
|
|
|
|
|
{ |
|
|
|
|
|
branches_->erase(branches_->begin()); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
erase_end(BranchVec *branches_) |
|
|
|
|
|
{ |
|
|
|
|
|
branches_->pop_back(); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
|
int |
|
|
|
|
|
erase_fnmatch(const std::string &str_, |
|
|
|
|
|
Branches *branches_) |
|
|
|
|
|
{ |
|
|
|
|
|
vector<string> patterns; |
|
|
|
|
|
|
|
|
|
|
|
str::split(str_,':',&patterns); |
|
|
|
|
|
|
|
|
|
|
|
for(BranchVec::iterator i = branches_->vec.begin(); |
|
|
|
|
|
i != branches_->vec.end();) |
|
|
|
|
|
{ |
|
|
|
|
|
int match = FNM_NOMATCH; |
|
|
|
|
|
|
|
|
|
|
|
for(vector<string>::const_iterator pi = patterns.begin(); |
|
|
|
|
|
pi != patterns.end() && match != 0; |
|
|
|
|
|
++pi) |
|
|
|
|
|
{ |
|
|
|
|
|
match = ::fnmatch(pi->c_str(),i->path.c_str(),0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
i = ((match == 0) ? branches_->vec.erase(i) : (i+1)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int |
|
|
int |
|
|
Branches::from_string(const std::string &s_) |
|
|
Branches::from_string(const std::string &s_) |
|
|
{ |
|
|
{ |
|
|
rwlock::WriteGuard guard(&lock); |
|
|
|
|
|
|
|
|
rwlock::WriteGuard guard(lock); |
|
|
|
|
|
|
|
|
std::string instr; |
|
|
std::string instr; |
|
|
std::string values; |
|
|
std::string values; |
|
|
|
|
|
|
|
|
::split(s_,&instr,&values); |
|
|
|
|
|
|
|
|
l::split(s_,&instr,&values); |
|
|
|
|
|
|
|
|
if(instr == "+") |
|
|
if(instr == "+") |
|
|
::add_end(*this,values); |
|
|
|
|
|
ef(instr == "+<") |
|
|
|
|
|
::add_begin(*this,values); |
|
|
|
|
|
ef(instr == "+>") |
|
|
|
|
|
::add_end(*this,values); |
|
|
|
|
|
ef(instr == "-") |
|
|
|
|
|
::erase_fnmatch(*this,values); |
|
|
|
|
|
ef(instr == "-<") |
|
|
|
|
|
::erase_begin(*this); |
|
|
|
|
|
ef(instr == "->") |
|
|
|
|
|
::erase_end(*this); |
|
|
|
|
|
ef(instr == "=") |
|
|
|
|
|
::set(*this,values); |
|
|
|
|
|
ef(instr.empty()) |
|
|
|
|
|
::set(*this,values); |
|
|
|
|
|
else |
|
|
|
|
|
return -EINVAL; |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
return l::add_end(values,this); |
|
|
|
|
|
if(instr == "+<") |
|
|
|
|
|
return l::add_begin(values,this); |
|
|
|
|
|
if(instr == "+>") |
|
|
|
|
|
return l::add_end(values,this); |
|
|
|
|
|
if(instr == "-") |
|
|
|
|
|
return l::erase_fnmatch(values,this); |
|
|
|
|
|
if(instr == "-<") |
|
|
|
|
|
return l::erase_begin(&vec); |
|
|
|
|
|
if(instr == "->") |
|
|
|
|
|
return l::erase_end(&vec); |
|
|
|
|
|
if(instr == "=") |
|
|
|
|
|
return l::set(values,this); |
|
|
|
|
|
if(instr.empty()) |
|
|
|
|
|
return l::set(values,this); |
|
|
|
|
|
|
|
|
|
|
|
return -EINVAL; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
string |
|
|
string |
|
|
Branches::to_string(void) const |
|
|
Branches::to_string(void) const |
|
|
{ |
|
|
{ |
|
|
rwlock::ReadGuard guard(&lock); |
|
|
|
|
|
|
|
|
rwlock::ReadGuard guard(lock); |
|
|
|
|
|
|
|
|
string tmp; |
|
|
string tmp; |
|
|
|
|
|
|
|
|
for(size_t i = 0; i < size(); i++) |
|
|
|
|
|
|
|
|
for(size_t i = 0; i < vec.size(); i++) |
|
|
{ |
|
|
{ |
|
|
const Branch &branch = (*this)[i]; |
|
|
|
|
|
|
|
|
|
|
|
tmp += branch.path; |
|
|
|
|
|
|
|
|
|
|
|
tmp += '='; |
|
|
|
|
|
switch(branch.mode) |
|
|
|
|
|
{ |
|
|
|
|
|
default: |
|
|
|
|
|
case Branch::RW: |
|
|
|
|
|
tmp += "RW"; |
|
|
|
|
|
break; |
|
|
|
|
|
case Branch::RO: |
|
|
|
|
|
tmp += "RO"; |
|
|
|
|
|
break; |
|
|
|
|
|
case Branch::NC: |
|
|
|
|
|
tmp += "NC"; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const Branch &branch = vec[i]; |
|
|
|
|
|
|
|
|
|
|
|
tmp += branch.to_string(); |
|
|
tmp += ':'; |
|
|
tmp += ':'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -274,11 +419,11 @@ Branches::to_string(void) const |
|
|
void |
|
|
void |
|
|
Branches::to_paths(vector<string> &vec_) const |
|
|
Branches::to_paths(vector<string> &vec_) const |
|
|
{ |
|
|
{ |
|
|
rwlock::ReadGuard guard(&lock); |
|
|
|
|
|
|
|
|
rwlock::ReadGuard guard(lock); |
|
|
|
|
|
|
|
|
for(size_t i = 0; i < size(); i++) |
|
|
|
|
|
|
|
|
for(size_t i = 0; i < vec.size(); i++) |
|
|
{ |
|
|
{ |
|
|
const Branch &branch = (*this)[i]; |
|
|
|
|
|
|
|
|
const Branch &branch = vec[i]; |
|
|
|
|
|
|
|
|
vec_.push_back(branch.path); |
|
|
vec_.push_back(branch.path); |
|
|
} |
|
|
} |
|
@ -299,12 +444,13 @@ SrcMounts::from_string(const std::string &s_) |
|
|
std::string |
|
|
std::string |
|
|
SrcMounts::to_string(void) const |
|
|
SrcMounts::to_string(void) const |
|
|
{ |
|
|
{ |
|
|
rwlock::ReadGuard guard(&_branches.lock); |
|
|
|
|
|
|
|
|
rwlock::ReadGuard guard(_branches.lock); |
|
|
|
|
|
|
|
|
std::string rv; |
|
|
std::string rv; |
|
|
|
|
|
|
|
|
for(uint64_t i = 0; i < _branches.size(); i++) |
|
|
|
|
|
|
|
|
for(uint64_t i = 0; i < _branches.vec.size(); i++) |
|
|
{ |
|
|
{ |
|
|
rv += _branches[i].path; |
|
|
|
|
|
|
|
|
rv += _branches.vec[i].path; |
|
|
rv += ':'; |
|
|
rv += ':'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|