brintos

brintos / llvm-project-archived public Read only

0
0
Text · 618 B · 20b5e11 Raw
27 lines · c
1// REQUIRES: (linux && !android) || freebsd2 3// RUN: rm -rf %t-dir4// RUN: mkdir -p %t-dir5// RUN: touch %t-dir/a %t-dir/b %t-dir/c6 7// RUN: %clang %s -DTEMP_DIR='"'"%t-dir"'"' -o %t && %run %t 2>&18 9#include <dirent.h>10#include <stdio.h>11#include <stdlib.h>12#include <string.h>13 14int 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}27