pkg: call stat(2) in scan function

feature/tap-sh
William Pitcock 2012-07-26 00:07:27 -05:00
parent 0ac7978ee2
commit 79ca134f7f
2 changed files with 8 additions and 0 deletions

5
pkg.c
View File

@ -289,11 +289,16 @@ pkg_scan_dir(const char *path, pkg_iteration_func_t func)
static char filebuf[PKG_BUFSIZE];
pkg_t *pkg;
FILE *f;
struct stat st;
strlcpy(filebuf, path, sizeof filebuf);
strlcat(filebuf, "/", sizeof filebuf);
strlcat(filebuf, dirent->d_name, sizeof filebuf);
stat(filebuf, &st);
if (!(S_ISREG(st.st_mode)))
continue;
f = fopen(filebuf, "r");
if (f == NULL)
continue;

View File

@ -24,6 +24,9 @@
#include <string.h>
#include <libgen.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN