namespace SecurityManager {
namespace FS {
+FileNameVector getDirsFromDirectory(const std::string &path)
+{
+ return getDirContents(path, S_IFDIR);
+}
+
FileNameVector getFilesFromDirectory(const std::string &path)
{
+ return getDirContents(path, S_IFREG);
+}
+
+FileNameVector getDirContents(const std::string &path, const mode_t &mode)
+{
FileNameVector result;
dirent tmp, *ptr;
int err;
ThrowMsg(FS::Exception::FileError, "Error reading: " << ptr->d_name);
}
- if (S_ISREG(finfo.st_mode)) {
+ if ((finfo.st_mode & S_IFMT) == mode)
result.push_back(ptr->d_name);
- }
}
return result;
typedef std::vector<std::string> FileNameVector;
+FileNameVector getDirContents(const std::string &path, const mode_t &mode);
FileNameVector getFilesFromDirectory(const std::string &path);
+FileNameVector getDirsFromDirectory(const std::string &path);
} // namespace FS
} // nanespace SecurityManager