| 1 |
// REQUIRES: (linux && !android) || freebsd |
| 2 |
|
| 3 |
// RUN: rm -rf %t-dir |
| 4 |
// RUN: mkdir -p %t-dir |
| 5 |
// RUN: touch %t-dir/a %t-dir/b %t-dir/c |
| 6 |
|
| 7 |
// RUN: %clang %s -DTEMP_DIR='"'"%t-dir"'"' -o %t && %run %t 2>&1 |
| 8 |
|
| 9 |
#include <dirent.h> |
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
#include <string.h> |
| 13 |
|
| 14 |
int main(int argc, char **argv) { |
| 15 |
struct dirent **dirpp = NULL; |
| 16 |
int count = scandir(TEMP_DIR, &dirpp, NULL, NULL); |
| 17 |
fprintf(stderr, "count is %d\n", count); |
| 18 |
if (count >= 0) { |
| 19 |
for (int i = 0; i < count; ++i) { |
| 20 |
fprintf(stderr, "found %s\n", dirpp[i]->d_name); |
| 21 |
free(dirpp[i]); |
| 22 |
} |
| 23 |
free(dirpp); |
| 24 |
} |
| 25 |
return 0; |
| 26 |
} |