def get_free_space(path): """Returns the number of free bytes.""" if sys.platform == 'win32': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(path), None, None, ctypes.pointer(free_bytes)) return free_bytes.value # For OSes other than Windows. f = fs.statvfs(path) # pylint: disable=E1101 return f.f_bfree * f.f_frsize
def get_free_space(path): """Returns the number of free bytes. On POSIX platforms, this returns the free space as visible by the current user. On some systems, there's a percentage of the free space on the partition that is only accessible as the root user. """ if sys.platform == 'win32': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW( ctypes.c_wchar_p(path), None, None, ctypes.pointer(free_bytes)) return free_bytes.value # For OSes other than Windows. f = fs.statvfs(path) # pylint: disable=E1101 return f.f_bfree * f.f_frsize