minor refactor towards recursive dir_stat impl

This commit is contained in:
Doug MacEachern 2005-12-14 02:15:04 +00:00
parent f8060d5cf9
commit e058d29cc3

View File

@ -368,9 +368,10 @@ static __inline int file_type(char *file)
} }
} }
SIGAR_DECLARE(int) sigar_dir_stat_get(sigar_t *sigar, static int dir_stat_get(sigar_t *sigar,
const char *dir, const char *dir,
sigar_dir_stat_t *dirstats) sigar_dir_stat_t *dirstats,
int recurse)
{ {
char name[SIGAR_PATH_MAX+1]; char name[SIGAR_PATH_MAX+1];
int len = strlen(dir); int len = strlen(dir);
@ -381,7 +382,6 @@ SIGAR_DECLARE(int) sigar_dir_stat_get(sigar_t *sigar,
DWORD error; DWORD error;
char delim; char delim;
SIGAR_ZERO(dirstats);
if (file_type((char *)dir) != SIGAR_FILETYPE_DIR) { if (file_type((char *)dir) != SIGAR_FILETYPE_DIR) {
return ERROR_NO_MORE_FILES; return ERROR_NO_MORE_FILES;
} }
@ -468,6 +468,14 @@ SIGAR_DECLARE(int) sigar_dir_stat_get(sigar_t *sigar,
return SIGAR_OK; return SIGAR_OK;
} }
SIGAR_DECLARE(int) sigar_dir_stat_get(sigar_t *sigar,
const char *dir,
sigar_dir_stat_t *dirstats)
{
SIGAR_ZERO(dirstats);
return dir_stat_get(sigar, dir, dirstats, 0);
}
#else #else
#include <dirent.h> #include <dirent.h>
@ -696,7 +704,7 @@ int sigar_dir_stat_get(sigar_t *sigar,
const char *dir, const char *dir,
sigar_dir_stat_t *dirstats) sigar_dir_stat_t *dirstats)
{ {
SIGAR_ZERO(dirstats); SIGAR_ZERO(dirstats);
return dir_stat_get(sigar, dir, dirstats, 0); return dir_stat_get(sigar, dir, dirstats, 0);
} }