junction.py 文件源码

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

项目:conv2mp4-py 作者: Kameecoding 项目源码 文件源码
def readlink(path):
    # Make sure the path exists and is actually a junction
    if not isjunction(path):
        raise Exception("%s does not exist or is not a junction" % path)

    hlink = CreateFile(path, fs.GENERIC_READ, fs.FILE_SHARE_READ, None,
        fs.OPEN_EXISTING,
        fs.FILE_FLAG_OPEN_REPARSE_POINT | fs.FILE_FLAG_BACKUP_SEMANTICS,
        None)
    if hlink == fs.INVALID_HANDLE_VALUE:
        raise WinError()

    try:
        (junctioninfo, infolen) = new_junction_reparse_buffer()
        dummy = DWORD(0)
        res = DeviceIoControl(
            hlink,
            FSCTL_GET_REPARSE_POINT,
            None,
            0,
            byref(junctioninfo),
            infolen,
            byref(dummy),
            None)

        if res == 0:
            raise WinError()

        return unparsed_unconvert(junctioninfo.SubstituteNameBuffer)
    finally:
        CloseHandle(hlink)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号