aboutsummaryrefslogtreecommitdiff
path: root/lsx.c
diff options
context:
space:
mode:
Diffstat (limited to 'lsx.c')
-rw-r--r--lsx.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lsx.c b/lsx.c
index 7b84acc..325c508 100644
--- a/lsx.c
+++ b/lsx.c
@@ -6,7 +6,7 @@
6#include <unistd.h> 6#include <unistd.h>
7#include <sys/stat.h> 7#include <sys/stat.h>
8 8
9static void lsx(const char *s); 9static void lsx(const char *dir);
10 10
11int 11int
12main(int argc, char *argv[]) { 12main(int argc, char *argv[]) {
@@ -34,9 +34,7 @@ lsx(const char *dir) {
34 } 34 }
35 while((d = readdir(dp))) { 35 while((d = readdir(dp))) {
36 snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name); 36 snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name);
37 if(stat(buf, &st) == -1) 37 if(stat(buf, &st) == 0 && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
38 perror(buf);
39 else if(S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
40 puts(d->d_name); 38 puts(d->d_name);
41 } 39 }
42 closedir(dp); 40 closedir(dp);