recurse: ignore links
This commit is contained in:
parent
ad16c666dc
commit
b5ff71655d
|
@ -2,7 +2,7 @@
|
||||||
VERSION = 0.0
|
VERSION = 0.0
|
||||||
|
|
||||||
#CC = gcc
|
#CC = gcc
|
||||||
#CC = musl-gcc
|
CC = musl-gcc
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
CPPFLAGS = -D_POSIX_C_SOURCE=200112L
|
CPPFLAGS = -D_POSIX_C_SOURCE=200112L
|
||||||
CFLAGS = -Os -ansi -Wall -pedantic $(CPPFLAGS)
|
CFLAGS = -Os -ansi -Wall -pedantic $(CPPFLAGS)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "../util.h"
|
#include "../util.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -11,14 +12,14 @@ recurse(const char *path, void (*fn)(const char *))
|
||||||
{
|
{
|
||||||
char *cwd;
|
char *cwd;
|
||||||
struct dirent *d;
|
struct dirent *d;
|
||||||
|
struct stat st;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
|
|
||||||
if(!(dp = opendir(path))) {
|
if(lstat(path, &st) == -1 || !S_ISDIR(st.st_mode))
|
||||||
if(errno == ENOTDIR)
|
|
||||||
return;
|
return;
|
||||||
else
|
else if(!(dp = opendir(path)))
|
||||||
eprintf("opendir %s:", path);
|
eprintf("opendir %s:", path);
|
||||||
}
|
|
||||||
cwd = agetcwd();
|
cwd = agetcwd();
|
||||||
if(chdir(path) == -1)
|
if(chdir(path) == -1)
|
||||||
eprintf("chdir %s:", path);
|
eprintf("chdir %s:", path);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user