| 156 | } |
| 157 | |
| 158 | DirectoryLoader::DirectoryLoader(const std::string &dir_path, |
| 159 | const std::vector<loco::Node *> &input_nodes) |
| 160 | : _input_nodes{input_nodes} |
| 161 | { |
| 162 | DIR *dir = opendir(dir_path.c_str()); |
| 163 | if (not dir) |
| 164 | { |
| 165 | throw std::runtime_error("Cannot open directory \"" + dir_path + "\"."); |
| 166 | } |
| 167 | |
| 168 | struct dirent *entry = nullptr; |
| 169 | const auto input_total_bytes = getTotalByteSizeOf(input_nodes); |
| 170 | while ((entry = readdir(dir))) |
| 171 | { |
| 172 | // Skip if the entry is not a regular file |
| 173 | if (entry->d_type != DT_REG) |
| 174 | continue; |
| 175 | |
| 176 | _data_paths.push_back(dir_path + "/" + entry->d_name); |
| 177 | } |
| 178 | |
| 179 | closedir(dir); |
| 180 | } |
| 181 | |
| 182 | uint32_t DirectoryLoader::size(void) const { return _data_paths.size(); } |
| 183 |
nothing calls this directly
no test coverage detected