Created
December 22, 2025 11:08
-
-
Save oneman/8c608fc372e77779c92942a6e9e55925 to your computer and use it in GitHub Desktop.
You should try lsd!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <sys/types.h> | |
| #include <sys/stat.h> | |
| #include <fts.h> | |
| /* lsd is awesome */ | |
| int main(int argc, char **argv) { | |
| static char path[4096]; | |
| getcwd(path, sizeof(path)); | |
| FTS *fs; | |
| FTSENT *n; | |
| char *paths[] = { path, NULL }; | |
| fs = fts_open(paths, FTS_PHYSICAL, NULL); | |
| if (!fs) return 1; | |
| for (;;) { | |
| n = fts_read(fs); | |
| if (!n) break; | |
| if (n->fts_info == FTS_F) printf("%s\n", n->fts_path); | |
| } | |
| return fts_close(fs); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment