forked from ariadne/pkgconf
pkg: call stat(2) in scan function
parent
0ac7978ee2
commit
79ca134f7f
5
pkg.c
5
pkg.c
|
@ -289,11 +289,16 @@ pkg_scan_dir(const char *path, pkg_iteration_func_t func)
|
||||||
static char filebuf[PKG_BUFSIZE];
|
static char filebuf[PKG_BUFSIZE];
|
||||||
pkg_t *pkg;
|
pkg_t *pkg;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
strlcpy(filebuf, path, sizeof filebuf);
|
strlcpy(filebuf, path, sizeof filebuf);
|
||||||
strlcat(filebuf, "/", sizeof filebuf);
|
strlcat(filebuf, "/", sizeof filebuf);
|
||||||
strlcat(filebuf, dirent->d_name, sizeof filebuf);
|
strlcat(filebuf, dirent->d_name, sizeof filebuf);
|
||||||
|
|
||||||
|
stat(filebuf, &st);
|
||||||
|
if (!(S_ISREG(st.st_mode)))
|
||||||
|
continue;
|
||||||
|
|
||||||
f = fopen(filebuf, "r");
|
f = fopen(filebuf, "r");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
3
stdinc.h
3
stdinc.h
|
@ -24,6 +24,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
|
Loading…
Reference in New Issue