aboutsummaryrefslogtreecommitdiff
path: root/src/c.c
diff options
context:
space:
mode:
authorCarlos Une <brocolis@eml.cc>2021-07-07 00:38:31 -0300
committerCarlos Une <brocolis@eml.cc>2021-07-07 00:38:31 -0300
commitdb869aa38ad7736df9eec5dfb8ac05b4ba45590b (patch)
treebdbf95df35ee864367c4c0ca8809a150c0ab5db4 /src/c.c
parent7de24a6cf2a8bb13eda0a9921c6c5f9062fe159c (diff)
downloadfpm-db869aa38ad7736df9eec5dfb8ac05b4ba45590b.tar.gz
fpm-db869aa38ad7736df9eec5dfb8ac05b4ba45590b.zip
Add C wrapper for file listing
Diffstat (limited to 'src/c.c')
-rw-r--r--src/c.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/c.c b/src/c.c
new file mode 100644
index 0000000..8cfbd20
--- /dev/null
+++ b/src/c.c
@@ -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