Style inquistion for util and some tools.

This commit is contained in:
Christoph Lohmann
2013-03-05 21:46:48 +01:00
parent 52d39e35c2
commit f8dc6883a3
15 changed files with 100 additions and 32 deletions

View File

@@ -5,6 +5,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include "../util.h"
void
@@ -15,20 +16,25 @@ recurse(const char *path, void (*fn)(const char *))
struct stat st;
DIR *dp;
if(lstat(path, &st) == -1 || !S_ISDIR(st.st_mode))
if(lstat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
return;
else if(!(dp = opendir(path)))
} else if(!(dp = opendir(path))) {
eprintf("opendir %s:", path);
}
cwd = agetcwd();
if(chdir(path) == -1)
eprintf("chdir %s:", path);
while((d = readdir(dp)))
while((d = readdir(dp))) {
if(strcmp(d->d_name, ".") && strcmp(d->d_name, ".."))
fn(d->d_name);
}
closedir(dp);
if(chdir(cwd) == -1)
eprintf("chdir %s:", cwd);
free(cwd);
}