summaryrefslogtreecommitdiff
path: root/src/statvfs_helper.c
blob: 8f6a4fedadcb1d15c7d58f3ed1aac04bc604f110 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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