summaryrefslogtreecommitdiff
path: root/src/statvfs_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/statvfs_helper.c')
-rw-r--r--src/statvfs_helper.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/statvfs_helper.c b/src/statvfs_helper.c
new file mode 100644
index 0000000..8f6a4fe
--- /dev/null
+++ b/src/statvfs_helper.c
@@ -0,0 +1,19 @@
+#include <stdint.h>
+
+#ifdef _WIN32
+uint64_t statvfs_get_free_space_impl(const char* path) {
+ // Windows not implemented
+ (void)path;
+ return 0;
+}
+#else
+#include <sys/statvfs.h>
+
+uint64_t statvfs_get_free_space_impl(const char* path) {
+ struct statvfs stat;
+ if (statvfs(path, &stat) != 0) {
+ return 0;
+ }
+ return (uint64_t)stat.f_frsize * (uint64_t)stat.f_bavail;
+}
+#endif \ No newline at end of file