12#include "dlinear/util/logging.h"
17 const std::size_t idx = name.rfind(
'.');
18 if (idx == std::string::npos)
return "";
19 return name.substr(idx + 1);
23 std::vector<std::string> r;
24 for (
const char *p = in; *p; ++p) {
25 while (*p ==
' ' || *p ==
'\t' || *p ==
'\r') ++p;
26 if (*p ==
'\0')
break;
28 while (p[length] !=
' ' && p[length] !=
'\t' && p[length] !=
'\r' && p[length]) ++length;
29 r.emplace_back(p, length);
35std::vector<std::string>
GetFiles(
const std::string &path,
const std::string &extension) {
36 std::vector<std::string> files;
37 for (
const std::filesystem::directory_entry &entry : std::filesystem::directory_iterator(path)) {
38 if (!extension.empty() && entry.path().extension() != extension)
continue;
39 files.emplace_back(entry.path());
Global namespace for the dlinear library.
std::vector< std::string > GetFiles(const std::string &path, const std::string &extension)
Get the files in a directory.
std::string GetExtension(const std::string &name)
Get the extension of the file.
std::vector< std::string > SplitStringByWhitespace(const char *in)
Split a C-string by whitespace.