mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Rework of runtime interface (#1498)
Also have special error handling for when branches are invalid and ENOENT would be returned for getattr and readdir so users understand what is going on and the runtime interface can still be used to fix the problem.
This commit is contained in:
parent
e87867cd2a
commit
2b500f194a
37 changed files with 3376 additions and 822 deletions
49
src/str.cpp
49
src/str.cpp
|
|
@ -14,9 +14,13 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "str.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <fnmatch.h>
|
||||
|
|
@ -104,6 +108,28 @@ namespace str
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
splitkv(const std::string_view &str_,
|
||||
const char delimiter_,
|
||||
std::string &key_,
|
||||
std::string_view &val_)
|
||||
{
|
||||
size_t pos;
|
||||
|
||||
pos = str_.find(delimiter_);
|
||||
if(pos != std::string_view::npos)
|
||||
{
|
||||
key_ = str_.substr(0,pos);
|
||||
val_ = str_.substr(pos + 1,
|
||||
str_.size() - pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
key_ = str_;
|
||||
val_ = std::string_view{};
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
splitkv(const string &str_,
|
||||
const char delimiter_,
|
||||
|
|
@ -272,3 +298,26 @@ namespace str
|
|||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
str::eq(const char *s0_,
|
||||
const char *s1_)
|
||||
{
|
||||
return (strcmp(s0_,s1_) == 0);
|
||||
}
|
||||
|
||||
bool
|
||||
str::startswith(const char *s_,
|
||||
const char *p_)
|
||||
{
|
||||
while(*p_)
|
||||
{
|
||||
if(*p_ != *s_)
|
||||
return false;
|
||||
|
||||
p_++;
|
||||
s_++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue