summaryrefslogtreecommitdiff
path: root/filesystem.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-03 20:55:42 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-03 20:55:42 -0500
commit16ab3629d435d52539b6345d79433e27c367ce83 (patch)
tree44fb3c7a13870dbd748e0f35d5236d6b3a31cb9a /filesystem.c
parent35cb8b8cfbd141d4ba2e3f1435a9550864d9e2e1 (diff)
make install, command line arguments
Diffstat (limited to 'filesystem.c')
-rw-r--r--filesystem.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/filesystem.c b/filesystem.c
new file mode 100644
index 0000000..f68fe72
--- /dev/null
+++ b/filesystem.c
@@ -0,0 +1,19 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#if __unix__
+#include <unistd.h>
+#endif
+
+static bool fs_file_exists(char const *path) {
+#if _WIN32
+ struct _stat statbuf = {0};
+ if (_stat(path, &statbuf) != 0)
+ return false;
+ return statbuf.st_mode == _S_IFREG;
+#else
+ struct stat statbuf = {0};
+ if (stat(path, &statbuf) != 0)
+ return false;
+ return S_ISREG(statbuf.st_mode);
+#endif
+}