hs-hath-1.4.0: cbits/available.c
#include <stdint.h>
#ifdef _WIN32
#include <windows.h>
int64_t hath_available_bytes(const wchar_t *path)
{
ULARGE_INTEGER available;
if (!GetDiskFreeSpaceExW(path, &available, NULL, NULL))
return -1;
return (int64_t) available.QuadPart;
}
#else
#include <sys/statvfs.h>
int64_t hath_available_bytes(const char *path)
{
struct statvfs st;
if (statvfs(path, &st) != 0)
return -1;
return (int64_t) st.f_bavail * (int64_t) st.f_frsize;
}
#endif