| 194 | #endif |
| 195 | |
| 196 | Status StatSelector(const PlatformFilename& dir_fn, const FileSelector& select, |
| 197 | int32_t nesting_depth, std::vector<FileInfo>* out) { |
| 198 | auto result = ListDir(dir_fn); |
| 199 | if (!result.ok()) { |
| 200 | auto status = result.status(); |
| 201 | if (select.allow_not_found && status.IsIOError()) { |
| 202 | ARROW_ASSIGN_OR_RAISE(bool exists, FileExists(dir_fn)); |
| 203 | if (!exists) { |
| 204 | return Status::OK(); |
| 205 | } |
| 206 | } |
| 207 | return status; |
| 208 | } |
| 209 | |
| 210 | for (const auto& child_fn : *result) { |
| 211 | PlatformFilename full_fn = dir_fn.Join(child_fn); |
| 212 | ARROW_ASSIGN_OR_RAISE(FileInfo info, StatFile(full_fn.ToNative())); |
| 213 | if (info.type() != FileType::NotFound) { |
| 214 | out->push_back(std::move(info)); |
| 215 | } |
| 216 | if (nesting_depth < select.max_recursion && select.recursive && |
| 217 | info.type() == FileType::Directory) { |
| 218 | RETURN_NOT_OK(StatSelector(full_fn, select, nesting_depth + 1, out)); |
| 219 | } |
| 220 | } |
| 221 | return Status::OK(); |
| 222 | } |
| 223 | |
| 224 | } // namespace |
| 225 | |