21 #ifndef CYPRESS_UTIL_FILESYSTEM_HPP 22 #define CYPRESS_UTIL_FILESYSTEM_HPP 27 #include <unordered_set> 31 #include <sys/types.h> 35 namespace filesystem {
47 for (std::string &file : files) {
50 if (lstat(file.c_str(), &stat) != 0 || !S_ISREG(stat.st_mode)) {
61 std::unordered_set<std::string>
dirs(
const std::vector<std::string> &files);
69 auto it = dirs.cbegin();
70 size_t n = it->size();
71 const std::string &cmp = *it;
72 for (it++; it != dirs.end(); it++) {
73 auto p = std::mismatch(cmp.begin(), cmp.end(), it->begin());
74 if ((p.first - cmp.begin()) < ssize_t(n)) {
75 n = p.first - cmp.begin();
79 0, std::max(1UL, (n == dirs.cbegin()->size())
80 ? ((dirs.cbegin()->back() ==
'/') ? n - 1 : n)
81 : cmp.rfind(sep, n)));
92 std::string
tmpfile(std::string &path);
std::unordered_set< std::string > dirs(const std::vector< std::string > &files)
std::string canonicalise(const std::string &file)
std::string longest_common_path(const T &dirs, char sep= '/')
Definition: filesystem.hpp:67
void canonicalise_files(T &files)
Definition: filesystem.hpp:45
Definition: brainscales_lib.hpp:39
std::string tmpfile(std::string &path)