support recursion in dir_stat (win32)

This commit is contained in:
Doug MacEachern 2005-12-14 02:17:25 +00:00
parent e058d29cc3
commit 19d9d3fe5f
1 changed files with 10 additions and 0 deletions

View File

@ -373,6 +373,8 @@ static int dir_stat_get(sigar_t *sigar,
sigar_dir_stat_t *dirstats, sigar_dir_stat_t *dirstats,
int recurse) int recurse)
{ {
int status;
int do_log = SIGAR_LOG_IS_WARN(sigar);
char name[SIGAR_PATH_MAX+1]; char name[SIGAR_PATH_MAX+1];
int len = strlen(dir); int len = strlen(dir);
int max = sizeof(name)-len-1; int max = sizeof(name)-len-1;
@ -431,6 +433,14 @@ static int dir_stat_get(sigar_t *sigar,
break; break;
case SIGAR_FILETYPE_DIR: case SIGAR_FILETYPE_DIR:
++dirstats->subdirs; ++dirstats->subdirs;
if (recurse) {
status =
dir_stat_get(sigar, name,
dirstats, recurse);
if ((status != SIGAR_OK) && do_log) {
DIR_STAT_WARN();
}
}
break; break;
case SIGAR_FILETYPE_LNK: case SIGAR_FILETYPE_LNK:
++dirstats->symlinks; ++dirstats->symlinks;