20std::vector<std::string>
Str::tokenize(
const std::string&
src,
char delim,
bool trimToken,
bool skipEmpty)
22 std::stringstream ss(
src);
24 std::vector<std::string> tokens;
26 while (std::getline(ss, token, delim)) {
30 if (!token.empty() || !skipEmpty) {
31 tokens.push_back(std::move(token));
41 auto nextAllowed = [
pid]() {
42 constexpr char chars[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
43 constexpr size_t L =
sizeof(chars) - 1;
44 int rn = std::rand() |
pid;
47 std::string
str(lenght, 0);
48 std::generate_n(
str.begin(), lenght, nextAllowed);
54 return p.compare(0, 8,
"alien://") ? std::filesystem::exists(std::string{p}) :
true;
59 return std::filesystem::is_directory(std::string{p});
64 return std::filesystem::canonical(std::string{p}).
string();
70 if (dir.empty() || dir ==
"none") {
73 if (p.compare(0, 8,
"alien://") == 0) {
74 if (!gGrid && !TGrid::Connect(
"alien://")) {
75 throw std::runtime_error(fmt::format(
"failed to initialize alien for {}", dir));
84 throw std::runtime_error(fmt::format(
"{} is not an accessible directory", dir));
86 if (dir.back() !=
'/') {
101 bool needSlash =
pathIsDirectory(prefix) && !prefix.empty() && prefix.back() !=
'/';
GLuint GLsizei GLsizei * length
GLsizei const GLchar *const * path
static bool pathIsDirectory(const std::string_view p)
static void trim(std::string &s)
static std::string rectifyDirectory(const std::string_view p)
static bool pathExists(const std::string_view p)
static std::vector< std::string > tokenize(const std::string &src, char delim, bool trimToken=true, bool skipEmpty=true)
static std::string concat_string(Ts const &... ts)
static std::string getFullPath(const std::string_view p)
static std::string create_unique_path(const std::string_view prefix="", int length=16)
static bool endsWith(const std::string &s, const std::string &ending)
static std::string getRandomString(int length)