diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-06-29 09:34:37 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-06-29 09:43:00 -0400 |
commit | 973afcc40b52d71bfb1a1285806977fee9b843f6 (patch) | |
tree | 2798b5b0dd3f47021c29f9598d8ce3c33cfc33bb /src/common | |
parent | f0319fcbde2117098bcef12cc731600fd6a85afe (diff) | |
download | tor-973afcc40b52d71bfb1a1285806977fee9b843f6.tar.gz tor-973afcc40b52d71bfb1a1285806977fee9b843f6.zip |
Move tor_get_avail_disk_space() to lib/fs
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/compat.c | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/common/compat.c b/src/common/compat.c index 63bf99de68..b0a0a302c2 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -547,43 +547,3 @@ tor_getpass(const char *prompt, char *output, size_t buflen) #error "No implementation for tor_getpass found!" #endif /* defined(HAVE_READPASSPHRASE) || ... */ } - -/** Return the amount of free disk space we have permission to use, in - * bytes. Return -1 if the amount of free space can't be determined. */ -int64_t -tor_get_avail_disk_space(const char *path) -{ -#ifdef HAVE_STATVFS - struct statvfs st; - int r; - memset(&st, 0, sizeof(st)); - - r = statvfs(path, &st); - if (r < 0) - return -1; - - int64_t result = st.f_bavail; - if (st.f_frsize) { - result *= st.f_frsize; - } else if (st.f_bsize) { - result *= st.f_bsize; - } else { - return -1; - } - - return result; -#elif defined(_WIN32) - ULARGE_INTEGER freeBytesAvail; - BOOL ok; - - ok = GetDiskFreeSpaceEx(path, &freeBytesAvail, NULL, NULL); - if (!ok) { - return -1; - } - return (int64_t)freeBytesAvail.QuadPart; -#else - (void)path; - errno = ENOSYS; - return -1; -#endif /* defined(HAVE_STATVFS) || ... */ -} |