Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/du/du.c
| Show First 20 Lines • Show All 264 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
| if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL) | if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL) | ||||
| xo_err(1, "fts_open"); | xo_err(1, "fts_open"); | ||||
| xo_set_version(DU_XO_VERSION); | xo_set_version(DU_XO_VERSION); | ||||
| xo_open_container("disk-usage-information"); | xo_open_container("disk-usage-information"); | ||||
| xo_open_list("paths"); | xo_open_list("paths"); | ||||
| for (errno = 0; (p = fts_read(fts)) != NULL; errno = 0) { | for (errno = 0; (p = fts_read(fts)) != NULL; errno = 0) { | ||||
| if (info) { | |||||
| info = 0; | |||||
| (void)fprintf(stderr, "\t%s\n", p->fts_path); | |||||
| } | |||||
| switch (p->fts_info) { | switch (p->fts_info) { | ||||
| case FTS_D: /* Ignore. */ | case FTS_D: /* Ignore. */ | ||||
| if (ignorep(p)) | if (ignorep(p)) | ||||
| fts_set(fts, p, FTS_SKIP); | fts_set(fts, p, FTS_SKIP); | ||||
| break; | break; | ||||
| case FTS_DP: /* Directory files */ | case FTS_DP: /* Directory files */ | ||||
| if (ignorep(p)) | if (ignorep(p)) | ||||
| break; | break; | ||||
| record_file_size(p); | record_file_size(p); | ||||
| if (p->fts_level <= depth && check_threshold(p)) | if (p->fts_level <= depth && check_threshold(p)) | ||||
| print_file_size(p); | print_file_size(p); | ||||
| if (info) { | |||||
| info = 0; | |||||
| (void)printf("\t%s\n", p->fts_path); | |||||
| } | |||||
| break; | break; | ||||
| case FTS_DC: /* Ignore. */ | case FTS_DC: /* Ignore. */ | ||||
| break; | break; | ||||
| case FTS_DNR: /* Warn, continue. */ | case FTS_DNR: /* Warn, continue. */ | ||||
| case FTS_ERR: | case FTS_ERR: | ||||
| case FTS_NS: | case FTS_NS: | ||||
| xo_warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); | xo_warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); | ||||
| rval = 1; | rval = 1; | ||||
| ▲ Show 20 Lines • Show All 281 Lines • Show Last 20 Lines | |||||