mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-20 06:56:27 -05:00
Misc changes (#1513)
* Start moving to string_view where possible * Rework readdir object to use atomic load/store
This commit is contained in:
parent
2101ef5bcc
commit
6ac7f389c5
61 changed files with 841 additions and 745 deletions
|
|
@ -1,3 +1,66 @@
|
|||
#include "state.hpp"
|
||||
|
||||
#include "fmt/core.h"
|
||||
|
||||
#include "errno.hpp"
|
||||
|
||||
|
||||
State state;
|
||||
|
||||
// static
|
||||
// void
|
||||
// _register_getattr(State *state_)
|
||||
// {
|
||||
// State::GetSet x;
|
||||
|
||||
// x.get = [state_]() -> std::string
|
||||
// {
|
||||
// return state_->getattr.to_string();
|
||||
// };
|
||||
// x.set = [state_](const std::string_view s_) -> int
|
||||
// {
|
||||
// return state_->getattr.from_string(s_);
|
||||
// };
|
||||
|
||||
// state_->set_getset("user.mergerfs.func.getattr",x);
|
||||
// }
|
||||
|
||||
State::State()
|
||||
{
|
||||
// _register_getattr(this);
|
||||
}
|
||||
|
||||
void
|
||||
State::set_getset(const std::string &name_,
|
||||
const State::GetSet &gs_)
|
||||
{
|
||||
_getset[name_] = gs_;
|
||||
}
|
||||
|
||||
int
|
||||
State::get(const std::string &key_,
|
||||
std::string &val_)
|
||||
{
|
||||
std::map<std::string,State::GetSet>::iterator i;
|
||||
|
||||
i = _getset.find(key_);
|
||||
if((i == _getset.end()) || (!i->second.get))
|
||||
return -ENOATTR;
|
||||
|
||||
val_ = i->second.get();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
State::set(const std::string &key_,
|
||||
const std::string_view val_)
|
||||
{
|
||||
std::map<std::string,State::GetSet>::iterator i;
|
||||
|
||||
i = _getset.find(key_);
|
||||
if((i == _getset.end()) || (!i->second.set))
|
||||
return -ENOATTR;
|
||||
|
||||
return i->second.set(val_);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue