13 #ifndef __STOUT_OS_POSIX_LS_HPP__ 14 #define __STOUT_OS_POSIX_LS_HPP__ 31 DIR* dir = opendir(directory.c_str());
34 return ErrnoError(
"Failed to opendir '" + directory +
"'");
37 std::list<std::string> result;
44 while ((entry = readdir(dir)) !=
nullptr) {
45 if (strcmp(entry->d_name,
".") == 0 || strcmp(entry->d_name,
"..") == 0) {
48 result.push_back(entry->d_name);
58 if (closedir(dir) == -1) {
59 return ErrnoError(
"Failed to close directory");
67 #endif // __STOUT_OS_POSIX_LS_HPP__ Definition: errorbase.hpp:36
Definition: errorbase.hpp:50
Definition: posix_signalhandler.hpp:23
std::string error(const std::string &msg, uint32_t code)
Try< std::list< std::string > > ls(const std::string &directory)
Definition: ls.hpp:29