My dmenu build
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
пре 13 година
1234567891011121314151617181920212223242526272829303132333435363738
  1. /* See LICENSE file for copyright and license details. */
  2. #include <dirent.h>
  3. #include <limits.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include <sys/stat.h>
  8. static void lsx(const char *dir);
  9. int
  10. main(int argc, char *argv[]) {
  11. int i;
  12. if(argc < 2)
  13. lsx(".");
  14. else for(i = 1; i < argc; i++)
  15. lsx(argv[i]);
  16. return EXIT_SUCCESS;
  17. }
  18. void
  19. lsx(const char *dir) {
  20. char buf[PATH_MAX];
  21. struct dirent *d;
  22. struct stat st;
  23. DIR *dp;
  24. if(!(dp = opendir(dir))) {
  25. perror(dir);
  26. return;
  27. }
  28. while((d = readdir(dp)))
  29. if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < (int)sizeof buf
  30. && !stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0)
  31. puts(d->d_name);
  32. closedir(dp);
  33. }