fts.c
changeset 112 9bfb339a8156
parent 77 49e0babccb23
equal deleted inserted replaced
111:2247473fd12d 112:9bfb339a8156
    41     for (i = 1; i < argc; i++) {
    41     for (i = 1; i < argc; i++) {
    42         paths[i - 1] = argv[i];
    42         paths[i - 1] = argv[i];
    43     }
    43     }
    44 
    44 
    45     paths[i] = NULL;
    45     paths[i] = NULL;
       
    46     errno = 0;
    46 
    47 
    47     if ((fts = fts_open (paths, FTS_NOSTAT, &compare)) == NULL) {
    48     if ((fts = fts_open (paths, FTS_NOSTAT, (void *)&compare)) == NULL) {
    48         perror ("fts_open");
    49         perror ("fts_open");
    49         return EXIT_FAILURE;
    50         return EXIT_FAILURE;
    50     }
    51     }
    51 
    52 
    52     while ((current = fts_read (fts)) != NULL) {
    53     while ((current = fts_read (fts)) != NULL) {
    53         if (!errno)
    54         if (!errno)
    54             printf ("%s/%s\n", current->fts_path, current->fts_name);
    55             printf ("%s/%s\n", current->fts_path, current->fts_name);
       
    56         else
       
    57             perror ("fts_read");
    55     }
    58     }
    56 
    59 
    57     if (fts_close (fts) < 0)
    60     if (fts_close (fts) < 0)
    58         perror ("fts_close");
    61         perror ("fts_close");
    59 
    62