diff options
Diffstat (limited to 'lsx.c')
| -rw-r--r-- | lsx.c | 6 |
1 files changed, 2 insertions, 4 deletions
| @@ -6,7 +6,7 @@ | |||
| 6 | #include <unistd.h> | 6 | #include <unistd.h> |
| 7 | #include <sys/stat.h> | 7 | #include <sys/stat.h> |
| 8 | 8 | ||
| 9 | static void lsx(const char *s); | 9 | static void lsx(const char *dir); |
| 10 | 10 | ||
| 11 | int | 11 | int |
| 12 | main(int argc, char *argv[]) { | 12 | main(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); |
