summaryrefslogtreecommitdiff
path: root/filesystem.c
diff options
context:
space:
mode:
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
+}