| 258 | } |
| 259 | |
| 260 | StrArr *ListFiles(const char *path) { |
| 261 | #ifdef HAVE_DIRENT_H |
| 262 | StrArr *result = new StrArr(); |
| 263 | DIR *dir = opendir(path); |
| 264 | if (!dir) |
| 265 | return NULL; |
| 266 | for (;;) { |
| 267 | struct dirent *entry = readdir(dir); |
| 268 | if (!entry) |
| 269 | break; |
| 270 | if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) |
| 271 | continue; |
| 272 | result->add(new Str(entry->d_name)); |
| 273 | } |
| 274 | closedir(dir); |
| 275 | return result; |
| 276 | #else |
| 277 | return NULL; |
| 278 | #endif |
| 279 | } |
| 280 | |
| 281 | StrArr *ListFiles(Str *path) { |
| 282 | return ListFiles(path->c_str()); |