os_util.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:wptagent 作者: WPO-Foundation 项目源码 文件源码
def get_free_disk_space():
    """Return the number of bytes free on the given disk in Gigabytes (floating)"""
    path = os.path.dirname(os.path.realpath(__file__))
    if platform.system() == 'Windows':
        import ctypes
        free_bytes = ctypes.c_ulonglong(0)
        ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(path),
                                                   None, None, ctypes.pointer(free_bytes))
        return float(free_bytes.value / 1024 / 1024) / 1024.0
    else:
        stat = os.statvfs(path)
        return float(stat.f_bavail * stat.f_frsize / 1024 / 1024) / 1024.0
# pylint: enable=E1101
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号