diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-08-24 06:33:50 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-08-24 06:33:50 +0200 |
commit | 65bdefaf7a0e0299e2a4361d107a9721eac9dd4e (patch) | |
tree | b605c47cb1ca162b1bd9893784938b43bc343f4c /src/statvfs_helper.c | |
parent | 16e6d5386fecba7895aa64c035eabec664472de6 (diff) |
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.
Diffstat (limited to 'src/statvfs_helper.c')
-rw-r--r-- | src/statvfs_helper.c | 19 |
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 |