diff options
author | Carlos Une <brocolis@eml.cc> | 2021-07-07 00:38:31 -0300 |
---|---|---|
committer | Carlos Une <brocolis@eml.cc> | 2021-07-07 00:38:31 -0300 |
commit | db869aa38ad7736df9eec5dfb8ac05b4ba45590b (patch) | |
tree | bdbf95df35ee864367c4c0ca8809a150c0ab5db4 /src/c.c | |
parent | 7de24a6cf2a8bb13eda0a9921c6c5f9062fe159c (diff) | |
download | fpm-db869aa38ad7736df9eec5dfb8ac05b4ba45590b.tar.gz fpm-db869aa38ad7736df9eec5dfb8ac05b4ba45590b.zip |
Add C wrapper for file listing
Diffstat (limited to 'src/c.c')
-rw-r--r-- | src/c.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -0,0 +1,22 @@ +/* FIXME: fpm --flag '-DENABLE_C_WRAPPER' currently doesn't work with .c files. Use #if..#endif below for the time being. */ +#if ((defined(_WIN32) && (defined(__MINGW32__) || defined(__MINGW64__))) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__)) +#define ENABLE_C_WRAPPER +#endif + +#ifdef ENABLE_C_WRAPPER +#include <sys/stat.h> +#include <dirent.h> + +int is_dir(const char *path) +{ + struct stat m; + int r = stat(path, &m); + return r == 0 && S_ISDIR(m.st_mode); +} + +const char *get_d_name(struct dirent *d) +{ + return (const char *) d->d_name; +} + +#endif |