From 65bdefaf7a0e0299e2a4361d107a9721eac9dd4e Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 24 Aug 2025 06:33:50 +0200 Subject: Handle statvfs in C. This is necessary for musl support because musl's version of struct statvfs contains bitfields, which Zig does not know how to import. --- src/statvfs_helper.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/statvfs_helper.c (limited to 'src/statvfs_helper.c') 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 + +#ifdef _WIN32 +uint64_t statvfs_get_free_space_impl(const char* path) { + // Windows not implemented + (void)path; + return 0; +} +#else +#include + +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 -- cgit v1.2.1