filesystem.py 文件源码

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

项目:transmission_scripts 作者: leighmacdonald 项目源码 文件源码
def get_free_space(dir_name):
    """Get free space in bytes for the path provided

    :param dir_name:
    :return:
    """
    if platform.system() == 'Windows':
        import ctypes
        free_bytes = ctypes.c_ulonglong(0)
        ctypes.windll.kernel32.GetDiskFreeSpaceExW(
            ctypes.c_wchar_p(dir_name), None, None, ctypes.pointer(free_bytes)
        )
        return free_bytes.value
    else:
        st = os.statvfs(dir_name)
        return st.f_bavail * st.f_frsize
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号