42 char *str = getcwd(
nullptr, 0);
56 const std::string &extension)
62 std::string path = folder;
66 if (*path.rbegin() !=
'/')
68 if ((dir = opendir(path.c_str())) ==
nullptr)
71 while ((entry = readdir(dir)) !=
nullptr)
73 if (entry->d_type != DT_REG)
75 filename = entry->d_name;
76 if (filename.size() < extension.size())
78 if (std::equal(extension.rbegin(), extension.rend(), filename.rbegin()))
79 l.push_back(path + filename);
83 if (closedir(dir) == -1)
92 if ((pos = filename.find_last_of(
'/')) == std::string::npos)
95 return (filename.substr(pos + 1));
100 std::ifstream file(path);
103 throw(
FsException(
"could not open " + path +
'\''));
105 std::istreambuf_iterator<char>(
static_cast<std::istream &
>(file)),
106 std::istreambuf_iterator<char>()));
111 if (access(path.c_str(), F_OK) == -1)